mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1119277 - Remove the process CPU priority parameter and simplify all the associated code. r=khuey, r=dhylands
This commit is contained in:
parent
e95e36d777
commit
85e56139a4
@ -111,8 +111,7 @@ const browserElementTestHelpers = {
|
||||
|
||||
// Returns a promise which is resolved when a subprocess is created. The
|
||||
// argument to resolve() is the childID of the subprocess.
|
||||
function expectProcessCreated(/* optional */ initialPriority,
|
||||
/* optional */ initialCPUPriority) {
|
||||
function expectProcessCreated(/* optional */ initialPriority) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var observed = false;
|
||||
browserElementTestHelpers.addProcessPriorityObserver(
|
||||
@ -128,7 +127,7 @@ function expectProcessCreated(/* optional */ initialPriority,
|
||||
var childID = parseInt(data);
|
||||
ok(true, 'Got new process, id=' + childID);
|
||||
if (initialPriority) {
|
||||
expectPriorityChange(childID, initialPriority, initialCPUPriority).then(function() {
|
||||
expectPriorityChange(childID, initialPriority).then(function() {
|
||||
resolve(childID);
|
||||
});
|
||||
} else {
|
||||
@ -141,9 +140,8 @@ function expectProcessCreated(/* optional */ initialPriority,
|
||||
|
||||
// Just like expectProcessCreated(), except we'll call ok(false) if a second
|
||||
// process is created.
|
||||
function expectOnlyOneProcessCreated(/* optional */ initialPriority,
|
||||
/* optional */ initialCPUPriority) {
|
||||
var p = expectProcessCreated(initialPriority, initialCPUPriority);
|
||||
function expectOnlyOneProcessCreated(/* optional */ initialPriority) {
|
||||
var p = expectProcessCreated(initialPriority);
|
||||
p.then(function() {
|
||||
expectProcessCreated().then(function(childID) {
|
||||
ok(false, 'Got unexpected process creation, childID=' + childID);
|
||||
@ -153,15 +151,10 @@ function expectOnlyOneProcessCreated(/* optional */ initialPriority,
|
||||
}
|
||||
|
||||
// Returns a promise which is resolved or rejected the next time the process
|
||||
// childID changes its priority. We resolve if the (priority, CPU priority)
|
||||
// tuple matches (expectedPriority, expectedCPUPriority) and we reject
|
||||
// otherwise.
|
||||
//
|
||||
// expectedCPUPriority is an optional argument; if it's not specified, we
|
||||
// resolve if priority matches expectedPriority.
|
||||
// childID changes its priority. We resolve if the priority matches
|
||||
// expectedPriority, and we reject otherwise.
|
||||
|
||||
function expectPriorityChange(childID, expectedPriority,
|
||||
/* optional */ expectedCPUPriority) {
|
||||
function expectPriorityChange(childID, expectedPriority) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var observed = false;
|
||||
browserElementTestHelpers.addProcessPriorityObserver(
|
||||
@ -171,7 +164,7 @@ function expectPriorityChange(childID, expectedPriority,
|
||||
return;
|
||||
}
|
||||
|
||||
var [id, priority, cpuPriority] = data.split(":");
|
||||
var [id, priority] = data.split(":");
|
||||
if (id != childID) {
|
||||
return;
|
||||
}
|
||||
@ -184,14 +177,7 @@ function expectPriorityChange(childID, expectedPriority,
|
||||
'Expected priority of childID ' + childID +
|
||||
' to change to ' + expectedPriority);
|
||||
|
||||
if (expectedCPUPriority) {
|
||||
is(cpuPriority, expectedCPUPriority,
|
||||
'Expected CPU priority of childID ' + childID +
|
||||
' to change to ' + expectedCPUPriority);
|
||||
}
|
||||
|
||||
if (priority == expectedPriority &&
|
||||
(!expectedCPUPriority || expectedCPUPriority == cpuPriority)) {
|
||||
if (priority == expectedPriority) {
|
||||
resolve();
|
||||
} else {
|
||||
reject();
|
||||
@ -212,13 +198,14 @@ function expectPriorityWithBackgroundLRUSet(childID, expectedBackgroundLRU) {
|
||||
'process-priority-with-background-LRU-set',
|
||||
function(subject, topic, data) {
|
||||
|
||||
var [id, priority, cpuPriority, backgroundLRU] = data.split(":");
|
||||
var [id, priority, backgroundLRU] = data.split(":");
|
||||
if (id != childID) {
|
||||
return;
|
||||
}
|
||||
|
||||
is(backgroundLRU, expectedBackgroundLRU,
|
||||
'Expected backgroundLRU ' + backgroundLRU + ' of childID ' + childID +
|
||||
'Expected backgroundLRU ' + backgroundLRU +
|
||||
' of childID ' + childID +
|
||||
' to change to ' + expectedBackgroundLRU);
|
||||
|
||||
if (backgroundLRU == expectedBackgroundLRU) {
|
||||
|
@ -1,15 +0,0 @@
|
||||
A word to the wise:
|
||||
|
||||
You must ensure that if your test finishes successfully, no processes have
|
||||
priority FOREGROUND_HIGH.
|
||||
|
||||
If you don't do this, expect to see tests randomly fail with mysterious
|
||||
FOREGROUND --> FOREGROUND priority transitions.
|
||||
|
||||
What's happening in this case is that your FOREGROUND_HIGH process lives until
|
||||
the beginning of the next test. This causes the process started by the next
|
||||
test to have low CPU priority. Then the FOREGROUND_HIGH process dies, because
|
||||
its iframe gets GC'ed, and we transition the new test's process from low CPU
|
||||
priority to regular CPU priority.
|
||||
|
||||
Ouch.
|
@ -10,8 +10,6 @@ skip-if = toolkit != "gtk2" || ((buildapp =='mulet' || buildapp == 'b2g') && (to
|
||||
[test_Visibility.html]
|
||||
[test_HighPriority.html]
|
||||
support-files = file_HighPriority.html
|
||||
[test_HighPriorityDowngrade.html]
|
||||
[test_HighPriorityDowngrade2.html]
|
||||
[test_Background.html]
|
||||
[test_BackgroundLRU.html]
|
||||
[test_Audio.html]
|
||||
|
@ -1,81 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
Test that high-priority processes downgrade the CPU priority of regular
|
||||
processes.
|
||||
-->
|
||||
<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();
|
||||
SpecialPowers.addPermission("embed-apps", true, document);
|
||||
|
||||
var iframe = null;
|
||||
var childID = null;
|
||||
|
||||
function runTest() {
|
||||
var iframe = document.createElement('iframe');
|
||||
iframe.setAttribute('mozbrowser', true);
|
||||
|
||||
iframe.src = browserElementTestHelpers.emptyPage1;
|
||||
|
||||
var highPriorityIframe = null;
|
||||
var childID = null;
|
||||
var lock = null;
|
||||
var p = null;
|
||||
|
||||
expectProcessCreated('FOREGROUND', 'CPU_NORMAL').then(function(chid) {
|
||||
childID = chid;
|
||||
}).then(function() {
|
||||
// Create a new, high-priority iframe.
|
||||
highPriorityIframe = document.createElement('iframe');
|
||||
highPriorityIframe.setAttribute('mozbrowser', true);
|
||||
highPriorityIframe.setAttribute('expecting-system-message', true);
|
||||
highPriorityIframe.setAttribute('mozapptype', 'critical');
|
||||
highPriorityIframe.setAttribute('mozapp', 'http://example.org/manifest.webapp');
|
||||
highPriorityIframe.src = browserElementTestHelpers.emptyPage2;
|
||||
|
||||
p = expectPriorityChange(childID, 'FOREGROUND', 'CPU_LOW');
|
||||
|
||||
document.body.appendChild(highPriorityIframe);
|
||||
|
||||
return p;
|
||||
}).then(function() {
|
||||
return expectPriorityChange(childID, 'FOREGROUND', 'CPU_NORMAL');
|
||||
}).then(function() {
|
||||
p = expectPriorityChange(childID, 'FOREGROUND', 'CPU_LOW');
|
||||
lock = navigator.requestWakeLock('high-priority');
|
||||
return p;
|
||||
}).then(function() {
|
||||
p = expectPriorityChange(childID, 'FOREGROUND', 'CPU_NORMAL');
|
||||
lock.unlock();
|
||||
return p;
|
||||
}).then(SimpleTest.finish);
|
||||
|
||||
document.body.appendChild(iframe);
|
||||
}
|
||||
|
||||
addEventListener('testready', function() {
|
||||
SpecialPowers.pushPrefEnv(
|
||||
{set: [
|
||||
/* Cause the CPU wake lock taken on behalf of the high-priority process
|
||||
* to time out after 1s. */
|
||||
["dom.ipc.systemMessageCPULockTimeoutSec", 1],
|
||||
["dom.wakelock.enabled", true]
|
||||
]},
|
||||
runTest);
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,76 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
Test that high-priority processes downgrade the CPU priority of regular
|
||||
processes.
|
||||
|
||||
This is just like test_HighPriorityDowngrade, except instead of waiting for the
|
||||
high-priority process's wake lock to expire, we kill the process by removing
|
||||
its iframe from the DOM.
|
||||
-->
|
||||
<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();
|
||||
SpecialPowers.addPermission("embed-apps", true, document);
|
||||
|
||||
function runTest() {
|
||||
var iframe = document.createElement('iframe');
|
||||
iframe.setAttribute('mozbrowser', true);
|
||||
|
||||
iframe.src = browserElementTestHelpers.emptyPage1;
|
||||
|
||||
var highPriorityIframe = null;
|
||||
var childID = null;
|
||||
|
||||
expectProcessCreated('FOREGROUND', 'CPU_NORMAL').then(function(chid) {
|
||||
childID = chid;
|
||||
}).then(function() {
|
||||
// Create a new, high-priority iframe.
|
||||
highPriorityIframe = document.createElement('iframe');
|
||||
highPriorityIframe.setAttribute('mozbrowser', true);
|
||||
highPriorityIframe.setAttribute('expecting-system-message', true);
|
||||
highPriorityIframe.setAttribute('mozapptype', 'critical');
|
||||
highPriorityIframe.setAttribute('mozapp', 'http://example.org/manifest.webapp');
|
||||
highPriorityIframe.src = browserElementTestHelpers.emptyPage2;
|
||||
|
||||
var p = Promise.all(
|
||||
[expectPriorityChange(childID, 'FOREGROUND', 'CPU_LOW'),
|
||||
expectMozbrowserEvent(highPriorityIframe, 'loadend')]
|
||||
);
|
||||
|
||||
document.body.appendChild(highPriorityIframe);
|
||||
|
||||
return p;
|
||||
}).then(function() {
|
||||
// Killing the high-priority iframe should cause our CPU priority to go back
|
||||
// up to regular.
|
||||
var p = expectPriorityChange(childID, 'FOREGROUND', 'CPU_NORMAL');
|
||||
document.body.removeChild(highPriorityIframe);
|
||||
return p;
|
||||
}).then(SimpleTest.finish);
|
||||
|
||||
document.body.appendChild(iframe);
|
||||
}
|
||||
|
||||
addEventListener('testready', function() {
|
||||
// Cause the CPU wake lock taken on behalf of the high-priority process never
|
||||
// to time out during this test.
|
||||
SpecialPowers.pushPrefEnv(
|
||||
{set: [["dom.ipc.systemMessageCPULockTimeoutSec", 1000]]},
|
||||
runTest);
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -53,7 +53,7 @@ function runTest()
|
||||
|
||||
// Ensure that the preallocated process initially gets BACKGROUND priority.
|
||||
// That's it.
|
||||
expectProcessCreated('PREALLOC', 'CPU_LOW').then(function() {
|
||||
expectProcessCreated('PREALLOC').then(function() {
|
||||
// We need to set the pref asynchoronously or the preallocated process won't
|
||||
// be shut down.
|
||||
SimpleTest.executeSoon(function(){
|
||||
|
@ -138,13 +138,6 @@ public:
|
||||
void FireTestOnlyObserverNotification(const char* aTopic,
|
||||
const nsACString& aData = EmptyCString());
|
||||
|
||||
/**
|
||||
* Does some process, other than the one handled by aParticularManager, have
|
||||
* priority FOREGROUND_HIGH?
|
||||
*/
|
||||
bool OtherProcessHasHighPriority(
|
||||
ParticularProcessPriorityManager* aParticularManager);
|
||||
|
||||
/**
|
||||
* Does one of the child processes have priority FOREGROUND_HIGH?
|
||||
*/
|
||||
@ -182,7 +175,6 @@ private:
|
||||
|
||||
void ObserveContentParentCreated(nsISupports* aContentParent);
|
||||
void ObserveContentParentDestroyed(nsISupports* aSubject);
|
||||
void ResetAllCPUPriorities();
|
||||
|
||||
nsDataHashtable<nsUint64HashKey, nsRefPtr<ParticularProcessPriorityManager> >
|
||||
mParticularManagers;
|
||||
@ -267,23 +259,11 @@ public:
|
||||
|
||||
ProcessPriority CurrentPriority();
|
||||
ProcessPriority ComputePriority();
|
||||
ProcessCPUPriority ComputeCPUPriority(ProcessPriority aPriority);
|
||||
|
||||
void ScheduleResetPriority(const char* aTimeoutPref);
|
||||
void ResetPriority();
|
||||
void ResetPriorityNow();
|
||||
void ResetCPUPriorityNow();
|
||||
|
||||
/**
|
||||
* This overload is equivalent to SetPriorityNow(aPriority,
|
||||
* ComputeCPUPriority()).
|
||||
*/
|
||||
void SetPriorityNow(ProcessPriority aPriority,
|
||||
uint32_t aBackgroundLRU = 0);
|
||||
|
||||
void SetPriorityNow(ProcessPriority aPriority,
|
||||
ProcessCPUPriority aCPUPriority,
|
||||
uint32_t aBackgroundLRU = 0);
|
||||
void SetPriorityNow(ProcessPriority aPriority, uint32_t aBackgroundLRU = 0);
|
||||
|
||||
void ShutDown();
|
||||
|
||||
@ -299,7 +279,6 @@ private:
|
||||
ContentParent* mContentParent;
|
||||
uint64_t mChildID;
|
||||
ProcessPriority mPriority;
|
||||
ProcessCPUPriority mCPUPriority;
|
||||
bool mHoldsCPUWakeLock;
|
||||
bool mHoldsHighPriorityWakeLock;
|
||||
|
||||
@ -439,8 +418,7 @@ ProcessPriorityManagerImpl::Init()
|
||||
// The master process's priority never changes; set it here and then forget
|
||||
// about it. We'll manage only subprocesses' priorities using the process
|
||||
// priority manager.
|
||||
hal::SetProcessPriority(getpid(), PROCESS_PRIORITY_MASTER,
|
||||
PROCESS_CPU_PRIORITY_NORMAL);
|
||||
hal::SetProcessPriority(getpid(), PROCESS_PRIORITY_MASTER);
|
||||
|
||||
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
||||
if (os) {
|
||||
@ -517,18 +495,6 @@ ProcessPriorityManagerImpl::ObserveContentParentCreated(
|
||||
GetParticularProcessPriorityManager(cp->AsContentParent());
|
||||
}
|
||||
|
||||
static PLDHashOperator
|
||||
EnumerateParticularProcessPriorityManagers(
|
||||
const uint64_t& aKey,
|
||||
nsRefPtr<ParticularProcessPriorityManager> aValue,
|
||||
void* aUserData)
|
||||
{
|
||||
nsTArray<nsRefPtr<ParticularProcessPriorityManager> >* aArray =
|
||||
static_cast<nsTArray<nsRefPtr<ParticularProcessPriorityManager> >*>(aUserData);
|
||||
aArray->AppendElement(aValue);
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
void
|
||||
ProcessPriorityManagerImpl::ObserveContentParentDestroyed(nsISupports* aSubject)
|
||||
{
|
||||
@ -548,38 +514,10 @@ ProcessPriorityManagerImpl::ObserveContentParentDestroyed(nsISupports* aSubject)
|
||||
|
||||
if (mHighPriorityChildIDs.Contains(childID)) {
|
||||
mHighPriorityChildIDs.RemoveEntry(childID);
|
||||
|
||||
// We just lost a high-priority process; reset everyone's CPU priorities.
|
||||
ResetAllCPUPriorities();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ProcessPriorityManagerImpl::ResetAllCPUPriorities( void )
|
||||
{
|
||||
nsTArray<nsRefPtr<ParticularProcessPriorityManager> > pppms;
|
||||
mParticularManagers.EnumerateRead(
|
||||
&EnumerateParticularProcessPriorityManagers,
|
||||
&pppms);
|
||||
|
||||
for (uint32_t i = 0; i < pppms.Length(); i++) {
|
||||
pppms[i]->ResetCPUPriorityNow();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
ProcessPriorityManagerImpl::OtherProcessHasHighPriority(
|
||||
ParticularProcessPriorityManager* aParticularManager)
|
||||
{
|
||||
if (mHighPriority) {
|
||||
return true;
|
||||
} else if (mHighPriorityChildIDs.Contains(aParticularManager->ChildID())) {
|
||||
return mHighPriorityChildIDs.Count() > 1;
|
||||
}
|
||||
return mHighPriorityChildIDs.Count() > 0;
|
||||
}
|
||||
|
||||
bool
|
||||
ProcessPriorityManagerImpl::ChildProcessHasHighPriority( void )
|
||||
{
|
||||
@ -591,8 +529,9 @@ ProcessPriorityManagerImpl::NotifyProcessPriorityChanged(
|
||||
ParticularProcessPriorityManager* aParticularManager,
|
||||
ProcessPriority aOldPriority)
|
||||
{
|
||||
// This priority change can only affect other processes' priorities if we're
|
||||
// changing to/from FOREGROUND_HIGH.
|
||||
/* We're interested only in changes to/from FOREGROUND_HIGH as we use we
|
||||
* need to track high priority processes so that we can react to their
|
||||
* presence. */
|
||||
|
||||
if (aOldPriority < PROCESS_PRIORITY_FOREGROUND_HIGH &&
|
||||
aParticularManager->CurrentPriority() <
|
||||
@ -607,17 +546,6 @@ ProcessPriorityManagerImpl::NotifyProcessPriorityChanged(
|
||||
} else {
|
||||
mHighPriorityChildIDs.RemoveEntry(aParticularManager->ChildID());
|
||||
}
|
||||
|
||||
nsTArray<nsRefPtr<ParticularProcessPriorityManager> > pppms;
|
||||
mParticularManagers.EnumerateRead(
|
||||
&EnumerateParticularProcessPriorityManagers,
|
||||
&pppms);
|
||||
|
||||
for (uint32_t i = 0; i < pppms.Length(); i++) {
|
||||
if (pppms[i] != aParticularManager) {
|
||||
pppms[i]->ResetCPUPriorityNow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* virtual */ void
|
||||
@ -633,10 +561,6 @@ ProcessPriorityManagerImpl::Notify(const WakeLockInformation& aInfo)
|
||||
mHighPriority = false;
|
||||
}
|
||||
|
||||
/* The main process got a high-priority wakelock change; reset everyone's
|
||||
* CPU priorities. */
|
||||
ResetAllCPUPriorities();
|
||||
|
||||
LOG("Got wake lock changed event. "
|
||||
"Now mHighPriorityParent = %d\n", mHighPriority);
|
||||
}
|
||||
@ -653,7 +577,6 @@ ParticularProcessPriorityManager::ParticularProcessPriorityManager(
|
||||
: mContentParent(aContentParent)
|
||||
, mChildID(aContentParent->ChildID())
|
||||
, mPriority(PROCESS_PRIORITY_UNKNOWN)
|
||||
, mCPUPriority(PROCESS_CPU_PRIORITY_NORMAL)
|
||||
, mHoldsCPUWakeLock(false)
|
||||
, mHoldsHighPriorityWakeLock(false)
|
||||
{
|
||||
@ -1015,40 +938,9 @@ ParticularProcessPriorityManager::ComputePriority()
|
||||
PROCESS_PRIORITY_BACKGROUND;
|
||||
}
|
||||
|
||||
ProcessCPUPriority
|
||||
ParticularProcessPriorityManager::ComputeCPUPriority(ProcessPriority aPriority)
|
||||
{
|
||||
if (aPriority == PROCESS_PRIORITY_PREALLOC) {
|
||||
return PROCESS_CPU_PRIORITY_LOW;
|
||||
}
|
||||
|
||||
if (aPriority >= PROCESS_PRIORITY_FOREGROUND_HIGH) {
|
||||
return PROCESS_CPU_PRIORITY_NORMAL;
|
||||
}
|
||||
|
||||
return ProcessPriorityManagerImpl::GetSingleton()->
|
||||
OtherProcessHasHighPriority(this) ?
|
||||
PROCESS_CPU_PRIORITY_LOW :
|
||||
PROCESS_CPU_PRIORITY_NORMAL;
|
||||
}
|
||||
|
||||
void
|
||||
ParticularProcessPriorityManager::ResetCPUPriorityNow()
|
||||
{
|
||||
SetPriorityNow(mPriority);
|
||||
}
|
||||
|
||||
void
|
||||
ParticularProcessPriorityManager::SetPriorityNow(ProcessPriority aPriority,
|
||||
uint32_t aBackgroundLRU)
|
||||
{
|
||||
SetPriorityNow(aPriority, ComputeCPUPriority(aPriority), aBackgroundLRU);
|
||||
}
|
||||
|
||||
void
|
||||
ParticularProcessPriorityManager::SetPriorityNow(ProcessPriority aPriority,
|
||||
ProcessCPUPriority aCPUPriority,
|
||||
uint32_t aBackgroundLRU)
|
||||
{
|
||||
if (aPriority == PROCESS_PRIORITY_UNKNOWN) {
|
||||
MOZ_ASSERT(false);
|
||||
@ -1058,11 +950,10 @@ ParticularProcessPriorityManager::SetPriorityNow(ProcessPriority aPriority,
|
||||
if (aBackgroundLRU > 0 &&
|
||||
aPriority == PROCESS_PRIORITY_BACKGROUND &&
|
||||
mPriority == PROCESS_PRIORITY_BACKGROUND) {
|
||||
hal::SetProcessPriority(Pid(), mPriority, mCPUPriority, aBackgroundLRU);
|
||||
hal::SetProcessPriority(Pid(), mPriority, aBackgroundLRU);
|
||||
|
||||
nsPrintfCString ProcessPriorityWithBackgroundLRU("%s:%d",
|
||||
ProcessPriorityToString(mPriority, mCPUPriority),
|
||||
aBackgroundLRU);
|
||||
ProcessPriorityToString(mPriority), aBackgroundLRU);
|
||||
|
||||
FireTestOnlyObserverNotification("process-priority-with-background-LRU-set",
|
||||
ProcessPriorityWithBackgroundLRU.get());
|
||||
@ -1070,7 +961,7 @@ ParticularProcessPriorityManager::SetPriorityNow(ProcessPriority aPriority,
|
||||
|
||||
if (!mContentParent ||
|
||||
!ProcessPriorityManagerImpl::PrefsEnabled() ||
|
||||
(mPriority == aPriority && mCPUPriority == aCPUPriority)) {
|
||||
(mPriority == aPriority)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1095,16 +986,18 @@ ParticularProcessPriorityManager::SetPriorityNow(ProcessPriority aPriority,
|
||||
}
|
||||
|
||||
LOGP("Changing priority from %s to %s.",
|
||||
ProcessPriorityToString(mPriority, mCPUPriority),
|
||||
ProcessPriorityToString(aPriority, aCPUPriority));
|
||||
ProcessPriorityToString(mPriority),
|
||||
ProcessPriorityToString(aPriority));
|
||||
|
||||
ProcessPriority oldPriority = mPriority;
|
||||
|
||||
mPriority = aPriority;
|
||||
mCPUPriority = aCPUPriority;
|
||||
hal::SetProcessPriority(Pid(), mPriority, mCPUPriority);
|
||||
hal::SetProcessPriority(Pid(), mPriority);
|
||||
|
||||
if (oldPriority != mPriority) {
|
||||
ProcessPriorityManagerImpl::GetSingleton()->
|
||||
NotifyProcessPriorityChanged(this, oldPriority);
|
||||
|
||||
unused << mContentParent->SendNotifyProcessPriorityChanged(mPriority);
|
||||
}
|
||||
|
||||
@ -1113,12 +1006,7 @@ ParticularProcessPriorityManager::SetPriorityNow(ProcessPriority aPriority,
|
||||
}
|
||||
|
||||
FireTestOnlyObserverNotification("process-priority-set",
|
||||
ProcessPriorityToString(mPriority, mCPUPriority));
|
||||
|
||||
if (oldPriority != mPriority) {
|
||||
ProcessPriorityManagerImpl::GetSingleton()->
|
||||
NotifyProcessPriorityChanged(this, oldPriority);
|
||||
}
|
||||
ProcessPriorityToString(mPriority));
|
||||
}
|
||||
|
||||
void
|
||||
|
87
hal/Hal.cpp
87
hal/Hal.cpp
@ -863,14 +863,12 @@ SetAlarm(int32_t aSeconds, int32_t aNanoseconds)
|
||||
void
|
||||
SetProcessPriority(int aPid,
|
||||
ProcessPriority aPriority,
|
||||
ProcessCPUPriority aCPUPriority,
|
||||
uint32_t aBackgroundLRU)
|
||||
{
|
||||
// n.b. The sandboxed implementation crashes; SetProcessPriority works only
|
||||
// from the main process.
|
||||
MOZ_ASSERT(aBackgroundLRU == 0 || aPriority == PROCESS_PRIORITY_BACKGROUND);
|
||||
PROXY_IF_SANDBOXED(SetProcessPriority(aPid, aPriority, aCPUPriority,
|
||||
aBackgroundLRU));
|
||||
PROXY_IF_SANDBOXED(SetProcessPriority(aPid, aPriority, aBackgroundLRU));
|
||||
}
|
||||
|
||||
void
|
||||
@ -920,89 +918,6 @@ ThreadPriorityToString(ThreadPriority aPriority)
|
||||
}
|
||||
}
|
||||
|
||||
// From HalTypes.h.
|
||||
const char*
|
||||
ProcessPriorityToString(ProcessPriority aPriority,
|
||||
ProcessCPUPriority aCPUPriority)
|
||||
{
|
||||
// Sorry this is ugly. At least it's all in one place.
|
||||
//
|
||||
// We intentionally fall through if aCPUPriority is invalid; we won't hit any
|
||||
// of the if statements further down, so it's OK.
|
||||
|
||||
switch (aPriority) {
|
||||
case PROCESS_PRIORITY_MASTER:
|
||||
if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) {
|
||||
return "MASTER:CPU_NORMAL";
|
||||
}
|
||||
if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) {
|
||||
return "MASTER:CPU_LOW";
|
||||
}
|
||||
case PROCESS_PRIORITY_PREALLOC:
|
||||
if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) {
|
||||
return "PREALLOC:CPU_NORMAL";
|
||||
}
|
||||
if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) {
|
||||
return "PREALLOC:CPU_LOW";
|
||||
}
|
||||
case PROCESS_PRIORITY_FOREGROUND_HIGH:
|
||||
if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) {
|
||||
return "FOREGROUND_HIGH:CPU_NORMAL";
|
||||
}
|
||||
if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) {
|
||||
return "FOREGROUND_HIGH:CPU_LOW";
|
||||
}
|
||||
case PROCESS_PRIORITY_FOREGROUND:
|
||||
if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) {
|
||||
return "FOREGROUND:CPU_NORMAL";
|
||||
}
|
||||
if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) {
|
||||
return "FOREGROUND:CPU_LOW";
|
||||
}
|
||||
case PROCESS_PRIORITY_FOREGROUND_KEYBOARD:
|
||||
if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) {
|
||||
return "FOREGROUND_KEYBOARD:CPU_NORMAL";
|
||||
}
|
||||
if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) {
|
||||
return "FOREGROUND_KEYBOARD:CPU_LOW";
|
||||
}
|
||||
case PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE:
|
||||
if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) {
|
||||
return "BACKGROUND_PERCEIVABLE:CPU_NORMAL";
|
||||
}
|
||||
if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) {
|
||||
return "BACKGROUND_PERCEIVABLE:CPU_LOW";
|
||||
}
|
||||
case PROCESS_PRIORITY_BACKGROUND_HOMESCREEN:
|
||||
if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) {
|
||||
return "BACKGROUND_HOMESCREEN:CPU_NORMAL";
|
||||
}
|
||||
if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) {
|
||||
return "BACKGROUND_HOMESCREEN:CPU_LOW";
|
||||
}
|
||||
case PROCESS_PRIORITY_BACKGROUND:
|
||||
if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) {
|
||||
return "BACKGROUND:CPU_NORMAL";
|
||||
}
|
||||
if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) {
|
||||
return "BACKGROUND:CPU_LOW";
|
||||
}
|
||||
case PROCESS_PRIORITY_UNKNOWN:
|
||||
if (aCPUPriority == PROCESS_CPU_PRIORITY_NORMAL) {
|
||||
return "UNKNOWN:CPU_NORMAL";
|
||||
}
|
||||
if (aCPUPriority == PROCESS_CPU_PRIORITY_LOW) {
|
||||
return "UNKNOWN:CPU_LOW";
|
||||
}
|
||||
default:
|
||||
// Fall through. (|default| is here to silence warnings.)
|
||||
break;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(false);
|
||||
return "???";
|
||||
}
|
||||
|
||||
static StaticAutoPtr<ObserverList<FMRadioOperationInformation> > sFMRadioObservers;
|
||||
static StaticAutoPtr<ObserverList<FMRadioRDSGroup> > sFMRadioRDSObservers;
|
||||
|
||||
|
@ -468,13 +468,7 @@ void NotifyAlarmFired();
|
||||
bool SetAlarm(int32_t aSeconds, int32_t aNanoseconds);
|
||||
|
||||
/**
|
||||
* Set the priority of the given process. A process's priority is a two-tuple
|
||||
* consisting of a hal::ProcessPriority value and a hal::ProcessCPUPriority
|
||||
* value.
|
||||
*
|
||||
* Two processes with the same ProcessCPUPriority value don't necessarily have
|
||||
* the same CPU priority; the CPU priority we assign to a process is a function
|
||||
* of its ProcessPriority and ProcessCPUPriority.
|
||||
* Set the priority of the given process.
|
||||
*
|
||||
* Exactly what this does will vary between platforms. On *nix we might give
|
||||
* background processes higher nice values. On other platforms, we might
|
||||
@ -482,7 +476,6 @@ bool SetAlarm(int32_t aSeconds, int32_t aNanoseconds);
|
||||
*/
|
||||
void SetProcessPriority(int aPid,
|
||||
hal::ProcessPriority aPriority,
|
||||
hal::ProcessCPUPriority aCPUPriority,
|
||||
uint32_t aLRU = 0);
|
||||
|
||||
|
||||
|
@ -73,12 +73,6 @@ enum ProcessPriority {
|
||||
NUM_PROCESS_PRIORITY
|
||||
};
|
||||
|
||||
enum ProcessCPUPriority {
|
||||
PROCESS_CPU_PRIORITY_LOW,
|
||||
PROCESS_CPU_PRIORITY_NORMAL,
|
||||
NUM_PROCESS_CPU_PRIORITY
|
||||
};
|
||||
|
||||
/**
|
||||
* Values that can be passed to hal::SetCurrentThreadPriority(). These should be
|
||||
* functional in nature, such as COMPOSITOR, instead of levels, like LOW/HIGH.
|
||||
@ -92,9 +86,8 @@ enum ThreadPriority {
|
||||
};
|
||||
|
||||
/**
|
||||
* Convert a ProcessPriority enum value (with an optional ProcessCPUPriority)
|
||||
* to a string. The strings returned by this function are statically
|
||||
* allocated; do not attempt to free one!
|
||||
* Convert a ProcessPriority enum value to a string. The strings returned by
|
||||
* this function are statically allocated; do not attempt to free one!
|
||||
*
|
||||
* If you pass an unknown process priority, we fatally assert in debug
|
||||
* builds and otherwise return "???".
|
||||
@ -102,10 +95,6 @@ enum ThreadPriority {
|
||||
const char*
|
||||
ProcessPriorityToString(ProcessPriority aPriority);
|
||||
|
||||
const char*
|
||||
ProcessPriorityToString(ProcessPriority aPriority,
|
||||
ProcessCPUPriority aCPUPriority);
|
||||
|
||||
/**
|
||||
* Convert a ThreadPriority enum value to a string. The strings returned by
|
||||
* this function are statically allocated; do not attempt to free one!
|
||||
|
@ -13,12 +13,10 @@ namespace hal_impl {
|
||||
void
|
||||
SetProcessPriority(int aPid,
|
||||
ProcessPriority aPriority,
|
||||
ProcessCPUPriority aCPUPriority,
|
||||
uint32_t aBackgroundLRU)
|
||||
{
|
||||
HAL_LOG("FallbackProcessPriority - SetProcessPriority(%d, %s, %u)\n",
|
||||
aPid, ProcessPriorityToString(aPriority, aCPUPriority),
|
||||
aBackgroundLRU);
|
||||
aPid, ProcessPriorityToString(aPriority), aBackgroundLRU);
|
||||
}
|
||||
|
||||
} // hal_impl
|
||||
|
@ -1738,11 +1738,10 @@ EnsureKernelLowMemKillerParamsSet()
|
||||
void
|
||||
SetProcessPriority(int aPid,
|
||||
ProcessPriority aPriority,
|
||||
ProcessCPUPriority aCPUPriority,
|
||||
uint32_t aBackgroundLRU)
|
||||
{
|
||||
HAL_LOG("SetProcessPriority(pid=%d, priority=%d, cpuPriority=%d, LRU=%u)",
|
||||
aPid, aPriority, aCPUPriority, aBackgroundLRU);
|
||||
HAL_LOG("SetProcessPriority(pid=%d, priority=%d, LRU=%u)",
|
||||
aPid, aPriority, aBackgroundLRU);
|
||||
|
||||
// If this is the first time SetProcessPriority was called, set the kernel's
|
||||
// OOM parameters according to our prefs.
|
||||
|
@ -357,7 +357,6 @@ SetAlarm(int32_t aSeconds, int32_t aNanoseconds)
|
||||
void
|
||||
SetProcessPriority(int aPid,
|
||||
ProcessPriority aPriority,
|
||||
ProcessCPUPriority aCPUPriority,
|
||||
uint32_t aBackgroundLRU)
|
||||
{
|
||||
NS_RUNTIMEABORT("Only the main process may set processes' priorities.");
|
||||
|
Loading…
Reference in New Issue
Block a user