Bug 1157030 - Revert bug 1142806. r=khuey

This commit is contained in:
Gabriele Svelto 2015-04-30 11:25:29 +02:00
parent 2b7a2633ce
commit 25e7d9d88b
13 changed files with 10 additions and 309 deletions

View File

@ -53,8 +53,7 @@ const browserElementTestHelpers = {
['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]
);
},
@ -229,43 +228,6 @@ function expectPriorityWithLRUSet(childID, expectedPriority, expectedLRU) {
});
}
// 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) {

View File

@ -27,4 +27,3 @@ support-files = file_NestedFramesOuter.html
[test_WebGLContextLost.html]
disabled = bug 865844
support-files = file_WebGLContextLost.html
[test_DelayedBackgroundTransition.html]

View File

@ -18,17 +18,6 @@ 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);
@ -62,7 +51,7 @@ function runTest() {
// service. This is controled by the media.useAudioChannelService pref.
addEventListener('testready', function() {
SpecialPowers.pushPrefEnv({set: [['media.useAudioChannelService', true]]},
setupTest);
runTest);
});
</script>

View File

@ -19,17 +19,6 @@ 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);
@ -58,7 +47,7 @@ function runTest() {
document.body.appendChild(iframe);
}
addEventListener('testready', setupTest);
addEventListener('testready', runTest);
</script>
</body>

View File

@ -20,17 +20,6 @@ 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);
@ -79,7 +68,7 @@ function runTest() {
document.body.appendChild(iframe1);
}
addEventListener('testready', setupTest);
addEventListener('testready', runTest);
</script>
</body>

View File

@ -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>

View File

@ -33,17 +33,6 @@ addEventListener('unload', function() {
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);
@ -73,7 +62,7 @@ addEventListener('testready', function() {
// set the timeout to a large value.
SpecialPowers.pushPrefEnv(
{set: [["dom.ipc.systemMessageCPULockTimeoutSec", 99999]]},
setupTest);
runTest);
});
</script>

View File

@ -19,17 +19,6 @@ 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);
@ -59,7 +48,7 @@ function runTest() {
document.body.appendChild(iframe);
}
addEventListener('testready', setupTest);
addEventListener('testready', runTest);
</script>
</body>

View File

@ -19,17 +19,6 @@ 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);
@ -64,7 +53,7 @@ function runTest() {
document.body.appendChild(iframe);
}
addEventListener('testready', setupTest);
addEventListener('testready', runTest);
</script>
</body>
</html>

View File

@ -32,17 +32,6 @@ addEventListener('unload', function() {
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:
//
@ -80,7 +69,7 @@ function runTest() {
document.body.appendChild(iframe);
}
addEventListener('testready', setupTest);
addEventListener('testready', runTest);
</script>
</body>

View File

@ -18,17 +18,6 @@ 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);
@ -57,7 +46,7 @@ function runTest() {
document.body.appendChild(iframe);
}
addEventListener('testready', setupTest);
addEventListener('testready', runTest);
</script>
</body>
</html>

View File

@ -19,17 +19,6 @@ 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);
@ -102,7 +91,7 @@ addEventListener('testready', function() {
// 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>

View File

@ -38,8 +38,6 @@
#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.
@ -204,26 +202,6 @@ public:
*/
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;
@ -258,10 +236,6 @@ private:
/** Contains a pseudo-LRU list of foreground processes */
ProcessLRUPool mForegroundLRUPool;
/** Contains the delayed priority change request */
std::pair<nsRefPtr<ParticularProcessPriorityManager>, hal::ProcessPriority>
mDelayedSetPriority;
};
/**
@ -451,7 +425,6 @@ ProcessPriorityManagerImpl::ProcessPriorityManagerImpl()
{
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
RegisterWakeLockObserver(this);
mDelayedSetPriority = std::make_pair(nullptr, PROCESS_PRIORITY_UNKNOWN);
}
ProcessPriorityManagerImpl::~ProcessPriorityManagerImpl()
@ -568,10 +541,6 @@ ProcessPriorityManagerImpl::ObserveContentParentDestroyed(nsISupports* aSubject)
if (mHighPriorityChildIDs.Contains(childID)) {
mHighPriorityChildIDs.RemoveEntry(childID);
}
if (mDelayedSetPriority.first == pppm) {
mDelayedSetPriority = std::make_pair(nullptr, PROCESS_PRIORITY_UNKNOWN);
}
}
}
@ -670,55 +639,6 @@ ProcessPriorityManagerImpl::Unfreeze()
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,
@ -1125,20 +1045,6 @@ ParticularProcessPriorityManager::SetPriorityNow(ProcessPriority 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);
@ -1155,12 +1061,6 @@ ParticularProcessPriorityManager::SetPriorityNow(ProcessPriority aPriority,
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