Bug 541373 (part 2) - Provide a global VACUUM component. Use idle-daily category. r=sdwilsh a=blocking
authorMarco Bonardo <mbonardo@mozilla.com>
Tue, 19 Oct 2010 15:46:51 +0200
changeset 56088 0e4c3af3ac59797c231eaca4962616fa39807bf9
parent 56087 7d13edc2927276fc663646bbe38fd1fd62dc4dd1
child 56089 fe519f659d606e728a29fcd20b98cb2a49837462
push id16403
push usermak77@bonardo.net
push dateTue, 19 Oct 2010 13:48:25 +0000
treeherdermozilla-central@0e4c3af3ac59 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssdwilsh, blocking
bugs541373
milestone2.0b8pre
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 541373 (part 2) - Provide a global VACUUM component. Use idle-daily category. r=sdwilsh a=blocking
storage/build/mozStorageModule.cpp
storage/src/VacuumManager.cpp
--- a/storage/build/mozStorageModule.cpp
+++ b/storage/build/mozStorageModule.cpp
@@ -73,17 +73,17 @@ static const mozilla::Module::CIDEntry k
 static const mozilla::Module::ContractIDEntry kStorageContracts[] = {
     { MOZ_STORAGE_SERVICE_CONTRACTID, &kMOZ_STORAGE_SERVICE_CID },
     { MOZ_STORAGE_STATEMENT_WRAPPER_CONTRACTID, &kMOZ_STORAGE_STATEMENT_WRAPPER_CID },
     { VACUUMMANAGER_CONTRACTID, &kVACUUMMANAGER_CID },
     { NULL }
 };
 
 static const mozilla::Module::CategoryEntry kStorageCategories[] = {
-    { "profile-after-change", "MozStorage Vacuum Manager", VACUUMMANAGER_CONTRACTID },
+    { "idle-daily", "MozStorage Vacuum Manager", VACUUMMANAGER_CONTRACTID },
     { NULL }
 };
 
 static const mozilla::Module kStorageModule = {
     mozilla::Module::kVersion,
     kStorageCIDs,
     kStorageContracts,
     kStorageCategories
--- a/storage/src/VacuumManager.cpp
+++ b/storage/src/VacuumManager.cpp
@@ -477,24 +477,16 @@ VacuumManager::VacuumManager()
   gVacuumManager = this;
 }
 
 nsresult
 VacuumManager::initialize()
 {
   NS_PRECONDITION(NS_IsMainThread(), "Must be running on the main thread!");
 
-  // Observe idle-daily to run a single vacuum per day.
-  nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
-  NS_ENSURE_STATE(os);
-  nsresult rv = os->AddObserver(this, OBSERVER_TOPIC_IDLE_DAILY, PR_FALSE);
-  NS_ENSURE_SUCCESS(rv, rv);
-  rv = os->AddObserver(this, OBSERVER_TOPIC_XPCOM_SHUTDOWN, PR_FALSE);
-  NS_ENSURE_SUCCESS(rv, rv);
-
   // Used to store last vacuum times.
   nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
   NS_ENSURE_STATE(prefs);
   prefs->GetBranch(PREF_VACUUM_BRANCH, getter_AddRefs(mPrefBranch));
   NS_ENSURE_STATE(mPrefBranch);
 
   return NS_OK;
 }
@@ -534,22 +526,15 @@ VacuumManager::Observe(nsISupports *aSub
       nsCOMPtr<Vacuumer> vacuum = new Vacuumer(entries[index], mPrefBranch);
       NS_ENSURE_STATE(vacuum);
       // Only vacuum one database per day.
       if (vacuum->execute()) {
         break;
       }
     }
     (void)mPrefBranch->SetIntPref(NS_LITERAL_CSTRING("index").get(), index);
-    return NS_OK;
   }
-  else if (strcmp(aTopic, OBSERVER_TOPIC_XPCOM_SHUTDOWN) == 0) {
-    nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
-    if (os) {
-      (void)os->RemoveObserver(this, OBSERVER_TOPIC_IDLE_DAILY);
-      (void)os->RemoveObserver(this, OBSERVER_TOPIC_XPCOM_SHUTDOWN);
-    }
-  }
+
   return NS_OK;
 }
 
 } // namespace storage
 } // namespace mozilla