Backed out changeset ce8f00cca9dd (bug 1000338) for XPC-2 test failures
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Thu, 11 Sep 2014 14:31:54 +0200
changeset 228077 46a22a5950fcaed2374fa5a6853f3e1a1490bb27
parent 228076 6d1071f4d95ec0b0f86130afcfec5ca12eb35a38
child 228078 b4102ee7bdf23bf241d96e84a38b0a47bbe57247
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1000338
milestone35.0a1
backs outce8f00cca9ddd0daa58a296b88c96bce1f100df5
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset ce8f00cca9dd (bug 1000338) for XPC-2 test failures
netwerk/cache2/CacheEntry.cpp
netwerk/cache2/CacheFile.cpp
netwerk/cache2/CacheFile.h
netwerk/cache2/CacheFileMetadata.cpp
netwerk/cache2/CacheFileMetadata.h
netwerk/test/unit/test_cache2-28-last-access-attrs.js
netwerk/test/unit/xpcshell.ini
--- a/netwerk/cache2/CacheEntry.cpp
+++ b/netwerk/cache2/CacheEntry.cpp
@@ -754,21 +754,16 @@ void CacheEntry::InvokeAvailableCallback
     nsRefPtr<AvailableCallbackRunnable> event =
       new AvailableCallbackRunnable(this, aCallback);
 
     rv = aCallback.mTargetThread->Dispatch(event, nsIEventTarget::DISPATCH_NORMAL);
     LOG(("  redispatched, (rv = 0x%08x)", rv));
     return;
   }
 
-  if (NS_SUCCEEDED(mFileStatus)) {
-    // Let the last-fetched and fetch-count properties be updated.
-    mFile->OnFetched();
-  }
-
   if (mIsDoomed || aCallback.mNotWanted) {
     LOG(("  doomed or not wanted, notifying OCEA with NS_ERROR_CACHE_KEY_NOT_FOUND"));
     aCallback.mCallback->OnCacheEntryAvailable(
       nullptr, false, nullptr, NS_ERROR_CACHE_KEY_NOT_FOUND);
     return;
   }
 
   if (state == READY) {
--- a/netwerk/cache2/CacheFile.cpp
+++ b/netwerk/cache2/CacheFile.cpp
@@ -906,16 +906,37 @@ CacheFile::GetExpirationTime(uint32_t *_
   CacheFileAutoLock lock(this);
   MOZ_ASSERT(mMetadata);
   NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);
 
   return mMetadata->GetExpirationTime(_retval);
 }
 
 nsresult
+CacheFile::SetLastModified(uint32_t aLastModified)
+{
+  CacheFileAutoLock lock(this);
+  MOZ_ASSERT(mMetadata);
+  NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);
+
+  PostWriteTimer();
+  return mMetadata->SetLastModified(aLastModified);
+}
+
+nsresult
+CacheFile::GetLastModified(uint32_t *_retval)
+{
+  CacheFileAutoLock lock(this);
+  MOZ_ASSERT(mMetadata);
+  NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);
+
+  return mMetadata->GetLastModified(_retval);
+}
+
+nsresult
 CacheFile::SetFrecency(uint32_t aFrecency)
 {
   CacheFileAutoLock lock(this);
   MOZ_ASSERT(mMetadata);
   NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);
 
   PostWriteTimer();
 
@@ -931,26 +952,16 @@ CacheFile::GetFrecency(uint32_t *_retval
   CacheFileAutoLock lock(this);
   MOZ_ASSERT(mMetadata);
   NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);
 
   return mMetadata->GetFrecency(_retval);
 }
 
 nsresult
-CacheFile::GetLastModified(uint32_t *_retval)
-{
-  CacheFileAutoLock lock(this);
-  MOZ_ASSERT(mMetadata);
-  NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);
-
-  return mMetadata->GetLastModified(_retval);
-}
-
-nsresult
 CacheFile::GetLastFetched(uint32_t *_retval)
 {
   CacheFileAutoLock lock(this);
   MOZ_ASSERT(mMetadata);
   NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);
 
   return mMetadata->GetLastFetched(_retval);
 }
@@ -960,28 +971,16 @@ CacheFile::GetFetchCount(uint32_t *_retv
 {
   CacheFileAutoLock lock(this);
   MOZ_ASSERT(mMetadata);
   NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);
 
   return mMetadata->GetFetchCount(_retval);
 }
 
