Bug 1206060 - Show pinning status at about:cache. r=michal
authorHonza Bambas <honzab.moz@firemni.cz>
Fri, 30 Oct 2015 08:12:00 +0100
changeset 270765 b531b32383d447c667f6d0687f3cc28f63595ebd
parent 270764 1e5910f48b8fcd274ef20359df8684a74b2f4443
child 270766 5cbef5458e6b5a0eaf47718003222d2b4dc5d4e4
push id29623
push userkwierso@gmail.com
push dateMon, 02 Nov 2015 23:12:59 +0000
treeherdermozilla-central@9f69202d8275 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmichal
bugs1206060
milestone45.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 1206060 - Show pinning status at about:cache. r=michal
netwerk/base/Predictor.cpp
netwerk/cache2/CacheEntry.h
netwerk/cache2/CacheFileIOManager.cpp
netwerk/cache2/CacheStorageService.cpp
netwerk/cache2/CacheStorageService.h
netwerk/cache2/OldWrappers.cpp
netwerk/cache2/nsICacheStorageVisitor.idl
netwerk/protocol/about/nsAboutCache.cpp
toolkit/themes/shared/aboutCache.css
--- a/netwerk/base/Predictor.cpp
+++ b/netwerk/base/Predictor.cpp
@@ -1852,17 +1852,18 @@ Predictor::Resetter::OnCacheStorageInfo(
   MOZ_ASSERT(NS_IsMainThread());
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 Predictor::Resetter::OnCacheEntryInfo(nsIURI *uri, const nsACString &idEnhance,
                                       int64_t dataSize, int32_t fetchCount,
-                                      uint32_t lastModifiedTime, uint32_t expirationTime)
+                                      uint32_t lastModifiedTime, uint32_t expirationTime,
+                                      bool aPinned)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // The predictor will only ever touch entries with no idEnhance ("") or an
   // idEnhance of PREDICTOR_ORIGIN_EXTENSION, so we filter out any entries that
   // don't match that to avoid doing extra work.
   if (idEnhance.EqualsLiteral(PREDICTOR_ORIGIN_EXTENSION)) {
     // This is an entry we own, so we can just doom it entirely
--- a/netwerk/cache2/CacheEntry.h
+++ b/netwerk/cache2/CacheEntry.h
@@ -66,16 +66,17 @@ public:
   nsCString const &GetStorageID() const { return mStorageID; }
   nsCString const &GetEnhanceID() const { return mEnhanceID; }
   nsIURI* GetURI() const { return mURI; }
   // Accessible at any time
   bool IsUsingDisk() const { return mUseDisk; }
   bool IsReferenced() const;
   bool IsFileDoomed();
   bool IsDoomed() const { return mIsDoomed; }
+  bool IsPinned() const { return mPinned; }
 
   // Methods for entry management (eviction from memory),
   // called only on the management thread.
 
   // TODO make these inline
   double GetFrecency() const;
   uint32_t GetExpirationTime() const;
   uint32_t UseCount() const { return mUseCount; }
--- a/netwerk/cache2/CacheFileIOManager.cpp
+++ b/netwerk/cache2/CacheFileIOManager.cpp
@@ -2377,17 +2377,17 @@ CacheFileIOManager::GetEntryInfo(const S
   }
   uint32_t lastModified;
   if (NS_FAILED(metadata->GetLastModified(&lastModified))) {
     lastModified = 0;
   }
 
   // Call directly on the callback.
   aCallback->OnEntryInfo(uriSpec, enhanceId, dataSize, fetchCount,
-                         lastModified, expirationTime);
+                         lastModified, expirationTime, metadata->Pinned());
 
   return NS_OK;
 }
 
 nsresult
 CacheFileIOManager::TruncateSeekSetEOFInternal(CacheFileHandle *aHandle,
                                                int64_t aTruncatePos,
                                                int64_t aEOFPos)
--- a/netwerk/cache2/CacheStorageService.cpp
+++ b/netwerk/cache2/CacheStorageService.cpp
@@ -306,25 +306,26 @@ private:
       walker->mSize += size;
 
     walker->mEntryArray.AppendElement(aEntry);
     return PL_DHASH_NEXT;
   }
 
   virtual void OnEntryInfo(const nsACString & aURISpec, const nsACString & aIdEnhance,
                            int64_t aDataSize, int32_t aFetchCount,
-                           uint32_t aLastModifiedTime, uint32_t aExpirationTime)
+                           uint32_t aLastModifiedTime, uint32_t aExpirationTime,
+                           bool aPinned)
   {
     nsCOMPtr<nsIURI> uri;
     nsresult rv = NS_NewURI(getter_AddRefs(uri), aURISpec);
     if (NS_FAILED(rv))
       return;
 
     mCallback->OnCacheEntryInfo(uri, aIdEnhance, aDataSize, aFetchCount,
-                                aLastModifiedTime, aExpirationTime);
+                                aLastModifiedTime, aExpirationTime, aPinned);
   }
 
 private:
   nsCString mContextKey;
   nsTArray<RefPtr<CacheEntry> > mEntryArray;
 };
 
 // WalkDiskCacheRunnable
