Bug 1460768 - Part 1 - Have StorageActivityService emit an observer notification when storage is modified. draft
authorJohann Hofmann <jhofmann@mozilla.com>
Thu, 05 Jul 2018 23:06:49 +0200
changeset 814656 bf5981a94c82d5606968b02743ad9d757f8cca54
parent 808055 c40cc0a89bc70511751d17ed0cdd569a74abac88
child 814657 408ff50e50f021156a2135c5a58bf8c42b31413f
push id115305
push userjhofmann@mozilla.com
push dateThu, 05 Jul 2018 21:44:52 +0000
bugs1460768
milestone62.0a1
Bug 1460768 - Part 1 - Have StorageActivityService emit an observer notification when storage is modified. MozReview-Commit-ID: KO1Y75AfgVc
dom/storage/StorageActivityService.cpp
dom/storage/StorageActivityService.h
--- a/dom/storage/StorageActivityService.cpp
+++ b/dom/storage/StorageActivityService.cpp
@@ -145,22 +145,30 @@ StorageActivityService::SendActivityInte
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return;
   }
 
   SendActivityInternal(origin);
 }
 
 void
-StorageActivityService::SendActivityInternal(const nsACString& aOrigin)
+StorageActivityService::SendActivityInternal(const nsCString& aOrigin)
 {
   MOZ_ASSERT(XRE_IsParentProcess());
 
   mActivities.Put(aOrigin, PR_Now());
   MaybeStartTimer();
+
+  nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
+  if (NS_WARN_IF(!obs)) {
+    return;
+  }
+
+  obs->NotifyObservers(nullptr, "storage-activity",
+                       NS_ConvertUTF8toUTF16(aOrigin).get());
 }
 
 void
 StorageActivityService::SendActivityToParent(nsIPrincipal* aPrincipal)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(!XRE_IsParentProcess());
 
--- a/dom/storage/StorageActivityService.h
+++ b/dom/storage/StorageActivityService.h
@@ -50,17 +50,17 @@ public:
 private:
   StorageActivityService();
   ~StorageActivityService();
 
   void
   SendActivityInternal(nsIPrincipal* aPrincipal);
 
   void
-  SendActivityInternal(const nsACString& aOrigin);
+  SendActivityInternal(const nsCString& aOrigin);
 
   void
   SendActivityToParent(nsIPrincipal* aPrincipal);
 
   void
   MaybeStartTimer();
 
   void