-nsresult
-CacheFile::OnFetched()
-{
-  CacheFileAutoLock lock(this);
-  MOZ_ASSERT(mMetadata);
-  NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);
-
-  PostWriteTimer();
-
-  return mMetadata->OnFetched();
-}
-
 void
 CacheFile::Lock()
 {
   mLock.Lock();
 }
 
 void
 CacheFile::Unlock()
--- a/netwerk/cache2/CacheFile.h
+++ b/netwerk/cache2/CacheFile.h
@@ -85,24 +85,22 @@ public:
 
   // metadata forwarders
   nsresult GetElement(const char *aKey, char **_retval);
   nsresult SetElement(const char *aKey, const char *aValue);
   nsresult VisitMetaData(nsICacheEntryMetaDataVisitor *aVisitor);
   nsresult ElementsSize(uint32_t *_retval);
   nsresult SetExpirationTime(uint32_t aExpirationTime);
   nsresult GetExpirationTime(uint32_t *_retval);
+  nsresult SetLastModified(uint32_t aLastModified);
+  nsresult GetLastModified(uint32_t *_retval);
   nsresult SetFrecency(uint32_t aFrecency);
   nsresult GetFrecency(uint32_t *_retval);
-  nsresult GetLastModified(uint32_t *_retval);
   nsresult GetLastFetched(uint32_t *_retval);
   nsresult GetFetchCount(uint32_t *_retval);
-  // Called by upper layers to indicated the entry has been fetched,
-  // i.e. delivered to the consumer.
-  nsresult OnFetched();
 
   bool DataSize(int64_t* aSize);
   void Key(nsACString& aKey) { aKey = mKey; }
   bool IsDoomed();
   bool IsWriteInProgress();
 
   // Memory reporting
   size_t SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
