Bug 1252998 - StorageActivityService - part 6 - StorageActivityService in ServiceWorkerRegistrar, r=asuth
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 18 Apr 2018 18:19:13 +0200
changeset 467877 185d6fcf4eee894e3a062b21bfddd899f5ef0ba7
parent 467876 4367167b71d8972d5af696c45a3cd4d5f8f30521
child 467878 830a2e991b0c1a3a9f9684b469172e28ec689383
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1252998
milestone61.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 1252998 - StorageActivityService - part 6 - StorageActivityService in ServiceWorkerRegistrar, r=asuth
dom/serviceworkers/ServiceWorkerRegistrar.cpp
--- a/dom/serviceworkers/ServiceWorkerRegistrar.cpp
+++ b/dom/serviceworkers/ServiceWorkerRegistrar.cpp
@@ -14,16 +14,17 @@
 #include "nsILineInputStream.h"
 #include "nsIObserverService.h"
 #include "nsIOutputStream.h"
 #include "nsISafeOutputStream.h"
 
 #include "MainThreadUtils.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/CycleCollectedJSContext.h"
+#include "mozilla/dom/StorageActivityService.h"
 #include "mozilla/ErrorNames.h"
 #include "mozilla/ipc/BackgroundChild.h"
 #include "mozilla/ipc/BackgroundParent.h"
 #include "mozilla/ipc/PBackgroundChild.h"
 #include "mozilla/ModuleUtils.h"
 #include "mozilla/Services.h"
 #include "mozilla/StaticPtr.h"
 #include "mozJSComponentLoader.h"
@@ -260,16 +261,17 @@ ServiceWorkerRegistrar::RegisterServiceW
 
   {
     MonitorAutoLock lock(mMonitor);
     MOZ_ASSERT(mDataLoaded);
     RegisterServiceWorkerInternal(aData);
   }
 
   MaybeScheduleSaveData();
+  StorageActivityService::SendActivity(aData.principal());
 }
 
 void
 ServiceWorkerRegistrar::UnregisterServiceWorker(
                                             const PrincipalInfo& aPrincipalInfo,
                                             const nsACString& aScope)
 {
   AssertIsOnBackgroundThread();
@@ -296,43 +298,54 @@ ServiceWorkerRegistrar::UnregisterServic
         deleted = true;
         break;
       }
     }
   }
 
   if (deleted) {
     MaybeScheduleSaveData();
+    StorageActivityService::SendActivity(aPrincipalInfo);
   }
 }
 
 void
 ServiceWorkerRegistrar::RemoveAll()
 {
   AssertIsOnBackgroundThread();
 
   if (mShuttingDown) {
     NS_WARNING("Failed to remove all the serviceWorkers during shutting down.");
     return;
   }
 
   bool deleted = false;
 
+  nsTArray<ServiceWorkerRegistrationData> data;
   {
     MonitorAutoLock lock(mMonitor);
     MOZ_ASSERT(mDataLoaded);
 
+    // Let's take a copy in order to inform StorageActivityService.
+    data = mData;
+
     deleted = !mData.IsEmpty();
     mData.Clear();
 
     mDataGeneration = GetNextGeneration();
   }
 
-  if (deleted) {
-    MaybeScheduleSaveData();
+  if (!deleted) {
+    return;
+  }
+
+  MaybeScheduleSaveData();
+
+  for (uint32_t i = 0, len = data.Length(); i < len; ++i) {
+    StorageActivityService::SendActivity(data[i].principal());
   }
 }
 
 void
 ServiceWorkerRegistrar::LoadData()
 {
   MOZ_ASSERT(!NS_IsMainThread());
   MOZ_ASSERT(!mDataLoaded);