Bug 675221 part E - fix up DOMStorage proxies (miscellaenous #includes from other places also included) r=mayhemer
authorBenjamin Smedberg <benjamin@smedbergs.us>
Fri, 19 Aug 2011 11:50:37 -0400
changeset 75572 e8cb17fdc2f64f8adc93acb5c90c3d7d778967b1
parent 75571 97407f5d696f516eb56fae979d1d013699ef2f2a
child 75573 df2aebf58b689b9b820587aacb57a712c86f7f93
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersmayhemer
bugs675221
milestone9.0a1
Bug 675221 part E - fix up DOMStorage proxies (miscellaenous #includes from other places also included) r=mayhemer
dom/src/storage/nsDOMStorage.cpp
modules/libpr0n/src/imgLoader.cpp
modules/libpr0n/src/imgRequest.cpp
--- a/dom/src/storage/nsDOMStorage.cpp
+++ b/dom/src/storage/nsDOMStorage.cpp
@@ -65,18 +65,18 @@ using mozilla::dom::StorageChild;
 #include "nsIPermission.h"
 #include "nsIPermissionManager.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsIOfflineCacheUpdate.h"
 #include "nsIJSContextStack.h"
 #include "nsIPrivateBrowsingService.h"
 #include "nsDOMString.h"
 #include "nsNetCID.h"
-#include "nsIProxyObjectManager.h"
 #include "mozilla/Preferences.h"
+#include "nsThreadUtils.h"
 
 using namespace mozilla;
 
 static const PRUint32 ASK_BEFORE_ACCEPT = 1;
 static const PRUint32 ACCEPT_SESSION = 2;
 static const PRUint32 BEHAVIOR_REJECT = 2;
 
 static const PRUint32 DEFAULT_QUOTA = 5 * 1024;
@@ -1893,16 +1893,44 @@ nsPIDOMStorage::nsDOMStorageType
 nsDOMStorage2::StorageType()
 {
   if (mStorage)
     return mStorage->StorageType();
 
   return nsPIDOMStorage::Unknown;
 }
 
+namespace {
+
+class StorageNotifierRunnable : public nsRunnable
+{
+public:
+  StorageNotifierRunnable(nsISupports* aSubject)
+    : mSubject(aSubject)
+  { }
+
+  NS_DECL_NSIRUNNABLE
+
+private:
+  nsCOMPtr<nsISupports> mSubject;
+};
+
+NS_IMETHODIMP
+StorageNotifierRunnable::Run()
+{
+  nsCOMPtr<nsIObserverService> observerService =
+    mozilla::services::GetObserverService();
+  if (observerService) {
+    observerService->NotifyObservers(mSubject, "dom-storage2-changed", nsnull);
+  }
+  return NS_OK;
+}
+
+} // anonymous namespace
+
 void
 nsDOMStorage2::BroadcastChangeNotification(const nsSubstring &aKey,
                                           const nsSubstring &aOldValue,
                                           const nsSubstring &aNewValue)
 {
   nsresult rv;
   nsCOMPtr<nsIDOMStorageEvent> event = new nsDOMStorageEvent();
   rv = event->InitStorageEvent(NS_LITERAL_STRING("storage"),
@@ -1912,36 +1940,18 @@ nsDOMStorage2::BroadcastChangeNotificati
                                aOldValue,
                                aNewValue,
                                mDocumentURI,
                                static_cast<nsIDOMStorage*>(this));
   if (NS_FAILED(rv)) {
     return;
   }
 
-  nsCOMPtr<nsIObserverService> observerService =
-    mozilla::services::GetObserverService();
-  if (!observerService) {
-    return;
-  }
-
-  nsCOMPtr<nsIObserverService> observerServiceProxy;
-  rv = NS_GetProxyForObject(NS_PROXY_TO_MAIN_THREAD,
-                            NS_GET_IID(nsIObserverService),
-                            observerService,
-                            NS_PROXY_ASYNC | NS_PROXY_ALWAYS,
-                            getter_AddRefs(observerServiceProxy));
-  if (NS_FAILED(rv)) {
-    return;
-  }
-
-  // Fire off a notification that a storage object changed.
-  observerServiceProxy->NotifyObservers(event,
-                                        "dom-storage2-changed",
-                                        nsnull);
+  nsRefPtr<StorageNotifierRunnable> r = new StorageNotifierRunnable(event);
+  NS_DispatchToMainThread(r);
 }
 
 NS_IMETHODIMP
 nsDOMStorage2::GetLength(PRUint32 *aLength)
 {
   return mStorage->GetLength(aLength);
 }
 
--- a/modules/libpr0n/src/imgLoader.cpp
+++ b/modules/libpr0n/src/imgLoader.cpp
@@ -57,17 +57,16 @@
 #include "nsNetUtil.h"
 #include "nsStreamUtils.h"
 #include "nsIHttpChannel.h"
 #include "nsICachingChannel.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIProgressEventSink.h"
 #include "nsIChannelEventSink.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
-#include "nsIProxyObjectManager.h"
 #include "nsIServiceManager.h"
 #include "nsIFileURL.h"
 #include "nsThreadUtils.h"
 #include "nsXPIDLString.h"
 #include "nsCRT.h"
 #include "nsIDocument.h"
 #include "nsPIDOMWindow.h"
 
--- a/modules/libpr0n/src/imgRequest.cpp
+++ b/modules/libpr0n/src/imgRequest.cpp
@@ -62,17 +62,16 @@
 #include "nsICachingChannel.h"
 #include "nsILoadGroup.h"
 #include "nsIInputStream.h"
 #include "nsIMultiPartChannel.h"
 #include "nsIHttpChannel.h"
 
 #include "nsIComponentManager.h"
 #include "nsIInterfaceRequestorUtils.h"
-#include "nsIProxyObjectManager.h"
 #include "nsIServiceManager.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIScriptSecurityManager.h"
 
 #include "nsICacheVisitor.h"
 
 #include "nsString.h"
 #include "nsXPIDLString.h"