@@ -374,28 +375,29 @@ private:
 
       nsCOMPtr<nsIURI> uri;
       nsresult rv = NS_NewURI(getter_AddRefs(uri), mURISpec);
       if (NS_FAILED(rv))
         return NS_OK;
 
       mWalker->mCallback->OnCacheEntryInfo(
         uri, mIdEnhance, mDataSize, mFetchCount,
-        mLastModifiedTime, mExpirationTime);
+        mLastModifiedTime, mExpirationTime, mPinned);
       return NS_OK;
     }
 
     RefPtr<WalkDiskCacheRunnable> mWalker;
 
     nsCString mURISpec;
     nsCString mIdEnhance;
     int64_t mDataSize;
     int32_t mFetchCount;
     uint32_t mLastModifiedTime;
     uint32_t mExpirationTime;
+    bool mPinned;
   };
 
   NS_IMETHODIMP Run()
   {
     // The main loop
     nsresult rv;
 
     if (CacheStorageService::IsOnManagementThread()) {
@@ -465,28 +467,30 @@ private:
       return NS_ERROR_FAILURE;
     }
 
     return NS_OK;
   }
 
   virtual void OnEntryInfo(const nsACString & aURISpec, const nsACString & aIdEnhance,
                            int64_t aDataSize, int32_t aFetchCount,
-                           uint32_t aLastModifiedTime, uint32_t aExpirationTime)
+                           uint32_t aLastModifiedTime, uint32_t aExpirationTime,
+                           bool aPinned)
   {
     // Called directly from CacheFileIOManager::GetEntryInfo.
 
     // Invoke onCacheEntryInfo on the main thread for this entry.
     RefPtr<OnCacheEntryInfoRunnable> info = new OnCacheEntryInfoRunnable(this);
     info->mURISpec = aURISpec;
     info->mIdEnhance = aIdEnhance;
     info->mDataSize = aDataSize;
     info->mFetchCount = aFetchCount;
     info->mLastModifiedTime = aLastModifiedTime;
     info->mExpirationTime = aExpirationTime;
+    info->mPinned = aPinned;
 
     NS_DispatchToMainThread(info);
   }
 
   RefPtr<nsILoadContextInfo> mLoadInfo;
   enum {
     // First, we collect stats for the load context.
     COLLECT_STATS,
@@ -1919,17 +1923,18 @@ CacheStorageService::GetCacheEntryInfo(C
     lastModified = 0;
   }
   uint32_t expirationTime;
   if (NS_FAILED(aEntry->GetExpirationTime(&expirationTime))) {
     expirationTime = 0;
   }
 
   aCallback->OnEntryInfo(uriSpec, enhanceId, dataSize,
-                         fetchCount, lastModified, expirationTime);
+                         fetchCount, lastModified, expirationTime,
+                         aEntry->IsPinned());
 }
 
 // Telementry collection
 
 namespace {
 
 bool TelemetryEntryKey(CacheEntry const* entry, nsAutoCString& key)
 {
--- a/netwerk/cache2/CacheStorageService.h
+++ b/netwerk/cache2/CacheStorageService.h
@@ -98,17 +98,18 @@ public:
 
   // Helper thread-safe interface to pass entry info, only difference from
   // nsICacheStorageVisitor is that instead of nsIURI only the uri spec is
   // passed.
   class EntryInfoCallback {
   public:
     virtual void OnEntryInfo(const nsACString & aURISpec, const nsACString & aIdEnhance,
                              int64_t aDataSize, int32_t aFetchCount,
-                             uint32_t aLastModifiedTime, uint32_t aExpirationTime) = 0;
+                             uint32_t aLastModifiedTime, uint32_t aExpirationTime,
+                             bool aPinned) = 0;
   };
 
   // Invokes OnEntryInfo for the given aEntry, synchronously.
   static void GetCacheEntryInfo(CacheEntry* aEntry, EntryInfoCallback *aVisitor);
 
   // Memory reporting
   size_t SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
   size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
--- a/netwerk/cache2/OldWrappers.cpp
+++ b/netwerk/cache2/OldWrappers.cpp
@@ -263,17 +263,17 @@ NS_IMETHODIMP _OldVisitCallbackWrapper::
   if (NS_FAILED(entryInfo->GetExpirationTime(&expirationTime)))
     expirationTime = 0;
   uint32_t lastModified;
   if (NS_FAILED(entryInfo->GetLastModified(&lastModified)))
     lastModified = 0;
 
   // Send them to the consumer.
   rv = mCB->OnCacheEntryInfo(
-    uri, enhanceId, (int64_t)dataSize, fetchCount, lastModified, expirationTime);
+    uri, enhanceId, (int64_t)dataSize, fetchCount, lastModified, expirationTime, false);
 
   *_retval = NS_SUCCEEDED(rv);
   return NS_OK;
 }
 
 // _OldGetDiskConsumption
 
 //static
