Bug 1157030 - Revert bug 1142806. r=khuey
authorGabriele Svelto <gsvelto@mozilla.com>
Thu, 30 Apr 2015 11:25:29 +0200
changeset 244243 42259ecc8e7621dd243415035596c07356ab07ee
parent 244208 35918b0441b4ea614185fe2df5e8de4db9fb28d9
child 244244 ade63ea87e0e977fb437f27f67786487679f86c8
push id28773
push usercbook@mozilla.com
push dateMon, 18 May 2015 11:43:50 +0000
treeherdermozilla-central@f578b845c4b8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs1157030, 1142806
milestone41.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 1157030 - Revert bug 1142806. r=khuey
dom/browser-element/mochitest/browserElementTestHelpers.js
dom/browser-element/mochitest/priority/mochitest.ini
dom/browser-element/mochitest/priority/test_Audio.html
dom/browser-element/mochitest/priority/test_Background.html
dom/browser-element/mochitest/priority/test_BackgroundLRU.html
dom/browser-element/mochitest/priority/test_DelayedBackgroundTransition.html
dom/browser-element/mochitest/priority/test_ExpectingSystemMessage2.html
dom/browser-element/mochitest/priority/test_Keyboard.html
dom/browser-element/mochitest/priority/test_MultipleFrames.html
dom/browser-element/mochitest/priority/test_NestedFrames.html
dom/browser-element/mochitest/priority/test_Visibility.html
dom/browser-element/mochitest/priority/test_WebGLContextLost.html
dom/ipc/ProcessPriorityManager.cpp
--- a/dom/browser-element/mochitest/browserElementTestHelpers.js
+++ b/dom/browser-element/mochitest/browserElementTestHelpers.js
@@ -48,18 +48,17 @@ const browserElementTestHelpers = {
     }
   },
 
   enableProcessPriorityManager: function() {
     this._setPrefs(
       ['dom.ipc.processPriorityManager.BACKGROUND.LRUPoolLevels', 2],
       ['dom.ipc.processPriorityManager.FOREGROUND.LRUPoolLevels', 2],
       ['dom.ipc.processPriorityManager.testMode', true],
-      ['dom.ipc.processPriorityManager.enabled', true],
-      ['dom.ipc.processCount', 3]
+      ['dom.ipc.processPriorityManager.enabled', true]
     );
   },
 
   setEnabledPref: function(value) {
     this._setPref('dom.mozBrowserFramesEnabled', value);
   },
 
   setSelectionChangeEnabledPref: function(value) {
@@ -224,53 +223,16 @@ function expectPriorityWithLRUSet(childI
         } else {
           reject();
         }
       }
     );
   });
 }
 
