зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1394710 - Set process priority class on Windows r=aklotz
Fairly straightforward. Using an idle priority class for background, which mirrors what I am observing of Chromium in Process Explorer. MozReview-Commit-ID: 2mimYN7aJOy --HG-- extra : rebase_source : 18d992209178fc1f08d281920976881159af8f19
This commit is contained in:
Родитель
cf9a56e726
Коммит
869e854d3c
|
@ -38,6 +38,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
|
|||
]
|
||||
UNIFIED_SOURCES += [
|
||||
'android/AndroidSensor.cpp',
|
||||
'fallback/FallbackProcessPriority.cpp',
|
||||
]
|
||||
# AndroidHal.cpp cannot be built in unified mode because it relies on HalImpl.h.
|
||||
SOURCES += [
|
||||
|
@ -48,6 +49,7 @@ elif CONFIG['OS_TARGET'] == 'Linux':
|
|||
'fallback/FallbackScreenConfiguration.cpp',
|
||||
'fallback/FallbackSensor.cpp',
|
||||
'fallback/FallbackVibration.cpp',
|
||||
'fallback/FallbackProcessPriority.cpp',
|
||||
]
|
||||
if CONFIG['MOZ_ENABLE_DBUS']:
|
||||
UNIFIED_SOURCES += [
|
||||
|
@ -61,6 +63,7 @@ elif CONFIG['OS_TARGET'] == 'WINNT':
|
|||
UNIFIED_SOURCES += [
|
||||
'fallback/FallbackScreenConfiguration.cpp',
|
||||
'fallback/FallbackVibration.cpp',
|
||||
'windows/WindowsProcessPriority.cpp',
|
||||
'windows/WindowsSensor.cpp',
|
||||
]
|
||||
# WindowsBattery.cpp cannot be built in unified mode because it relies on HalImpl.h.
|
||||
|
@ -72,12 +75,14 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
|
|||
'cocoa/CocoaBattery.cpp',
|
||||
'fallback/FallbackScreenConfiguration.cpp',
|
||||
'fallback/FallbackVibration.cpp',
|
||||
'fallback/FallbackProcessPriority.cpp',
|
||||
]
|
||||
elif CONFIG['OS_TARGET'] in ('OpenBSD', 'NetBSD', 'FreeBSD', 'DragonFly'):
|
||||
UNIFIED_SOURCES += [
|
||||
'fallback/FallbackScreenConfiguration.cpp',
|
||||
'fallback/FallbackSensor.cpp',
|
||||
'fallback/FallbackVibration.cpp',
|
||||
'fallback/FallbackProcessPriority.cpp',
|
||||
]
|
||||
if CONFIG['MOZ_ENABLE_DBUS']:
|
||||
UNIFIED_SOURCES += [
|
||||
|
@ -93,12 +98,12 @@ else:
|
|||
'fallback/FallbackScreenConfiguration.cpp',
|
||||
'fallback/FallbackSensor.cpp',
|
||||
'fallback/FallbackVibration.cpp',
|
||||
'fallback/FallbackProcessPriority.cpp',
|
||||
]
|
||||
|
||||
# Fallbacks for backends no longer implemented.
|
||||
UNIFIED_SOURCES += [
|
||||
'fallback/FallbackDiskSpaceWatcher.cpp',
|
||||
'fallback/FallbackProcessPriority.cpp',
|
||||
]
|
||||
|
||||
# Fallbacks for backends implemented on Android only.
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "Hal.h"
|
||||
#include "HalLog.h"
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
using namespace mozilla::hal;
|
||||
|
||||
namespace mozilla {
|
||||
namespace hal_impl {
|
||||
|
||||
bool
|
||||
SetProcessPrioritySupported()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
SetProcessPriority(int aPid, ProcessPriority aPriority)
|
||||
{
|
||||
HAL_LOG("WindowsProcessPriority - SetProcessPriority(%d, %s)\n",
|
||||
aPid, ProcessPriorityToString(aPriority));
|
||||
|
||||
HANDLE hProcess = ::OpenProcess(PROCESS_SET_INFORMATION, false, aPid);
|
||||
if (hProcess) {
|
||||
DWORD priority = NORMAL_PRIORITY_CLASS;
|
||||
if (aPriority == PROCESS_PRIORITY_BACKGROUND ||
|
||||
aPriority == PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE) {
|
||||
priority = IDLE_PRIORITY_CLASS;
|
||||
}
|
||||
::SetPriorityClass(hProcess, priority);
|
||||
::CloseHandle(hProcess);
|
||||
}
|
||||
|
||||
HAL_LOG("WindowsProcessPriority - priority set to %d for pid %d\n",
|
||||
aPriority, aPid);
|
||||
}
|
||||
|
||||
} // namespace hal_impl
|
||||
} // namespace mozilla
|
Загрузка…
Ссылка в новой задаче