Bug 1368009 - Get rid of activity-opened/activity-closed observer, r=gsvelto
authorAndrea Marchesini <amarchesini@mozilla.com>
Thu, 01 Jun 2017 08:29:02 +0200
changeset 361707 d7b4edc492490251642bc0e35b244147b31b72e9
parent 361706 0f04ee5c2e1c916ae454c911bcead18a04927460
child 361708 4e8564ce92d8056d6282a499cac1933f4a90a769
push id90916
push useramarchesini@mozilla.com
push dateThu, 01 Jun 2017 06:59:54 +0000
treeherdermozilla-inbound@d7b4edc49249 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgsvelto
bugs1368009
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1368009 - Get rid of activity-opened/activity-closed observer, r=gsvelto
dom/browser-element/mochitest/priority/test_Activity.html
dom/ipc/ProcessPriorityManager.cpp
deleted file mode 100644
--- a/dom/browser-element/mochitest/priority/test_Activity.html
+++ /dev/null
@@ -1,62 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-Test that calling setVisible("false") on an iframe that has an open activity
-causes its priority to change.
--->
-<head>
-  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="../browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
-</head>
-<body>
-
-<script type="application/javascript">
-"use strict";
-
-SimpleTest.waitForExplicitFinish();
-browserElementTestHelpers.setEnabledPref(true);
-browserElementTestHelpers.enableProcessPriorityManager();
-
-function runTest() {
-  var os = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
-                        .getService(SpecialPowers.Ci.nsIObserverService);
-  var iframe = document.createElement("iframe");
-  iframe.setAttribute("mozbrowser", true);
-
-  iframe.src = browserElementTestHelpers.emptyPage1;
-
-  var childID = null;
-  Promise.all([
-    expectOnlyOneProcessCreated("FOREGROUND").then(function(chid) {
-      childID = chid;
-    }),
-    expectMozbrowserEvent(iframe, "loadend")
-  ]).then(function() {
-    var p = expectPriorityChange(childID, "BACKGROUND_PERCEIVABLE");
-
-    // We simulate opening an activity
-    os.notifyObservers(null, "activity-opened", childID);
-
-    // We wait until mozbrowserloadend before calling setVisible, because
-    // setVisible isn't available until mozbrowser has loaded.  In practice, that
-    // means we can call setVisible once we've gotten /any/ mozbrowser event.
-    iframe.setVisible(false);
-    return p;
-  }).then(function() {
-    var p = expectPriorityChange(childID, "BACKGROUND");
-
-    // Now we simulate closing an activity
-    os.notifyObservers(null, "activity-closed", childID);
-
-    return p;
-  }).then(SimpleTest.finish);
-
-  document.body.appendChild(iframe);
-}
-
-addEventListener("testready", runTest);
-
-</script>
-</body>
-</html>
--- a/dom/ipc/ProcessPriorityManager.cpp
+++ b/dom/ipc/ProcessPriorityManager.cpp
@@ -248,18 +248,16 @@ public:
    * The reference returned here is guaranteed to be live until the next call
    * to NameWithComma() or until the ParticularProcessPriorityManager is
    * destroyed, whichever comes first.
    */
   const nsAutoCString& NameWithComma();
 
   void OnRemoteBrowserFrameShown(nsISupports* aSubject);
   void OnTabParentDestroyed(nsISupports* aSubject);
-  void OnActivityOpened(const char16_t* aData);
-  void OnActivityClosed(const char16_t* aData);
 
   ProcessPriority CurrentPriority();
   ProcessPriority ComputePriority();
 
   enum TimeoutPref {
     BACKGROUND_PERCEIVABLE_GRACE_PERIOD,
     BACKGROUND_GRACE_PERIOD,
   };
@@ -283,17 +281,16 @@ private:
     const char* aTopic,
     const char* aData = nullptr);
 
   ContentParent* mContentParent;
   uint64_t mChildID;
   ProcessPriority mPriority;
   bool mHoldsCPUWakeLock;
   bool mHoldsHighPriorityWakeLock;
-  bool mIsActivityOpener;
 
   /**
    * Used to implement NameWithComma().
    */
   nsAutoCString mNameWithComma;
 
   nsCOMPtr<nsITimer> mResetPriorityTimer;
 };
