Back out changeset df94eb632b9c (bug 1224771) for Mulet failures.
authorKit Cambridge <kcambridge@mozilla.com>
Tue, 05 Jan 2016 14:43:41 -0700
changeset 319137 c342816f76c048db725e4c44e64bb3cfdcde7aa9
parent 319136 49093f32f8a954b1a3ea7702b18790475a7d4c2d
child 319138 854144400164d80114a84dcd77e05cf27647280f
child 319158 a855336ab34a663b898089b0c9b83642962a0316
push id8984
push userahunt@mozilla.com
push dateTue, 05 Jan 2016 23:06:12 +0000
bugs1224771
milestone46.0a1
backs outdf94eb632b9c65d4e7056b7a461514a109dd6809
Back out changeset df94eb632b9c (bug 1224771) for Mulet failures.
dom/notification/Notification.cpp
dom/notification/Notification.h
--- a/dom/notification/Notification.cpp
+++ b/dom/notification/Notification.cpp
@@ -976,33 +976,16 @@ Notification::Notification(nsIGlobalObje
     // fetch the atom for the event name which asserts main thread only.
     BindToOwner(aGlobal);
   } else {
     mWorkerPrivate = GetCurrentThreadWorkerPrivate();
     MOZ_ASSERT(mWorkerPrivate);
   }
 }
 
