# HG changeset patch # User Andrea Marchesini # Parent 8eb514ad8c0377741da3b199acac589213060634 Bug 1252998 - StorageActivityService in ServiceWorkerRegistrar, r?asuth diff --git a/dom/workers/ServiceWorkerRegistrar.cpp b/dom/workers/ServiceWorkerRegistrar.cpp --- a/dom/workers/ServiceWorkerRegistrar.cpp +++ b/dom/workers/ServiceWorkerRegistrar.cpp @@ -12,16 +12,17 @@ #include "nsIInputStream.h" #include "nsILineInputStream.h" #include "nsIObserverService.h" #include "nsIOutputStream.h" #include "nsISafeOutputStream.h" #include "MainThreadUtils.h" #include "mozilla/ClearOnShutdown.h" +#include "mozilla/dom/StorageActivityService.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 "nsAppDirectoryServiceDefs.h" #include "nsContentUtils.h" @@ -177,16 +178,17 @@ ServiceWorkerRegistrar::RegisterServiceW { MonitorAutoLock lock(mMonitor); MOZ_ASSERT(mDataLoaded); RegisterServiceWorkerInternal(aData); } ScheduleSaveData(); + StorageActivityService::SendActivity(aData.principal()); } void ServiceWorkerRegistrar::UnregisterServiceWorker( const PrincipalInfo& aPrincipalInfo, const nsACString& aScope) { AssertIsOnBackgroundThread(); @@ -212,41 +214,52 @@ ServiceWorkerRegistrar::UnregisterServic deleted = true; break; } } } if (deleted) { ScheduleSaveData(); + 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 data; { MonitorAutoLock lock(mMonitor); MOZ_ASSERT(mDataLoaded); + // Let's take a copy in order to inform StorageActivityService. + data = mData; + deleted = !mData.IsEmpty(); mData.Clear(); } - if (deleted) { - ScheduleSaveData(); + if (!deleted) { + return; + } + + ScheduleSaveData(); + + 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);