bool GMPStorageParent::RecvRead(const nsCString& aRecordName) { LOGD(("%s::%s: %p record=%s", __CLASS__, __FUNCTION__, this, aRecordName.get())); if (mShutdown) { return true; } PRFileDesc* fd = mFiles.Get(aRecordName); nsTArray<uint8_t> data; if (!fd) { unused << SendReadComplete(aRecordName, GMPClosedErr, data); return true; } int32_t len = PR_Seek(fd, 0, PR_SEEK_END); PR_Seek(fd, 0, PR_SEEK_SET); if (len > GMP_MAX_RECORD_SIZE) { // Refuse to read big records. unused << SendReadComplete(aRecordName, GMPQuotaExceededErr, data); return true; } data.SetLength(len); auto bytesRead = PR_Read(fd, data.Elements(), len); auto res = (bytesRead == len) ? GMPNoErr : GMPGenericErr; unused << SendReadComplete(aRecordName, res, data); return true; }
bool GMPStorageParent::RecvRead(const nsCString& aRecordName) { LOGD(("GMPStorageParent[%p]::RecvRead(record='%s')", this, aRecordName.get())); if (mShutdown) { return false; } nsTArray<uint8_t> data; if (!mStorage->IsOpen(aRecordName)) { LOGD(("GMPStorageParent[%p]::RecvRead(record='%s') failed; record not open", this, aRecordName.get())); Unused << SendReadComplete(aRecordName, GMPClosedErr, data); } else { GMPErr rv = mStorage->Read(aRecordName, data); LOGD(("GMPStorageParent[%p]::RecvRead(record='%s') read %d bytes rv=%d", this, aRecordName.get(), data.Length(), rv)); Unused << SendReadComplete(aRecordName, rv, data); } return true; }