-nsresult
-Notification::Init()
-{
-  if (!mWorkerPrivate) {
-    nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
-    NS_ENSURE_TRUE(obs, NS_ERROR_FAILURE);
-
-    nsresult rv = obs->AddObserver(this, DOM_WINDOW_DESTROYED_TOPIC, true);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    rv = obs->AddObserver(this, DOM_WINDOW_FROZEN_TOPIC, true);
-    NS_ENSURE_SUCCESS(rv, rv);
-  }
-
-  return NS_OK;
-}
-
 void
 Notification::SetAlertName()
 {
   AssertIsOnMainThread();
   if (!mAlertName.IsEmpty()) {
     return;
   }
 
@@ -1162,43 +1145,40 @@ Notification::UnpersistNotification()
 }
 
 already_AddRefed<Notification>
 Notification::CreateInternal(nsIGlobalObject* aGlobal,
                              const nsAString& aID,
                              const nsAString& aTitle,
                              const NotificationOptions& aOptions)
 {
-  nsresult rv;
   nsString id;
   if (!aID.IsEmpty()) {
     id = aID;
   } else {
     nsCOMPtr<nsIUUIDGenerator> uuidgen =
       do_GetService("@mozilla.org/uuid-generator;1");
     NS_ENSURE_TRUE(uuidgen, nullptr);
     nsID uuid;
-    rv = uuidgen->GenerateUUIDInPlace(&uuid);
+    nsresult rv = uuidgen->GenerateUUIDInPlace(&uuid);
     NS_ENSURE_SUCCESS(rv, nullptr);
 
     char buffer[NSID_LENGTH];
     uuid.ToProvidedString(buffer);
     NS_ConvertASCIItoUTF16 convertedID(buffer);
     id = convertedID;
   }
 
   RefPtr<Notification> notification = new Notification(aGlobal, id, aTitle,
                                                          aOptions.mBody,
                                                          aOptions.mDir,
                                                          aOptions.mLang,
                                                          aOptions.mTag,
                                                          aOptions.mIcon,
                                                          aOptions.mMozbehavior);
-  rv = notification->Init();
-  NS_ENSURE_SUCCESS(rv, nullptr);
   return notification.forget();
 }
 
 Notification::~Notification()
 {
   mData.setUndefined();
   mozilla::DropJSObjects(this);
   AssertIsOnTargetThread();
@@ -1217,18 +1197,16 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(Notification, DOMEventTargetHelper)
   NS_IMPL_CYCLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK(mData);
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
 NS_IMPL_ADDREF_INHERITED(Notification, DOMEventTargetHelper)
 NS_IMPL_RELEASE_INHERITED(Notification, DOMEventTargetHelper)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(Notification)
-  NS_INTERFACE_MAP_ENTRY(nsIObserver)
-  NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
 NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
 
 nsIPrincipal*
 Notification::GetPrincipal()
 {
   AssertIsOnMainThread();
   if (mWorkerPrivate) {
     return mWorkerPrivate->GetPrincipal();
@@ -2739,34 +2717,11 @@ Notification::OpenSettings(nsIPrincipal*
   if (!obs) {
     return NS_ERROR_FAILURE;
   }
   // Notify other observers so they can show settings UI.
   obs->NotifyObservers(aPrincipal, "notifications-open-settings", nullptr);
   return NS_OK;
 }
 
-NS_IMETHODIMP
-Notification::Observe(nsISupports* aSubject, const char* aTopic,
-                      const char16_t* aData)
-{
-  AssertIsOnMainThread();
-
-  if (!strcmp(aTopic, DOM_WINDOW_DESTROYED_TOPIC) ||
-      !strcmp(aTopic, DOM_WINDOW_FROZEN_TOPIC)) {
-
-    if (SameCOMIdentity(aSubject, GetOwner())) {
-      nsCOMPtr<nsIObserverService> obs =
-        mozilla::services::GetObserverService();
-      if (obs) {
-        obs->RemoveObserver(this, DOM_WINDOW_DESTROYED_TOPIC);
-        obs->RemoveObserver(this, DOM_WINDOW_FROZEN_TOPIC);
-      }
-      CloseInternal();
-    }
-  }
-
-  return NS_OK;
-}
-
 } // namespace dom
 } // namespace mozilla
 
--- a/dom/notification/Notification.h
+++ b/dom/notification/Notification.h
@@ -12,17 +12,16 @@
 #include "mozilla/dom/NotificationBinding.h"
 #include "mozilla/dom/workers/bindings/WorkerFeature.h"
 
 #include "nsIObserver.h"
 
 #include "nsCycleCollectionParticipant.h"
 #include "nsHashKeys.h"
 #include "nsTHashtable.h"
-#include "nsWeakReference.h"
 
 #define NOTIFICATIONTELEMETRYSERVICE_CONTRACTID \
   "@mozilla.org/notificationTelemetryService;1"
 
 class nsIPrincipal;
 class nsIVariant;
 
 namespace mozilla {
@@ -128,18 +127,16 @@ private:
  * the Notification, the NotificationRef destructor will first try to release
  * the Notification by dispatching a normal runnable to the worker so that it is
  * queued after any event runnables. If that dispatch fails, it means the worker
  * is no longer running and queued WorkerRunnables will be canceled, so we
  * dispatch a control runnable instead.
  *
  */
 class Notification : public DOMEventTargetHelper
-                   , public nsIObserver
-                   , public nsSupportsWeakReference
 {
   friend class CloseNotificationRunnable;
   friend class NotificationTask;
   friend class NotificationPermissionRequest;
   friend class MainThreadNotificationObserver;
   friend class NotificationStorageCallback;
   friend class ServiceWorkerNotificationObserver;
   friend class WorkerGetRunnable;
@@ -149,17 +146,16 @@ class Notification : public DOMEventTarg
 public:
   IMPL_EVENT_HANDLER(click)
   IMPL_EVENT_HANDLER(show)
   IMPL_EVENT_HANDLER(error)
   IMPL_EVENT_HANDLER(close)
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(Notification, DOMEventTargetHelper)
-  NS_DECL_NSIOBSERVER
 
   static bool PrefEnabled(JSContext* aCx, JSObject* aObj);
   // Returns if Notification.get() is allowed for the current global.
   static bool IsGetEnabled(JSContext* aCx, JSObject* aObj);
 
   static already_AddRefed<Notification> Constructor(const GlobalObject& aGlobal,
                                                     const nsAString& aTitle,
                                                     const NotificationOptions& aOption,
@@ -324,17 +320,16 @@ protected:
                const nsAString& aTag, const nsAString& aIconUrl,
                const NotificationBehavior& aBehavior);
 
   static already_AddRefed<Notification> CreateInternal(nsIGlobalObject* aGlobal,
                                                        const nsAString& aID,
                                                        const nsAString& aTitle,
                                                        const NotificationOptions& aOptions);
 
-  nsresult Init();
   bool IsInPrivateBrowsing();
   void ShowInternal();
   void CloseInternal();
 
   static NotificationPermission GetPermissionInternal(nsISupports* aGlobal,
                                                       ErrorResult& rv);
 
   static const nsString DirectionToString(NotificationDirection aDirection)