--- a/netwerk/cache2/CacheFileMetadata.cpp
+++ b/netwerk/cache2/CacheFileMetadata.cpp
@@ -22,18 +22,16 @@
 namespace mozilla {
 namespace net {
 
 #define kMinMetadataRead 1024  // TODO find optimal value from telemetry
 #define kAlignSize       4096
 
 #define kCacheEntryVersion 1
 
-#define NOW_SECONDS() (uint32_t(PR_Now() / PR_USEC_PER_SEC))
-
 NS_IMPL_ISUPPORTS(CacheFileMetadata, CacheFileIOListener)
 
 CacheFileMetadata::CacheFileMetadata(CacheFileHandle *aHandle, const nsACString &aKey)
   : CacheMemoryConsumer(NORMAL)
   , mHandle(aHandle)
   , mHashArray(nullptr)
   , mHashArraySize(0)
   , mHashCount(0)
@@ -79,16 +77,17 @@ CacheFileMetadata::CacheFileMetadata(boo
 {
   LOG(("CacheFileMetadata::CacheFileMetadata() [this=%p, key=%s]",
        this, PromiseFlatCString(aKey).get()));
 
   MOZ_COUNT_CTOR(CacheFileMetadata);
   memset(&mMetaHdr, 0, sizeof(CacheFileMetadataHeader));
   mMetaHdr.mVersion = kCacheEntryVersion;
   mMetaHdr.mExpirationTime = nsICacheEntry::NO_EXPIRATION_TIME;
+  mMetaHdr.mFetchCount = 1;
   mKey = aKey;
   mMetaHdr.mKeySize = mKey.Length();
 
   DebugOnly<nsresult> rv;
   rv = ParseKey(aKey);
   MOZ_ASSERT(NS_SUCCEEDED(rv));
 }
 
@@ -500,87 +499,79 @@ CacheFileMetadata::SetHash(uint32_t aInd
 }
 
 nsresult
 CacheFileMetadata::SetExpirationTime(uint32_t aExpirationTime)
 {
   LOG(("CacheFileMetadata::SetExpirationTime() [this=%p, expirationTime=%d]",
        this, aExpirationTime));
 
-  MarkDirty(false);
+  MarkDirty();
   mMetaHdr.mExpirationTime = aExpirationTime;
   return NS_OK;
 }
 
 nsresult
 CacheFileMetadata::GetExpirationTime(uint32_t *_retval)
 {
   *_retval = mMetaHdr.mExpirationTime;
   return NS_OK;
 }
 
 nsresult
+CacheFileMetadata::SetLastModified(uint32_t aLastModified)
+{
+  LOG(("CacheFileMetadata::SetLastModified() [this=%p, lastModified=%d]",
+       this, aLastModified));
+
+  MarkDirty();
+  mMetaHdr.mLastModified = aLastModified;
+  return NS_OK;
+}
+
+nsresult
+CacheFileMetadata::GetLastModified(uint32_t *_retval)
+{
+  *_retval = mMetaHdr.mLastModified;
+  return NS_OK;
+}
+
+nsresult
 CacheFileMetadata::SetFrecency(uint32_t aFrecency)
 {
   LOG(("CacheFileMetadata::SetFrecency() [this=%p, frecency=%f]",
        this, (double)aFrecency));
 
-  MarkDirty(false);
+  MarkDirty();
   mMetaHdr.mFrecency = aFrecency;
   return NS_OK;
 }
 
 nsresult
 CacheFileMetadata::GetFrecency(uint32_t *_retval)
 {
   *_retval = mMetaHdr.mFrecency;
   return NS_OK;
 }
 
 nsresult
-CacheFileMetadata::GetLastModified(uint32_t *_retval)
-{
-  *_retval = mMetaHdr.mLastModified;
-  return NS_OK;
-}
-
-nsresult
 CacheFileMetadata::GetLastFetched(uint32_t *_retval)
 {
   *_retval = mMetaHdr.mLastFetched;
   return NS_OK;
 }
 
 nsresult
 CacheFileMetadata::GetFetchCount(uint32_t *_retval)
 {
   *_retval = mMetaHdr.mFetchCount;
   return NS_OK;
 }
 
 nsresult
-CacheFileMetadata::OnFetched()
-{
-  MarkDirty(false);
-
-  mMetaHdr.mLastFetched = NOW_SECONDS();
-  ++mMetaHdr.mFetchCount;
-  return NS_OK;
-}
-
-void
-CacheFileMetadata::MarkDirty(bool aUpdateLastModified)
-{
-  mIsDirty = true;
-  if (aUpdateLastModified) {
-    mMetaHdr.mLastModified = NOW_SECONDS();
-  }
-}
-
-nsresult
 CacheFileMetadata::OnFileOpened(CacheFileHandle *aHandle, nsresult aResult)
 {
   MOZ_CRASH("CacheFileMetadata::OnFileOpened should not be called!");
   return NS_ERROR_UNEXPECTED;
 }
 
 nsresult
 CacheFileMetadata::OnDataWritten(CacheFileHandle *aHandle, const char *aBuf,
@@ -725,17 +716,17 @@ CacheFileMetadata::InitEmptyMetadata()
 {
   if (mBuf) {
     free(mBuf);
     mBuf = nullptr;
     mBufSize = 0;
   }
   mOffset = 0;
   mMetaHdr.mVersion = kCacheEntryVersion;
-  mMetaHdr.mFetchCount = 0;
+  mMetaHdr.mFetchCount = 1;
   mMetaHdr.mExpirationTime = nsICacheEntry::NO_EXPIRATION_TIME;
   mMetaHdr.mKeySize = mKey.Length();
 
   DoMemoryReport(MemoryUsage());
 }
 
 nsresult
 CacheFileMetadata::ParseMetadata(uint32_t aMetaOffset, uint32_t aBufOffset,
@@ -836,16 +827,17 @@ CacheFileMetadata::ParseMetadata(uint32_
   mHashCount = hashCount;
   if (mHashArraySize) {
     mHashArray = static_cast<CacheHash::Hash16_t *>(
                    moz_xmalloc(mHashArraySize));
     memcpy(mHashArray, mBuf + hashesOffset, mHashArraySize);
   }
 
 
+  mMetaHdr.mFetchCount++;
   MarkDirty();
 
   mElementsSize = metaposOffset - elementsOffset;
   memmove(mBuf, mBuf + elementsOffset, mElementsSize);
   mOffset = aMetaOffset;
 
   // TODO: shrink memory if buffer is too big
 
--- a/netwerk/cache2/CacheFileMetadata.h
+++ b/netwerk/cache2/CacheFileMetadata.h
@@ -133,28 +133,26 @@ public:
   nsresult     SetElement(const char *aKey, const char *aValue);
   nsresult     Visit(nsICacheEntryMetaDataVisitor *aVisitor);
 
   CacheHash::Hash16_t GetHash(uint32_t aIndex);
   nsresult            SetHash(uint32_t aIndex, CacheHash::Hash16_t aHash);
 
   nsresult SetExpirationTime(uint32_t aExpirationTime);
   nsresult GetExpirationTime(uint32_t *_retval);
+  nsresult SetLastModified(uint32_t aLastModified);
+  nsresult GetLastModified(uint32_t *_retval);
   nsresult SetFrecency(uint32_t aFrecency);
   nsresult GetFrecency(uint32_t *_retval);
-  nsresult GetLastModified(uint32_t *_retval);
   nsresult GetLastFetched(uint32_t *_retval);
   nsresult GetFetchCount(uint32_t *_retval);
-  // Called by upper layers to indicate the entry this metadata belongs
-  // with has been fetched, i.e. delivered to the consumer.
-  nsresult OnFetched();
 
   int64_t  Offset() { return mOffset; }
   uint32_t ElementsSize() { return mElementsSize; }
-  void     MarkDirty(bool aUpdateLastModified = true);
+  void     MarkDirty() { mIsDirty = true; }
   bool     IsDirty() { return mIsDirty; }
   uint32_t MemoryUsage() { return sizeof(CacheFileMetadata) + mHashArraySize + mBufSize; }
 
   NS_IMETHOD OnFileOpened(CacheFileHandle *aHandle, nsresult aResult);
   NS_IMETHOD OnDataWritten(CacheFileHandle *aHandle, const char *aBuf,
                            nsresult aResult);
   NS_IMETHOD OnDataRead(CacheFileHandle *aHandle, char *aBuf, nsresult aResult);
   NS_IMETHOD OnFileDoomed(CacheFileHandle *aHandle, nsresult aResult);
deleted file mode 100644
--- a/netwerk/test/unit/test_cache2-28-last-access-attrs.js
+++ /dev/null
@@ -1,39 +0,0 @@
-function run_test()
-{
-  do_get_profile();
-  function NowSeconds() {
-    return parseInt((new Date()).getTime() / 1000);
-  }
-  function do_check_time(t, min, max) {
-    do_check_true(t >= min);
-    do_check_true(t <= max);
-  }
-
-  var timeStart = NowSeconds();
-
-  asyncOpenCacheEntry("http://t/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
-    new OpenCallback(NEW, "m", "d", function(entry) {
-
-      var firstOpen = NowSeconds();
-      do_check_eq(entry.fetchCount, 1);
-      do_check_time(entry.lastFetched, timeStart, firstOpen);
-      do_check_time(entry.lastModified, timeStart, firstOpen);
-
-      do_timeout(2000, () => {
-        asyncOpenCacheEntry("http://t/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
-          new OpenCallback(NORMAL, "m", "d", function(entry) {
-
-            var secondOpen = NowSeconds();
-            do_check_eq(entry.fetchCount, 2);
-            do_check_time(entry.lastFetched, firstOpen, secondOpen);
-            do_check_time(entry.lastModified, timeStart, firstOpen);
-
-            finish_cache2_test();
-          })
-        );
-      })
-    })
-  );
-
-  do_test_pending();
-}
--- a/netwerk/test/unit/xpcshell.ini
+++ b/netwerk/test/unit/xpcshell.ini
@@ -54,17 +54,16 @@ support-files =
 [test_cache2-22-anon-visit.js]
 [test_cache2-23-read-over-chunk.js]
 [test_cache2-24-exists.js]
 [test_cache2-25-chunk-memory-limit.js]
 [test_cache2-26-no-outputstream-open.js]
 # GC, that this patch is dependent on, doesn't work well on Android.
 skip-if = os == "android"
 [test_cache2-27-force-valid-for.js]
-[test_cache2-28-last-access-attrs.js]
 [test_304_responses.js]
 [test_cacheForOfflineUse_no-store.js]
 [test_307_redirect.js]
 [test_NetUtil.js]
 [test_URIs.js]
 [test_aboutblank.js]
 [test_assoc.js]
 [test_auth_jar.js]