Bug 1536387 - Append a regular HTTP cache key tag of value 0x7f to distinguish memory-only entries, r=michal
authorHonza Bambas <honzab.moz@firemni.cz>
Wed, 20 Mar 2019 13:54:57 +0000
changeset 465229 1ac6a585937779eb00a89289822286600c3e8d51
parent 465228 d43f42ce6cf07fd76664767fafd1c55ee3e152bd
child 465230 6b9aee567032057ad7d598798362287297f85351
push id112496
push usershindli@mozilla.com
push dateThu, 21 Mar 2019 04:37:39 +0000
treeherdermozilla-inbound@29476d3ca61d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmichal
bugs1536387
milestone68.0a1
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
Bug 1536387 - Append a regular HTTP cache key tag of value 0x7f to distinguish memory-only entries, r=michal Differential Revision: https://phabricator.services.mozilla.com/D24170
netwerk/cache2/CacheStorageService.cpp
--- a/netwerk/cache2/CacheStorageService.cpp
+++ b/netwerk/cache2/CacheStorageService.cpp
@@ -35,19 +35,20 @@
 #include "mozilla/Services.h"
 #include "mozilla/IntegerPrintfMacros.h"
 
 namespace mozilla {
 namespace net {
 
 namespace {
 
-void AppendMemoryStorageID(nsAutoCString& key) {
-  key.Append('/');
-  key.Append('M');
+void AppendMemoryStorageTag(nsAutoCString& key) {
+  // Using DEL as the very last ascii-7 character we can use in the list of attributes
+  key.Append('\x7f');
+  key.Append(',');
 }
 
 }  // namespace
 
 // Not defining as static or class member of CacheStorageService since
 // it would otherwise need to include CacheEntry.h and that then would
 // need to be exported to make nsNetModule.cpp compilable.
 typedef nsClassHashtable<nsCStringHashKey, CacheEntryTable> GlobalEntryTables;
@@ -1055,17 +1056,17 @@ bool CacheStorageService::RemoveEntry(Ca
     }
   }
 
   CacheEntryTable* entries;
   if (sGlobalEntryTables->Get(aEntry->GetStorageID(), &entries))
     RemoveExactEntry(entries, entryKey, aEntry, false /* don't overwrite */);
 
   nsAutoCString memoryStorageID(aEntry->GetStorageID());
-  AppendMemoryStorageID(memoryStorageID);
+  AppendMemoryStorageTag(memoryStorageID);
 
   if (sGlobalEntryTables->Get(memoryStorageID, &entries))
     RemoveExactEntry(entries, entryKey, aEntry, false /* don't overwrite */);
 
   return true;
 }
 
 void CacheStorageService::RecordMemoryOnlyEntry(CacheEntry* aEntry,
@@ -1094,17 +1095,17 @@ void CacheStorageService::RecordMemoryOn
   rv = aEntry->HashingKey(entryKey);
   if (NS_FAILED(rv)) {
     NS_ERROR("aEntry->HashingKey() failed?");
     return;
   }
 
   CacheEntryTable* entries = nullptr;
   nsAutoCString memoryStorageID(aEntry->GetStorageID());
-  AppendMemoryStorageID(memoryStorageID);
+  AppendMemoryStorageTag(memoryStorageID);
 
   if (!sGlobalEntryTables->Get(memoryStorageID, &entries)) {
     if (!aOnlyInMemory) {
       LOG(("  not recorded as memory only"));
       return;
     }
 
     entries = new CacheEntryTable(CacheEntryTable::MEMORY_ONLY);
@@ -1523,17 +1524,17 @@ nsresult CacheStorageService::CheckStora
                                                 const nsACString& aIdExtension,
                                                 bool* aResult) {
   nsresult rv;
 
   nsAutoCString contextKey;
   CacheFileUtils::AppendKeyPrefix(aStorage->LoadInfo(), contextKey);
 
   if (!aStorage->WriteToDisk()) {
-    AppendMemoryStorageID(contextKey);
+    AppendMemoryStorageTag(contextKey);
   }
 
   LOG(("CacheStorageService::CheckStorageEntry [uri=%s, eid=%s, contextKey=%s]",
        aURI.BeginReading(), aIdExtension.BeginReading(), contextKey.get()));
 
   {
     mozilla::MutexAutoLock lock(mLock);
 
@@ -1796,17 +1797,17 @@ nsresult CacheStorageService::DoomStorag
   LOG(("CacheStorageService::DoomStorageEntries [context=%s]",
        aContextKey.BeginReading()));
 
   mLock.AssertCurrentThreadOwns();
 
   NS_ENSURE_TRUE(!mShutdown, NS_ERROR_NOT_INITIALIZED);
 
   nsAutoCString memoryStorageID(aContextKey);
-  AppendMemoryStorageID(memoryStorageID);
+  AppendMemoryStorageTag(memoryStorageID);
 
   if (aDiskStorage) {
     LOG(("  dooming disk+memory storage of %s", aContextKey.BeginReading()));
 
     // Walk one by one and remove entries according their pin status
     CacheEntryTable *diskEntries, *memoryEntries;
     if (sGlobalEntryTables->Get(aContextKey, &diskEntries)) {
       sGlobalEntryTables->Get(memoryStorageID, &memoryEntries);