--- a/netwerk/cache2/nsICacheStorageVisitor.idl
+++ b/netwerk/cache2/nsICacheStorageVisitor.idl
@@ -2,31 +2,32 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
 interface nsIURI;
 interface nsIFile;
 
-[scriptable, uuid(946bd799-9410-4945-9085-79c7fe019e83)]
+[scriptable, uuid(6cc7c253-93b6-482b-8e9d-1e04d8e9d655)]
 interface nsICacheStorageVisitor : nsISupports
 {
   /**
    */
   void onCacheStorageInfo(in uint32_t aEntryCount,
                           in uint64_t aConsumption,
                           in uint64_t aCapacity,
                           in nsIFile aDiskDirectory);
 
   /**
    */
   void onCacheEntryInfo(in nsIURI aURI,
                         in ACString aIdEnhance,
                         in int64_t aDataSize,
                         in long aFetchCount,
                         in uint32_t aLastModifiedTime,
-                        in uint32_t aExpirationTime);
+                        in uint32_t aExpirationTime,
+                        in boolean aPinned);
 
   /**
    */
   void onCacheEntryVisitCompleted();
 };
--- a/netwerk/protocol/about/nsAboutCache.cpp
+++ b/netwerk/protocol/about/nsAboutCache.cpp
@@ -341,40 +341,43 @@ nsAboutCache::OnCacheStorageInfo(uint32_
     }
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsAboutCache::OnCacheEntryInfo(nsIURI *aURI, const nsACString & aIdEnhance,
                                int64_t aDataSize, int32_t aFetchCount,
-                               uint32_t aLastModified, uint32_t aExpirationTime)
+                               uint32_t aLastModified, uint32_t aExpirationTime,
+                               bool aPinned)
 {
     // We need mStream for this
     if (!mStream) {
         return NS_ERROR_FAILURE;
     }
 
     if (!mEntriesHeaderAdded) {
         mBuffer.AppendLiteral("<hr/>\n"
                               "<table id=\"entries\">\n"
                               "  <colgroup>\n"
                               "   <col id=\"col-key\">\n"
                               "   <col id=\"col-dataSize\">\n"
                               "   <col id=\"col-fetchCount\">\n"
                               "   <col id=\"col-lastModified\">\n"
                               "   <col id=\"col-expires\">\n"
+                              "   <col id=\"col-pinned\">\n"
                               "  </colgroup>\n"
                               "  <thead>\n"
                               "    <tr>\n"
                               "      <th>Key</th>\n"
                               "      <th>Data size</th>\n"
                               "      <th>Fetch count</th>\n"
                               "      <th>Last Modifed</th>\n"
                               "      <th>Expires</th>\n"
+                              "      <th>Pinning</th>\n"
                               "    </tr>\n"
                               "  </thead>\n");
         mEntriesHeaderAdded = true;
     }
 
     // Generate a about:cache-entry URL for this entry...
 
     nsAutoCString url;
@@ -441,16 +444,25 @@ nsAboutCache::OnCacheEntryInfo(nsIURI *a
     if (aExpirationTime < 0xFFFFFFFF) {
         PrintTimeString(buf, sizeof(buf), aExpirationTime);
         mBuffer.Append(buf);
     } else {
         mBuffer.AppendLiteral("No expiration time");
     }
     mBuffer.AppendLiteral("</td>\n");
 
+    // Pinning
+    mBuffer.AppendLiteral("    <td>");
+    if (aPinned) {
+      mBuffer.Append(NS_LITERAL_CSTRING("Pinned"));
+    } else {
+      mBuffer.Append(NS_LITERAL_CSTRING("&nbsp;"));
+    }
+    mBuffer.AppendLiteral("</td>\n");
+
     // Entry is done...
     mBuffer.AppendLiteral("  </tr>\n");
 
     FlushBuffer();
     return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/toolkit/themes/shared/aboutCache.css
+++ b/toolkit/themes/shared/aboutCache.css
@@ -37,16 +37,20 @@ td {
 
 #col-dataSize,
 #col-fetchCount,
 #col-lastModified,
 #col-expires {
   width: 13%;
 }
 
+#col-pinned {
+  width: 5em;
+}
+
 #entries > tbody > tr:nth-child(odd) {
   background-color: rgba(0, 0, 0, .03);
 }
 
 #entries > tbody > tr:nth-child(even) {
   background-color: rgba(0, 0, 0, .06);
 }