Bug 795725 - Remove booleans that prevents calling RemoveObserver() twice. r=smaug
authorMounir Lamouri <mounir.lamouri@gmail.com>
Wed, 03 Oct 2012 10:39:23 +0100
changeset 109137 dd85a91c7ad69ea8e857668add82dc2307c5e592
parent 109136 2b5320ce41aa4536d9f52b28d8374572add62e4f
child 109138 00d03da9049aaaf8527e604070109a1e4f36cc3e
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewerssmaug
bugs795725
milestone18.0a1
Bug 795725 - Remove booleans that prevents calling RemoveObserver() twice. r=smaug
dom/base/nsGlobalWindow.cpp
dom/base/nsGlobalWindow.h
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -685,19 +685,17 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalW
     mSerial(0),
 #ifdef DEBUG
     mSetOpenerWindowCalled(false),
 #endif
     mCleanedUp(false),
     mCallCleanUpAfterModalDialogCloses(false),
     mDialogAbuseCount(0),
     mStopAbuseDialogs(false),
-    mDialogsPermanentlyDisabled(false),
-    mObservingNetworkUpload(false),
-    mObservingNetworkDownload(false)
+    mDialogsPermanentlyDisabled(false)
 {
   nsLayoutStatics::AddRef();
 
   // Initialize the PRCList (this).
   PR_INIT_CLIST(this);
 
   // Initialize timeout storage
   PR_INIT_CLIST(&mTimeouts);
@@ -11148,21 +11146,16 @@ nsGlobalWindow::SetHasAudioAvailableEven
   if (mDoc) {
     mDoc->NotifyAudioAvailableListener();
   }
 }
 
 void
 nsGlobalWindow::EnableNetworkEvent(uint32_t aType)
 {
-  if ((mObservingNetworkUpload && aType == NS_NETWORK_UPLOAD_EVENT) ||
-      (mObservingNetworkDownload && aType == NS_NETWORK_DOWNLOAD_EVENT)) {
-    return;
-  }
-
   nsCOMPtr<nsIPermissionManager> permMgr =
     do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
   if (!permMgr) {
     NS_ERROR("No PermissionManager available!");
     return;
   }
 
   uint32_t permission = nsIPermissionManager::DENY_ACTION;
@@ -11177,47 +11170,37 @@ nsGlobalWindow::EnableNetworkEvent(uint3
   if (!os) {
     NS_ERROR("ObserverService should be available!");
     return;
   }
 
   switch (aType) {
     case NS_NETWORK_UPLOAD_EVENT:
       os->AddObserver(mObserver, NS_NETWORK_ACTIVITY_BLIP_UPLOAD_TOPIC, false);
-      mObservingNetworkUpload = true;
       break;
     case NS_NETWORK_DOWNLOAD_EVENT:
       os->AddObserver(mObserver, NS_NETWORK_ACTIVITY_BLIP_DOWNLOAD_TOPIC, false);
-      mObservingNetworkDownload = true;
       break;
   }
 }
 
 void
 nsGlobalWindow::DisableNetworkEvent(uint32_t aType)
 {
-  if ((!mObservingNetworkUpload && aType == NS_NETWORK_UPLOAD_EVENT) ||
-      (!mObservingNetworkDownload && aType == NS_NETWORK_DOWNLOAD_EVENT)) {
-    return;
-  }
-
   nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
   if (!os) {
-    NS_ERROR("ObserverService should be available!");
     return;
   }
 
   switch (aType) {
     case NS_NETWORK_UPLOAD_EVENT:
       os->RemoveObserver(mObserver, NS_NETWORK_ACTIVITY_BLIP_UPLOAD_TOPIC);
-      mObservingNetworkUpload = false;
       break;
     case NS_NETWORK_DOWNLOAD_EVENT:
       os->RemoveObserver(mObserver, NS_NETWORK_ACTIVITY_BLIP_DOWNLOAD_TOPIC);
-      mObservingNetworkDownload = false;
       break;
   }
 }
 
 #define EVENT(name_, id_, type_, struct_)                                    \
   NS_IMETHODIMP nsGlobalWindow::GetOn##name_(JSContext *cx,                  \
                                              jsval *vp) {                    \
     nsEventListenerManager *elm = GetListenerManager(false);                 \
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -1089,21 +1089,16 @@ protected:
   // mDialogAbuseCount gets reset.
   bool                          mStopAbuseDialogs;
 
   // This flag gets set when dialogs should be permanently disabled for this
   // window (e.g. when we are closing the tab and therefore are guaranteed to be
   // destroying this window).
   bool                          mDialogsPermanentlyDisabled;
 
-  // Temporary booleans to know if we are currently observing network blips.
-  // Will be hopefully removed after bug 795703.
-  bool mObservingNetworkUpload;
-  bool mObservingNetworkDownload;
-
   nsRefPtr<nsDOMMozURLProperty> mURLProperty;
 
   nsTHashtable<nsPtrHashKey<nsDOMEventTargetHelper> > mEventTargetObjects;
 
   nsTArray<uint32_t> mEnabledSensors;
 
   friend class nsDOMScriptableHelper;
   friend class nsDOMWindowUtils;