summaryrefslogtreecommitdiffstats
path: root/netwerk/cache2/CacheFileIOManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'netwerk/cache2/CacheFileIOManager.cpp')
-rw-r--r--netwerk/cache2/CacheFileIOManager.cpp44
1 files changed, 32 insertions, 12 deletions
diff --git a/netwerk/cache2/CacheFileIOManager.cpp b/netwerk/cache2/CacheFileIOManager.cpp
index 8cff1c1cd9..89cd4497ad 100644
--- a/netwerk/cache2/CacheFileIOManager.cpp
+++ b/netwerk/cache2/CacheFileIOManager.cpp
@@ -2026,26 +2026,46 @@ nsresult CacheFileIOManager::Write(CacheFileHandle* aHandle, int64_t aOffset,
"validate=%d, truncate=%d, listener=%p]",
aHandle, aOffset, aCount, aValidate, aTruncate, aCallback));
- nsresult rv;
+ MOZ_ASSERT(aCallback);
+
RefPtr<CacheFileIOManager> ioMan = gInstance;
- if (aHandle->IsClosed() || (aCallback && aCallback->IsKilled()) || !ioMan) {
- if (!aCallback) {
- // When no callback is provided, CacheFileIOManager is responsible for
- // releasing the buffer. We must release it even in case of failure.
- free(const_cast<char*>(aBuf));
- }
+ if (aHandle->IsClosed() || aCallback->IsKilled() || !ioMan) {
return NS_ERROR_NOT_INITIALIZED;
}
RefPtr<WriteEvent> ev = new WriteEvent(aHandle, aOffset, aBuf, aCount,
aValidate, aTruncate, aCallback);
- rv = ioMan->mIOThread->Dispatch(ev, aHandle->mPriority
- ? CacheIOThread::WRITE_PRIORITY
- : CacheIOThread::WRITE);
- NS_ENSURE_SUCCESS(rv, rv);
+ return ioMan->mIOThread->Dispatch(ev, aHandle->mPriority
+ ? CacheIOThread::WRITE_PRIORITY
+ : CacheIOThread::WRITE);
+}
- return NS_OK;
+// static
+nsresult CacheFileIOManager::WriteWithoutCallback(CacheFileHandle* aHandle,
+ int64_t aOffset, char* aBuf,
+ int32_t aCount,
+ bool aValidate,
+ bool aTruncate) {
+ LOG(("CacheFileIOManager::WriteWithoutCallback() [handle=%p, offset=%" PRId64
+ ", count=%d, "
+ "validate=%d, truncate=%d]",
+ aHandle, aOffset, aCount, aValidate, aTruncate));
+
+ RefPtr<CacheFileIOManager> ioMan = gInstance;
+
+ if (aHandle->IsClosed() || !ioMan) {
+ // When no callback is provided, CacheFileIOManager is responsible for
+ // releasing the buffer. We must release it even in case of failure.
+ free(aBuf);
+ return NS_ERROR_NOT_INITIALIZED;
+ }
+
+ RefPtr<WriteEvent> ev = new WriteEvent(aHandle, aOffset, aBuf, aCount,
+ aValidate, aTruncate, nullptr);
+ return ioMan->mIOThread->Dispatch(ev, aHandle->mPriority
+ ? CacheIOThread::WRITE_PRIORITY
+ : CacheIOThread::WRITE);
}
static nsresult TruncFile(PRFileDesc* aFD, int64_t aEOF) {