Backed out changeset 70d068cc946d (Bug 1374675)
authorBevis Tseng <btseng@mozilla.com>
Wed, 21 Jun 2017 11:02:48 +0800
changeset 404168 2566cc1e0dd7a982739f14746bdbcc3810fc82c9
parent 404167 23cd94436e78bed4e6a9a406de8fa8f3e9a77851
child 404169 dbadec2bba3b296a333cadf9ce15b7481f63d3fb
push id57
push userfmarier@mozilla.com
push dateSat, 24 Jun 2017 00:05:50 +0000
bugs1374675
milestone56.0a1
backs out70d068cc946dd074557cbe3fd8e28e484c600ad2
Backed out changeset 70d068cc946d (Bug 1374675)
dom/base/TabGroup.cpp
dom/base/TabGroup.h
dom/base/nsGlobalWindow.cpp
dom/base/nsGlobalWindow.h
dom/base/nsPIDOMWindow.h
--- a/dom/base/TabGroup.cpp
+++ b/dom/base/TabGroup.cpp
@@ -21,18 +21,16 @@
 namespace mozilla {
 namespace dom {
 
 static StaticRefPtr<TabGroup> sChromeTabGroup;
 
 TabGroup::TabGroup(bool aIsChrome)
  : mLastWindowLeft(false)
  , mThrottledQueuesInitialized(false)
- , mNumOfIndexedDBTransactions(0)
- , mNumOfIndexedDBDatabases(0)
  , mIsChrome(aIsChrome)
  , mForegroundCount(0)
 {
   CreateEventTargets(/* aNeedValidation = */ !aIsChrome);
 
   // Do not throttle runnables from chrome windows.  In theory we should
   // not have abuse issues from these windows and many browser chrome
   // tests have races that fail if we do throttle chrome runnables.
--- a/dom/base/TabGroup.h
+++ b/dom/base/TabGroup.h
@@ -122,43 +122,29 @@ public:
   nsISerialEventTarget* EventTargetFor(TaskCategory aCategory) const override;
 
   void WindowChangedBackgroundStatus(bool aIsNowBackground);
 
   // Returns true if all of the TabGroup's top-level windows are in
   // the background.
   bool IsBackground() const override;
 
-  // Increase/Decrease the number of IndexedDB transactions/databases for the
-  // decision making of the preemption in the scheduler.
-  Atomic<uint32_t>& IndexedDBTransactionCounter()
-  {
-    return mNumOfIndexedDBTransactions;
-  }
-
-  Atomic<uint32_t>& IndexedDBDatabaseCounter()
-  {
-    return mNumOfIndexedDBDatabases;
-  }
-
 private:
   virtual AbstractThread*
   AbstractMainThreadForImpl(TaskCategory aCategory) override;
 
   TabGroup* AsTabGroup() override { return this; }
 
   void EnsureThrottledEventQueues();
 
   ~TabGroup();
 
   // Thread-safe members
   Atomic<bool> mLastWindowLeft;
   Atomic<bool> mThrottledQueuesInitialized;
-  Atomic<uint32_t> mNumOfIndexedDBTransactions;
-  Atomic<uint32_t> mNumOfIndexedDBDatabases;
   const bool mIsChrome;
 
   // Main thread only
   DocGroupMap mDocGroups;
   nsTArray<nsPIDOMWindowOuter*> mWindows;
   uint32_t mForegroundCount;
 };
 
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -1604,19 +1604,17 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalW
     mCleanedUp(false),
     mDialogAbuseCount(0),
     mAreDialogsEnabled(true),
 #ifdef DEBUG
     mIsValidatingTabGroup(false),
 #endif
     mCanSkipCCGeneration(0),
     mAutoActivateVRDisplayID(0),
-    mBeforeUnloadListenerCount(0),
-    mNumOfIndexedDBTransactions(0),
-    mNumOfIndexedDBDatabases(0)
+    mBeforeUnloadListenerCount(0)
 {
   AssertIsOnMainThread();
 
   nsLayoutStatics::AddRef();
 
   // Initialize the PRCList (this).
   PR_INIT_CLIST(this);
 
@@ -15424,61 +15422,11 @@ nsGlobalWindow::GetIntlUtils(ErrorResult
   if (!mIntlUtils) {
     mIntlUtils = new IntlUtils(AsInner());
   }
 
   return mIntlUtils;
 }
 #endif
 
-#define DEFINE_INDEXEDDB_COUNTER_FOR(name)                                     \
-void                                                                           \
-nsPIDOMWindowInner::UpdateActive##name##Count(int32_t aDelta)                  \
-{                                                                              \
-  nsGlobalWindow::Cast(this)->UpdateActive##name##Count(aDelta);               \
-}                                                                              \
-                                                                               \
-bool nsPIDOMWindowInner::HasActive##name##s()                                  \
-{                                                                              \
-  return nsGlobalWindow::Cast(this)->HasActive##name##s();                     \
-}                                                                              \
-                                                                               \
-void                                                                           \
-nsGlobalWindow::UpdateActive##name##Count(int32_t aDelta)                      \
-{                                                                              \
-  if (aDelta == 0) {                                                           \
-    return;                                                                    \
-  }                                                                            \
-                                                                               \
-  DebugOnly<uint32_t> count = mNumOf##name##s;                                 \
-  mNumOf##name##s += aDelta;                                                   \
-  TabGroup()->name##Counter() += aDelta;                                       \
-  MOZ_ASSERT(                                                                  \
-    aDelta > 0 ? mNumOf##name##s > count : mNumOf##name##s < count,            \
-    "The counters are either overflow or underflow!");                         \
-}                                                                              \
-                                                                               \
-bool                                                                           \
-nsGlobalWindow::HasActive##name##s()                                           \
-{                                                                              \
-  MOZ_ASSERT(NS_IsMainThread());                                               \
-  MOZ_DIAGNOSTIC_ASSERT(IsInnerWindow());                                      \
-                                                                               \
-  if (!AsInner()->IsCurrentInnerWindow())                                      \
-  {                                                                            \
-    return false;                                                              \
-  }                                                                            \
-                                                                               \
-  nsCOMPtr<nsPIDOMWindowOuter> topOutterWindow = this->GetScriptableTop();     \
-  MOZ_ASSERT(topOutterWindow);                                                 \
-  RefPtr<nsGlobalWindow> topInnerWindow =                                      \
-    nsGlobalWindow::Cast(topOutterWindow->GetCurrentInnerWindow());            \
-                                                                               \
-  return topInnerWindow ? topInnerWindow->mNumOf##name##s > 0 : false;         \
-}
-
-DEFINE_INDEXEDDB_COUNTER_FOR(IndexedDBTransaction)
-DEFINE_INDEXEDDB_COUNTER_FOR(IndexedDBDatabase)
-#undef DEFINE_INDEXEDDB_COUNTER_FOR
-
 template class nsPIDOMWindow<mozIDOMWindowProxy>;
 template class nsPIDOMWindow<mozIDOMWindow>;
 template class nsPIDOMWindow<nsISupports>;
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -1842,20 +1842,16 @@ public:
   void ScheduleIdleRequestDispatch();
   void SuspendIdleRequests();
   void ResumeIdleRequests();
 
   typedef mozilla::LinkedList<mozilla::dom::IdleRequest> IdleRequests;
   void InsertIdleCallback(mozilla::dom::IdleRequest* aRequest);
 
   void RemoveIdleCallback(mozilla::dom::IdleRequest* aRequest);
-  void UpdateActiveIndexedDBTransactionCount(int32_t aDelta);
-  void UpdateActiveIndexedDBDatabaseCount(int32_t aDelta);
-  bool HasActiveIndexedDBTransactions();
-  bool HasActiveIndexedDBDatabases();
 
 protected:
   // These members are only used on outer window objects. Make sure
   // you never set any of these on an inner object!
   bool                          mFullScreen : 1;
   bool                          mFullscreenMode : 1;
   bool                          mIsClosed : 1;
   bool                          mInClose : 1;
@@ -2070,21 +2066,16 @@ protected:
   RefPtr<mozilla::dom::VREventObserver> mVREventObserver;
 
   // When non-zero, the document should receive a vrdisplayactivate event
   // after loading.  The value is the ID of the VRDisplay that content should
   // begin presentation on.
   uint32_t mAutoActivateVRDisplayID; // Outer windows only
   int64_t mBeforeUnloadListenerCount; // Inner windows only
 
-  // The number of IndexedDB transactions/databases per tab counted at the top
-  // of inner window.
-  uint32_t mNumOfIndexedDBTransactions;
-  uint32_t mNumOfIndexedDBDatabases;
-
 #ifdef ENABLE_INTL_API
   RefPtr<mozilla::dom::IntlUtils> mIntlUtils;
 #endif
 
   friend class nsDOMScriptableHelper;
   friend class nsDOMWindowUtils;
   friend class mozilla::dom::PostMessageEvent;
   friend class DesktopNotification;
--- a/dom/base/nsPIDOMWindow.h
+++ b/dom/base/nsPIDOMWindow.h
@@ -890,26 +890,16 @@ public:
   bool IsPlayingAudio();
 
   bool IsDocumentLoaded() const;
 
   mozilla::dom::TimeoutManager& TimeoutManager();
 
   bool IsRunningTimeout();
 
-  // Increase/Decrease the number of active IndexedDB transactions/databases for
-  // the decision making of timer-throttling.
-  void UpdateActiveIndexedDBTransactionCount(int32_t aDelta);
-  void UpdateActiveIndexedDBDatabaseCount(int32_t aDelta);
-
-  // Return true if there is any active IndexedDB trasnsaction/databases in any
-  // window of the same tab.
-  bool HasActiveIndexedDBTransactions();
-  bool HasActiveIndexedDBDatabases();
-
 protected:
   void CreatePerformanceObjectIfNeeded();
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsPIDOMWindowInner, NS_PIDOMWINDOWINNER_IID)
 
 // NB: It's very very important that these two classes have identical vtables
 // and memory layout!