Bug 858680 - Part 2: Add idle notifications to QuotaClient, r=janv.

--HG--
extra : rebase_source : d4ec5e860b885ab01e4e1c19e6aed057b78e5aaa
This commit is contained in:
Ben Turner 2015-04-30 13:46:51 -07:00
parent 52201e6166
commit 805bc94273
6 changed files with 25 additions and 3 deletions

View File

@ -1850,6 +1850,10 @@ public:
MOZ_ASSERT_UNREACHABLE("There are no storages");
}
virtual void
PerformIdleMaintenance() override
{ }
virtual void
ShutdownWorkThreads() override
{ }

View File

@ -226,6 +226,9 @@ public:
}
}
virtual void
PerformIdleMaintenance() override
{ }
virtual void
ShutdownWorkThreads() override

View File

@ -7844,6 +7844,10 @@ public:
WaitForStoragesToComplete(nsTArray<nsIOfflineStorage*>& aStorages,
nsIRunnable* aCallback) override;
virtual void
PerformIdleMaintenance() override
{ }
virtual void
ShutdownWorkThreads() override;

View File

@ -115,6 +115,9 @@ public:
WaitForStoragesToComplete(nsTArray<nsIOfflineStorage*>& aStorages,
nsIRunnable* aCallback) = 0;
virtual void
PerformIdleMaintenance() = 0;
virtual void
ShutdownWorkThreads() = 0;

View File

@ -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<Client> 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;
}

View File

@ -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