From 805bc942732cac8d0ff6e39a9a715cc11b3b2c08 Mon Sep 17 00:00:00 2001 From: Ben Turner Date: Thu, 30 Apr 2015 13:46:51 -0700 Subject: [PATCH] Bug 858680 - Part 2: Add idle notifications to QuotaClient, r=janv. --HG-- extra : rebase_source : d4ec5e860b885ab01e4e1c19e6aed057b78e5aaa --- dom/asmjscache/AsmJSCache.cpp | 4 ++++ dom/cache/QuotaClient.cpp | 3 +++ dom/indexedDB/ActorsParent.cpp | 4 ++++ dom/quota/Client.h | 3 +++ dom/quota/QuotaManager.cpp | 12 +++++++++--- layout/build/nsLayoutModule.cpp | 2 ++ 6 files changed, 25 insertions(+), 3 deletions(-) diff --git a/dom/asmjscache/AsmJSCache.cpp b/dom/asmjscache/AsmJSCache.cpp index 7b14652e1af3..05be1bdebeb8 100644 --- a/dom/asmjscache/AsmJSCache.cpp +++ b/dom/asmjscache/AsmJSCache.cpp @@ -1850,6 +1850,10 @@ public: MOZ_ASSERT_UNREACHABLE("There are no storages"); } + virtual void + PerformIdleMaintenance() override + { } + virtual void ShutdownWorkThreads() override { } diff --git a/dom/cache/QuotaClient.cpp b/dom/cache/QuotaClient.cpp index be3fef8f2235..8eb7689cabd3 100644 --- a/dom/cache/QuotaClient.cpp +++ b/dom/cache/QuotaClient.cpp @@ -226,6 +226,9 @@ public: } } + virtual void + PerformIdleMaintenance() override + { } virtual void ShutdownWorkThreads() override diff --git a/dom/indexedDB/ActorsParent.cpp b/dom/indexedDB/ActorsParent.cpp index e0b92163b876..abebedf83506 100644 --- a/dom/indexedDB/ActorsParent.cpp +++ b/dom/indexedDB/ActorsParent.cpp @@ -7844,6 +7844,10 @@ public: WaitForStoragesToComplete(nsTArray& aStorages, nsIRunnable* aCallback) override; + virtual void + PerformIdleMaintenance() override + { } + virtual void ShutdownWorkThreads() override; diff --git a/dom/quota/Client.h b/dom/quota/Client.h index 5ee5dc9e4506..5d3e89592cea 100644 --- a/dom/quota/Client.h +++ b/dom/quota/Client.h @@ -115,6 +115,9 @@ public: WaitForStoragesToComplete(nsTArray& aStorages, nsIRunnable* aCallback) = 0; + virtual void + PerformIdleMaintenance() = 0; + virtual void ShutdownWorkThreads() = 0; diff --git a/dom/quota/QuotaManager.cpp b/dom/quota/QuotaManager.cpp index 1c39d1e29f1f..95c1664c279f 100644 --- a/dom/quota/QuotaManager.cpp +++ b/dom/quota/QuotaManager.cpp @@ -10,6 +10,7 @@ #include "nsIBinaryInputStream.h" #include "nsIBinaryOutputStream.h" #include "nsIFile.h" +#include "nsIIdleService.h" #include "nsIObserverService.h" #include "nsIOfflineStorage.h" #include "nsIPermissionManager.h" @@ -1482,10 +1483,8 @@ QuotaManager::Init() NS_ASSERTION(mClients.Capacity() == Client::TYPE_MAX, "Should be using an auto array with correct capacity!"); - nsRefPtr idbClient = indexedDB::CreateQuotaClient(); - // Register clients. - mClients.AppendElement(idbClient); + mClients.AppendElement(indexedDB::CreateQuotaClient()); mClients.AppendElement(asmjscache::CreateClient()); mClients.AppendElement(cache::CreateQuotaClient()); @@ -3061,6 +3060,13 @@ QuotaManager::Observe(nsISupports* aSubject, return NS_OK; } + if (!strcmp(aTopic, OBSERVER_TOPIC_IDLE_DAILY)) { + for (auto& client : mClients) { + client->PerformIdleMaintenance(); + } + return NS_OK; + } + NS_NOTREACHED("Unknown topic!"); return NS_ERROR_UNEXPECTED; } diff --git a/layout/build/nsLayoutModule.cpp b/layout/build/nsLayoutModule.cpp index 033bab332a48..8b432340b27f 100644 --- a/layout/build/nsLayoutModule.cpp +++ b/layout/build/nsLayoutModule.cpp @@ -28,6 +28,7 @@ #include "nsIDocumentEncoder.h" #include "nsIFactory.h" #include "nsIFrameUtil.h" +#include "nsIIdleService.h" #include "nsHTMLStyleSheet.h" #include "nsILayoutDebugger.h" #include "nsNameSpaceManager.h" @@ -1317,6 +1318,7 @@ static const mozilla::Module::CategoryEntry kLayoutCategories[] = { { "net-channel-event-sinks", NS_MIXEDCONTENTBLOCKER_CONTRACTID, NS_MIXEDCONTENTBLOCKER_CONTRACTID }, { "app-startup", "Script Security Manager", "service," NS_SCRIPTSECURITYMANAGER_CONTRACTID }, { TOPIC_WEB_APP_CLEAR_DATA, "QuotaManager", "service," QUOTA_MANAGER_CONTRACTID }, + { OBSERVER_TOPIC_IDLE_DAILY, "QuotaManager", QUOTA_MANAGER_CONTRACTID }, #ifdef MOZ_WIDGET_GONK { "app-startup", "Volume Service", "service," NS_VOLUMESERVICE_CONTRACTID }, #endif