-// Returns a promise which is resolved or rejected the next time the process
-// childID delays its priority change. We resolve if the priority matches
-// expectedPriority, and we reject otherwise.
-
-function expectPriorityDelay(childID, expectedPriority) {
-  return new Promise(function(resolve, reject) {
-    var observed = false;
-    browserElementTestHelpers.addProcessPriorityObserver(
-      'process-priority-delayed',
-      function(subject, topic, data) {
-        if (observed) {
-          return;
-        }
-
-        var [id, priority] = data.split(":");
-        if (id != childID) {
-          return;
-        }
-
-        // Make sure we run the is() calls in this observer only once, otherwise
-        // we'll expect /every/ priority change to match expectedPriority.
-        observed = true;
-
-        is(priority, expectedPriority,
-           'Expected delayed priority change of childID ' + childID +
-           ' to ' + expectedPriority);
-
-        if (priority == expectedPriority) {
-          resolve();
-        } else {
-          reject();
-        }
-      }
-    );
-  });
-}
-
 // Returns a promise which is resolved the first time the given iframe fires
 // the mozbrowser##eventName event.
 function expectMozbrowserEvent(iframe, eventName) {
   return new Promise(function(resolve, reject) {
     iframe.addEventListener('mozbrowser' + eventName, function handler(e) {
       iframe.removeEventListener('mozbrowser' + eventName, handler);
       resolve(e);
     });
--- a/dom/browser-element/mochitest/priority/mochitest.ini
+++ b/dom/browser-element/mochitest/priority/mochitest.ini
@@ -22,9 +22,8 @@ support-files = file_MultipleFrames.html
 disabled = bug 968604, bug 987164
 [test_ExpectingSystemMessage.html]
 [test_ExpectingSystemMessage2.html]
 [test_NestedFrames.html]
 support-files = file_NestedFramesOuter.html
 [test_WebGLContextLost.html]
 disabled = bug 865844
 support-files = file_WebGLContextLost.html
-[test_DelayedBackgroundTransition.html]
--- a/dom/browser-element/mochitest/priority/test_Audio.html
+++ b/dom/browser-element/mochitest/priority/test_Audio.html
@@ -13,27 +13,16 @@ Test that frames playing audio get BACKG
 <script type="application/javascript;version=1.7">
 "use strict";
 
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 browserElementTestHelpers.enableProcessPriorityManager();
 
-// ProcessPriorityManager requires at least one process in foreground
-// so that other processes can transit freely between foreground and
-// background.
-function setupTest() {
-  var foreground = document.createElement('iframe');
-  foreground.setAttribute('mozbrowser', true);
-  foreground.src = browserElementTestHelpers.emptyPage;
-  expectMozbrowserEvent(foreground, 'loadend').then(runTest);
-  document.body.appendChild(foreground);
-}
-
 function runTest() {
   var iframe = document.createElement('iframe');
   iframe.setAttribute('mozbrowser', true);
   iframe.src = 'file_Audio.html';
 
   var childID = null;
   Promise.all([
     expectOnlyOneProcessCreated("FOREGROUND").then(function(chid) {
@@ -57,14 +46,14 @@ function runTest() {
 
   document.body.appendChild(iframe);
 }
 
 // This test relies on <audio> elements interacting with the audio channel
 // service.  This is controled by the media.useAudioChannelService pref.
 addEventListener('testready', function() {
   SpecialPowers.pushPrefEnv({set: [['media.useAudioChannelService', true]]},
-                            setupTest);
+                            runTest);
 });
 
 </script>
 </body>
 </html>
--- a/dom/browser-element/mochitest/priority/test_Background.html
+++ b/dom/browser-element/mochitest/priority/test_Background.html
@@ -14,27 +14,16 @@ change.
 <script type="application/javascript;version=1.7">
 "use strict";
 
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 browserElementTestHelpers.enableProcessPriorityManager();
 
-// ProcessPriorityManager requires at least one process in foreground
-// so that other processes can transit freely between foreground and
-// background.
-function setupTest() {
-  var foreground = document.createElement('iframe');
-  foreground.setAttribute('mozbrowser', true);
-  foreground.src = browserElementTestHelpers.emptyPage;
-  expectMozbrowserEvent(foreground, 'loadend').then(runTest);
-  document.body.appendChild(foreground);
-}
-
 function runTest() {
   var iframe = document.createElement('iframe');
   iframe.setAttribute('mozbrowser', true);
 
   iframe.src = browserElementTestHelpers.emptyPage1;
 
   var childID = null;
   Promise.all([
@@ -53,13 +42,13 @@ function runTest() {
   }).then(function() {
     var p = expectPriorityChange(childID, 'FOREGROUND');
     iframe.setVisible(true);
   }).then(SimpleTest.finish);
 
   document.body.appendChild(iframe);
 }
 
-addEventListener('testready', setupTest);
+addEventListener('testready', runTest);
 
 </script>
 </body>
 </html>
--- a/dom/browser-element/mochitest/priority/test_BackgroundLRU.html
+++ b/dom/browser-element/mochitest/priority/test_BackgroundLRU.html
@@ -15,27 +15,16 @@ change.
 "use strict";
 
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 browserElementTestHelpers.enableProcessPriorityManager();
 SpecialPowers.addPermission("embed-apps", true, document);
 
-// ProcessPriorityManager requires at least one process in foreground
-// so that other processes can transit freely between foreground and
-// background.
-function setupTest() {
-  var foreground = document.createElement('iframe');
-  foreground.setAttribute('mozbrowser', true);
-  foreground.src = browserElementTestHelpers.emptyPage;
-  expectMozbrowserEvent(foreground, 'loadend').then(runTest);
-  document.body.appendChild(foreground);
-}
-
 function runTest() {
   var iframe1 = document.createElement('iframe');
   iframe1.setAttribute('mozbrowser', true);
   iframe1.src = 'file_MultipleFrames.html';
 
   var iframe2 = null;
   var childID = null;
 
@@ -74,13 +63,13 @@ function runTest() {
     return p;
   }).then(function() {
     SimpleTest.finish();
   });
 
   document.body.appendChild(iframe1);
 }
 
-addEventListener('testready', setupTest);
+addEventListener('testready', runTest);
 
 </script>
 </body>
 </html>
deleted file mode 100644
--- a/dom/browser-element/mochitest/priority/test_DelayedBackgroundTransition.html
+++ /dev/null
@@ -1,61 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-Test that a process won't transit to BACKGROUND priority unless
-there is at least one FOREGROUND process.
--->
-<head>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="../browserElementTestHelpers.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-</head>
-<body>
-  <script type="application/javascript;version=1.7">
-    "use strict";
-
-    SimpleTest.waitForExplicitFinish();
-    browserElementTestHelpers.setEnabledPref(true);
-    browserElementTestHelpers.addPermission();
-    browserElementTestHelpers.enableProcessPriorityManager();
-
-    function insertForegroundFrame() {
-      var foreground = document.createElement('iframe');
-      foreground.setAttribute('mozbrowser', true);
-      foreground.setAttribute('id', 'foreground');
-      foreground.src = browserElementTestHelpers.emptyPage;
-      expectMozbrowserEvent(foreground, 'loadend');
-      document.body.appendChild(foreground);
-    }
-
-    function runTest() {
-      var iframe = document.createElement('iframe');
-      iframe.setAttribute('mozbrowser', true);
-      iframe.src = browserElementTestHelpers.emptyPage;
-
-      var childID = null;
-      Promise.all([
-        expectProcessCreated('FOREGROUND').then(function(chid) {
-          childID = chid;
-        }),
-        expectMozbrowserEvent(iframe, 'loadend')
-      ]).then(function() {
-        var p = expectPriorityDelay(childID, 'BACKGROUND');
-        iframe.setVisible(false);
-        return p;
-      }).then(function() {
-        var p = expectPriorityChange(childID, 'BACKGROUND');
-        insertForegroundFrame();
-        return p;
-      }).then(function() {
-        var p = expectPriorityChange(childID, 'FOREGROUND');
-        iframe.setVisible(true);
-        return p;
-      }).then(SimpleTest.finish);
-
-      document.body.appendChild(iframe);
-    }
-
-    addEventListener('testready', runTest);
-  </script>
-</body>
-</html>
--- a/dom/browser-element/mochitest/priority/test_ExpectingSystemMessage2.html
+++ b/dom/browser-element/mochitest/priority/test_ExpectingSystemMessage2.html
@@ -28,27 +28,16 @@ SpecialPowers.addPermission("browser", t
 
 addEventListener('unload', function() {
   var principal = SpecialPowers.wrap(document).nodePrincipal;
   SpecialPowers.removePermission("browser", { url: SpecialPowers.wrap(principal.URI).spec,
                                               appId: principal.appId,
                                               isInBrowserElement: true });
 });
 
-// ProcessPriorityManager requires at least one process in foreground
-// so that other processes can transit freely between foreground and
-// background.
-function setupTest() {
-  var foreground = document.createElement('iframe');
-  foreground.setAttribute('mozbrowser', true);
-  foreground.src = browserElementTestHelpers.emptyPage;
-  expectMozbrowserEvent(foreground, 'loadend').then(runTest);
-  document.body.appendChild(foreground);
-}
-
 function runTest() {
   var iframe = document.createElement('iframe');
   iframe.setAttribute('mozbrowser', true);
   iframe.setAttribute('expecting-system-message', true);
   iframe.setAttribute('mozapp', 'http://example.org/manifest.webapp');
 
   iframe.src = browserElementTestHelpers.emptyPage1;
 
@@ -68,14 +57,14 @@ function runTest() {
 }
 
 addEventListener('testready', function() {
   // We don't want this wake lock to time out during the test; if it did, then
   // we might see BACKGROUND priority instead of BACKGROUND_PERCEIVABLE.  So
   // set the timeout to a large value.
   SpecialPowers.pushPrefEnv(
     {set: [["dom.ipc.systemMessageCPULockTimeoutSec", 99999]]},
-    setupTest);
+    runTest);
 });
 
 </script>
 </body>
 </html>
--- a/dom/browser-element/mochitest/priority/test_Keyboard.html
+++ b/dom/browser-element/mochitest/priority/test_Keyboard.html
@@ -14,27 +14,16 @@ priority level when in the foreground.
 <script type="application/javascript;version=1.7">
 "use strict";
 
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 browserElementTestHelpers.enableProcessPriorityManager();
 
-// ProcessPriorityManager requires at least one process in foreground
-// so that other processes can transit freely between foreground and
-// background.
-function setupTest() {
-  var foreground = document.createElement('iframe');
-  foreground.setAttribute('mozbrowser', true);
-  foreground.src = browserElementTestHelpers.emptyPage;
-  expectMozbrowserEvent(foreground, 'loadend').then(runTest);
-  document.body.appendChild(foreground);
-}
-
 function runTest() {
   var iframe = document.createElement('iframe');
   iframe.setAttribute('mozbrowser', true);
   iframe.setAttribute('mozapptype', 'inputmethod');
   iframe.src = browserElementTestHelpers.emptyPage1;
 
   var childID = null;
   Promise.all([
@@ -54,13 +43,13 @@ function runTest() {
   }).then(function() {
     var p = expectPriorityChange(childID, 'FOREGROUND_KEYBOARD');
     iframe.setVisible(true);
   }).then(SimpleTest.finish);
 
   document.body.appendChild(iframe);
 }
 
-addEventListener('testready', setupTest);
+addEventListener('testready', runTest);
 
 </script>
 </body>
 </html>
--- a/dom/browser-element/mochitest/priority/test_MultipleFrames.html
+++ b/dom/browser-element/mochitest/priority/test_MultipleFrames.html
@@ -14,27 +14,16 @@ priority is recomputed.
 <script type="application/javascript;version=1.7">
 "use strict";
 
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 browserElementTestHelpers.enableProcessPriorityManager();
 
-// ProcessPriorityManager requires at least one process in foreground
-// so that other processes can transit freely between foreground and
-// background.
-function setupTest() {
-  var foreground = document.createElement('iframe');
-  foreground.setAttribute('mozbrowser', true);
-  foreground.src = browserElementTestHelpers.emptyPage;
-  expectMozbrowserEvent(foreground, 'loadend').then(runTest);
-  document.body.appendChild(foreground);
-}
-
 function runTest() {
   var iframe = document.createElement('iframe');
   iframe.setAttribute('mozbrowser', true);
   iframe.src = 'file_MultipleFrames.html';
 
   var childID = null;
   var iframe2;
   Promise.all([
@@ -59,12 +48,12 @@ function runTest() {
     iframe.setVisible(false);
     document.body.removeChild(iframe2);
     return p;
   }).then(SimpleTest.finish);
 
   document.body.appendChild(iframe);
 }
 
-addEventListener('testready', setupTest);
+addEventListener('testready', runTest);
 </script>
 </body>
 </html>
--- a/dom/browser-element/mochitest/priority/test_NestedFrames.html
+++ b/dom/browser-element/mochitest/priority/test_NestedFrames.html
@@ -27,27 +27,16 @@ SpecialPowers.addPermission("browser", t
 
 addEventListener('unload', function() {
   var principal = SpecialPowers.wrap(document).nodePrincipal;
   SpecialPowers.removePermission("browser", { url: SpecialPowers.wrap(principal.URI).spec,
                                               appId: principal.appId,
                                               isInBrowserElement: true });
 });
 
-// ProcessPriorityManager requires at least one process in foreground
-// so that other processes can transit freely between foreground and
-// background.
-function setupTest() {
-  var foreground = document.createElement('iframe');
-  foreground.setAttribute('mozbrowser', true);
-  foreground.src = browserElementTestHelpers.emptyPage;
-  expectMozbrowserEvent(foreground, 'loadend').then(runTest);
-  document.body.appendChild(foreground);
-}
-
 function runTest() {
   // Set up the following hierarchy of frames:
   //
   //   <iframe mozbrowser remote=false src='file_NestedFramesOuter.html'>
   //     <iframe mozbrowser remote=true src='file_empty.html'>
   //
   // When we change the visibility of the outer iframe, it should change the
   // priority of the inner one.
@@ -75,13 +64,13 @@ function runTest() {
     var p = expectPriorityChange(childID, 'FOREGROUND');
     iframe.setVisible(true);
     return p;
   }).then(SimpleTest.finish);
 
   document.body.appendChild(iframe);
 }
 
-addEventListener('testready', setupTest);
+addEventListener('testready', runTest);
 
 </script>
 </body>
 </html>
--- a/dom/browser-element/mochitest/priority/test_Visibility.html
+++ b/dom/browser-element/mochitest/priority/test_Visibility.html
@@ -13,27 +13,16 @@ Test that setVisible() changes a process
 <script type="application/javascript;version=1.7">
 "use strict";
 
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 browserElementTestHelpers.enableProcessPriorityManager();
 
-// ProcessPriorityManager requires at least one process in foreground
-// so that other processes can transit freely between foreground and
-// background.
-function setupTest() {
-  var foreground = document.createElement('iframe');
-  foreground.setAttribute('mozbrowser', true);
-  foreground.src = browserElementTestHelpers.emptyPage;
-  expectMozbrowserEvent(foreground, 'loadend').then(runTest);
-  document.body.appendChild(foreground);
-}
-
 function runTest() {
   var iframe = document.createElement('iframe');
   iframe.setAttribute('mozbrowser', true);
   iframe.src = browserElementTestHelpers.emptyPage1;
 
   var childID = null;
   Promise.all([
     expectOnlyOneProcessCreated('FOREGROUND').then(function(chid) {
@@ -52,12 +41,12 @@ function runTest() {
     var p = expectPriorityChange(childID, 'FOREGROUND');
     iframe.setVisible(true);
     return p;
   }).then(SimpleTest.finish);
 
   document.body.appendChild(iframe);
 }
 
-addEventListener('testready', setupTest);
+addEventListener('testready', runTest);
 </script>
 </body>
 </html>
--- a/dom/browser-element/mochitest/priority/test_WebGLContextLost.html
+++ b/dom/browser-element/mochitest/priority/test_WebGLContextLost.html
@@ -14,27 +14,16 @@ notification causes a WebGL context loss
 <script type="application/javascript;version=1.7">
 "use strict";
 
 SimpleTest.waitForExplicitFinish();
 browserElementTestHelpers.setEnabledPref(true);
 browserElementTestHelpers.addPermission();
 browserElementTestHelpers.enableProcessPriorityManager();
 
-// ProcessPriorityManager requires at least one process in foreground
-// so that other processes can transit freely between foreground and
-// background.
-function setupTest() {
-  var foreground = document.createElement('iframe');
-  foreground.setAttribute('mozbrowser', true);
-  foreground.src = browserElementTestHelpers.emptyPage;
-  expectMozbrowserEvent(foreground, 'loadend').then(runTest);
-  document.body.appendChild(foreground);
-}
-
 function runTest() {
   var iframe = document.createElement('iframe');
   iframe.setAttribute('mozbrowser', true);
   iframe.src = 'file_WebGLContextLost.html';
 
   // We use this to ensure that we don't call SimpleTest.finish() twice.
   var finished = false;
   function finishOnce() {
@@ -97,14 +86,14 @@ addEventListener('testready', function()
   // processes never read the driver info themselves, nor do they get it from
   // their parent, so they refuse to start up WebGL.
   //
   // This isn't a problem on B2G because we force WebGL on there.  But it
   // obviously makes this test difficult.  bjacob says forcing WebGL on here
   // shouldn't hurt things, and anyway this setting mirrors what we do on B2G,
   // which is what we're trying to test!
   SpecialPowers.pushPrefEnv({set: [["webgl.force-enabled", true]]},
-                            setupTest);
+                            runTest);
 });
 
 </script>
 </body>
 </html>
--- a/dom/ipc/ProcessPriorityManager.cpp
+++ b/dom/ipc/ProcessPriorityManager.cpp
@@ -33,18 +33,16 @@
 #else
 #include <unistd.h>
 #endif
 
 #ifdef LOG
 #undef LOG
 #endif
 
-#include <utility>
-
 // Use LOGP inside a ParticularProcessPriorityManager method; use LOG
 // everywhere else.  LOGP prints out information about the particular process
 // priority manager.
 //
 // (Wow, our logging story is a huge mess.)
 
 // #define ENABLE_LOGGING 1
 
@@ -199,36 +197,16 @@ public:
   void Freeze();
 
   /**
    * Allow process' priorities to change again.  This will immediately adjust
    * processes whose priority change did not happen because of the freeze.
    */
   void Unfreeze();
 
-  /**
-   * Return the number of processes that have
-   * PROCESS_PRIORITY_FOREGROUND priority.
-   */
-  uint32_t NumberOfForegroundProcesses();
-
-  /**
-   * Register a priority change to be performed at later time.
-   */
-  void ScheduleDelayedSetPriority(
-    ParticularProcessPriorityManager* aParticularManager,
-    hal::ProcessPriority aPriority);
-
-  /**
-   * Perform the registered priority change unless
-   * aLastParticularManager is the same as the registered one.
-   */
-  void PerformDelayedSetPriority(
-    ParticularProcessPriorityManager* aLastParticularManager);
-
 private:
   static bool sPrefListenersRegistered;
   static bool sInitialized;
   static bool sFrozen;
   static StaticRefPtr<ProcessPriorityManagerImpl> sSingleton;
 
   static void PrefChangedCallback(const char* aPref, void* aClosure);
 
@@ -253,20 +231,16 @@ private:
   /** Contains the PIDs of child processes holding high-priority wakelocks */
   nsTHashtable<nsUint64HashKey> mHighPriorityChildIDs;
 
   /** Contains a pseudo-LRU list of background processes */
   ProcessLRUPool mBackgroundLRUPool;
 
   /** Contains a pseudo-LRU list of foreground processes */
   ProcessLRUPool mForegroundLRUPool;
-
-  /** Contains the delayed priority change request */
-  std::pair<nsRefPtr<ParticularProcessPriorityManager>, hal::ProcessPriority>
-    mDelayedSetPriority;
 };
 
 /**
  * This singleton class implements the parts of the process priority manager
  * that are available from all processes.
  */
 class ProcessPriorityManagerChild final
   : public nsIObserver
@@ -446,17 +420,16 @@ ProcessPriorityManagerImpl::GetSingleton
 
 ProcessPriorityManagerImpl::ProcessPriorityManagerImpl()
     : mHighPriority(false)
     , mBackgroundLRUPool(PROCESS_PRIORITY_BACKGROUND, 1)
     , mForegroundLRUPool(PROCESS_PRIORITY_FOREGROUND, 0)
 {
   MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
   RegisterWakeLockObserver(this);
-  mDelayedSetPriority = std::make_pair(nullptr, PROCESS_PRIORITY_UNKNOWN);
 }
 
 ProcessPriorityManagerImpl::~ProcessPriorityManagerImpl()
 {
   UnregisterWakeLockObserver(this);
 }
 
 void
@@ -563,20 +536,16 @@ ProcessPriorityManagerImpl::ObserveConte
 
     pppm->ShutDown();
 
     mParticularManagers.Remove(childID);
 
     if (mHighPriorityChildIDs.Contains(childID)) {
       mHighPriorityChildIDs.RemoveEntry(childID);
     }
-
-    if (mDelayedSetPriority.first == pppm) {
-      mDelayedSetPriority = std::make_pair(nullptr, PROCESS_PRIORITY_UNKNOWN);
-    }
   }
 }
 
 bool
 ProcessPriorityManagerImpl::ChildProcessHasHighPriority( void )
 {
   return mHighPriorityChildIDs.Count() > 0;
 }
@@ -665,65 +634,16 @@ UnfreezeParticularProcessPriorityManager
 void
 ProcessPriorityManagerImpl::Unfreeze()
 {
   sFrozen = false;
   mParticularManagers.EnumerateRead(&UnfreezeParticularProcessPriorityManagers,
                                     nullptr);
 }
 
-static PLDHashOperator
-CountNumberOfForegroundProcesses(
-  const uint64_t& aKey,
-  nsRefPtr<ParticularProcessPriorityManager> aValue,
-  void* aUserData)
-{
-  uint32_t* accumulator = static_cast<uint32_t*>(aUserData);
-  if (aValue->CurrentPriority() == PROCESS_PRIORITY_FOREGROUND ||
-      aValue->CurrentPriority() == PROCESS_PRIORITY_FOREGROUND_HIGH) {
-    (*accumulator)++;
-  }
-  return PL_DHASH_NEXT;
-}
-
-uint32_t
-ProcessPriorityManagerImpl::NumberOfForegroundProcesses()
-{
-  uint32_t accumulator = 0;
-  mParticularManagers.EnumerateRead(&CountNumberOfForegroundProcesses,
-                                    &accumulator);
-  return accumulator;
-}
-
-void
-ProcessPriorityManagerImpl::ScheduleDelayedSetPriority(
-  ParticularProcessPriorityManager* aParticularManager,
-  ProcessPriority aPriority)
-{
-  mDelayedSetPriority = std::make_pair(aParticularManager, aPriority);
-}
-
-void
-ProcessPriorityManagerImpl::PerformDelayedSetPriority(
-  ParticularProcessPriorityManager* aLastParticularManager)
-{
-  nsRefPtr<ParticularProcessPriorityManager> pppm = mDelayedSetPriority.first;
-  ProcessPriority priority = mDelayedSetPriority.second;
-
-  mDelayedSetPriority = std::make_pair(nullptr, PROCESS_PRIORITY_UNKNOWN);
-
-  if (pppm == aLastParticularManager) {
-    return;
-  }
-
-  if (pppm && priority != PROCESS_PRIORITY_UNKNOWN) {
-    pppm->SetPriorityNow(priority);
-  }
-}
-
 NS_IMPL_ISUPPORTS(ParticularProcessPriorityManager,
                   nsIObserver,
                   nsITimerCallback,
                   nsISupportsWeakReference);
 
 ParticularProcessPriorityManager::ParticularProcessPriorityManager(
   ContentParent* aContentParent, bool aFrozen)
   : mContentParent(aContentParent)
@@ -1120,52 +1040,32 @@ ParticularProcessPriorityManager::SetPri
   }
 
   LOGP("Changing priority from %s to %s.",
        ProcessPriorityToString(mPriority),
        ProcessPriorityToString(aPriority));
 
   ProcessPriority oldPriority = mPriority;
 
-  if (oldPriority == PROCESS_PRIORITY_FOREGROUND &&
-      aPriority < PROCESS_PRIORITY_FOREGROUND &&
-      ProcessPriorityManagerImpl::GetSingleton()->
-        NumberOfForegroundProcesses() == 1) {
-    LOGP("Attempting to demote the last foreground process is delayed.");
-
-    ProcessPriorityManagerImpl::GetSingleton()->
-      ScheduleDelayedSetPriority(this, aPriority);
-
-    FireTestOnlyObserverNotification("process-priority-delayed",
-      ProcessPriorityToString(aPriority));
-    return;
-  }
-
   mPriority = aPriority;
   hal::SetProcessPriority(Pid(), mPriority);
 
   if (oldPriority != mPriority) {
     ProcessPriorityManagerImpl::GetSingleton()->
       NotifyProcessPriorityChanged(this, oldPriority);
 
     unused << mContentParent->SendNotifyProcessPriorityChanged(mPriority);
   }
 
   if (aPriority < PROCESS_PRIORITY_FOREGROUND) {
     unused << mContentParent->SendFlushMemory(NS_LITERAL_STRING("low-memory"));
   }
 
   FireTestOnlyObserverNotification("process-priority-set",
     ProcessPriorityToString(mPriority));
-
-  if (aPriority >= PROCESS_PRIORITY_FOREGROUND) {
-    LOGP("More than one foreground processes. Run delayed priority change");
-    ProcessPriorityManagerImpl::GetSingleton()->
-      PerformDelayedSetPriority(this);
-  }
 }
 
 void
 ParticularProcessPriorityManager::Freeze()
 {
   mFrozen = true;
 }