Bug 967310 - optimize call to CacheFileIOManager::UnscheduleMetadataWrite, r=michal
authorHonza Bambas <honzab.moz@firemni.cz>
Mon, 23 Jun 2014 17:48:52 +0200
changeset 190144 0b5965befb37f76132f6e6707f9d5b338bd3bbb8
parent 190143 f5cec3f008aa50726cbc76e3bdd586e61c0720a2
child 190145 d4213538b0f3d99ad8feb6eda3f0676f310e0e37
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersmichal
bugs967310
milestone33.0a1
Bug 967310 - optimize call to CacheFileIOManager::UnscheduleMetadataWrite, r=michal
netwerk/cache2/CacheFile.cpp
--- a/netwerk/cache2/CacheFile.cpp
+++ b/netwerk/cache2/CacheFile.cpp
@@ -1685,29 +1685,29 @@ CacheFile::WriteMetadataIfNeededLocked(b
   AssertOwnsLock();
   MOZ_ASSERT(!mMemoryOnly);
 
   if (!mMetadata) {
     MOZ_CRASH("Must have metadata here");
     return;
   }
 
-  if (!aFireAndForget) {
-    // if aFireAndForget is set, we are called from dtor. Write
-    // scheduler hard-refers CacheFile otherwise, so we cannot be here.
-    CacheFileIOManager::UnscheduleMetadataWrite(this);
-  }
-
   if (NS_FAILED(mStatus))
     return;
 
   if (!IsDirty() || mOutput || mInputs.Length() || mChunks.Count() ||
       mWritingMetadata || mOpeningFile)
     return;
 
+  if (!aFireAndForget) {
+    // if aFireAndForget is set, we are called from dtor. Write
+    // scheduler hard-refers CacheFile otherwise, so we cannot be here.
+    CacheFileIOManager::UnscheduleMetadataWrite(this);
+  }
+
   LOG(("CacheFile::WriteMetadataIfNeededLocked() - Writing metadata [this=%p]",
        this));
 
   rv = mMetadata->WriteMetadata(mDataSize, aFireAndForget ? nullptr : this);
   if (NS_SUCCEEDED(rv)) {
     mWritingMetadata = true;
     mDataIsDirty = false;
   } else {