@@ -548,17 +545,16 @@ NS_IMPL_ISUPPORTS(ParticularProcessPrior
 
 ParticularProcessPriorityManager::ParticularProcessPriorityManager(
   ContentParent* aContentParent)
   : mContentParent(aContentParent)
   , mChildID(aContentParent->ChildID())
   , mPriority(PROCESS_PRIORITY_UNKNOWN)
   , mHoldsCPUWakeLock(false)
   , mHoldsHighPriorityWakeLock(false)
-  , mIsActivityOpener(false)
 {
   MOZ_ASSERT(XRE_IsParentProcess());
   LOGP("Creating ParticularProcessPriorityManager.");
 }
 
 void
 ParticularProcessPriorityManager::StaticInit()
 {
@@ -572,18 +568,16 @@ void
 ParticularProcessPriorityManager::Init()
 {
   RegisterWakeLockObserver(this);
 
   nsCOMPtr<nsIObserverService> os = services::GetObserverService();
   if (os) {
     os->AddObserver(this, "remote-browser-shown", /* ownsWeak */ true);
     os->AddObserver(this, "ipc:browser-destroyed", /* ownsWeak */ true);
-    os->AddObserver(this, "activity-opened", /* ownsWeak */ true);
-    os->AddObserver(this, "activity-closed", /* ownsWeak */ true);
   }
 
   // This process may already hold the CPU lock; for example, our parent may
   // have acquired it on our behalf.
   WakeLockInformation info1, info2;
   GetWakeLockInfo(NS_LITERAL_STRING("cpu"), &info1);
   mHoldsCPUWakeLock = info1.lockingProcesses().Contains(ChildID());
 
@@ -645,20 +639,16 @@ ParticularProcessPriorityManager::Observ
   }
 
   nsDependentCString topic(aTopic);
 
   if (topic.EqualsLiteral("remote-browser-shown")) {
     OnRemoteBrowserFrameShown(aSubject);
   } else if (topic.EqualsLiteral("ipc:browser-destroyed")) {
     OnTabParentDestroyed(aSubject);
-  } else if (topic.EqualsLiteral("activity-opened")) {
-    OnActivityOpened(aData);
-  } else if (topic.EqualsLiteral("activity-closed")) {
-    OnActivityClosed(aData);
   } else {
     MOZ_ASSERT(false);
   }
 
   return NS_OK;
 }
 
 uint64_t
@@ -733,40 +723,16 @@ ParticularProcessPriorityManager::OnTabP
   if (TabParent::GetFrom(tp)->Manager() != mContentParent) {
     return;
   }
 
   ResetPriority();
 }
 
 void
-ParticularProcessPriorityManager::OnActivityOpened(const char16_t* aData)
-{
-  uint64_t childID = nsCRT::atoll(NS_ConvertUTF16toUTF8(aData).get());
-
-  if (ChildID() == childID) {
-    LOGP("Marking as activity opener");
-    mIsActivityOpener = true;
-    ResetPriority();
-  }
-}
-
-void
-ParticularProcessPriorityManager::OnActivityClosed(const char16_t* aData)
-{
-  uint64_t childID = nsCRT::atoll(NS_ConvertUTF16toUTF8(aData).get());
-
-  if (ChildID() == childID) {
-    LOGP("Unmarking as activity opener");
-    mIsActivityOpener = false;
-    ResetPriority();
-  }
-}
-
-void
 ParticularProcessPriorityManager::ResetPriority()
 {
   ProcessPriority processPriority = ComputePriority();
   if (mPriority == PROCESS_PRIORITY_UNKNOWN ||
       mPriority > processPriority) {
     // Apps set at a perceivable background priority are often playing media.
     // Most media will have short gaps while changing tracks between songs,
     // switching videos, etc.  Give these apps a longer grace period so they
@@ -835,18 +801,17 @@ ParticularProcessPriorityManager::Comput
 {
   // TODO...
   return PROCESS_PRIORITY_FOREGROUND;
 
   if (mHoldsCPUWakeLock || mHoldsHighPriorityWakeLock) {
     return PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE;
   }
 
-  return mIsActivityOpener ? PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE
-                           : PROCESS_PRIORITY_BACKGROUND;
+  return PROCESS_PRIORITY_BACKGROUND;
 }
 
 void
 ParticularProcessPriorityManager::SetPriorityNow(ProcessPriority aPriority)
 {
   if (aPriority == PROCESS_PRIORITY_UNKNOWN) {
     MOZ_ASSERT(false);
     return;