Bug 1758804 [wpt PR 33140] - Move hint to the provider dictionary, a=testonly
[gecko.git] / hal / windows / WindowsProcessPriority.cpp
blobc872416502ef7fdc10b40c521980ddc8b4b69989
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "Hal.h"
6 #include "HalLog.h"
8 #include <windows.h>
10 using namespace mozilla::hal;
12 namespace mozilla {
13 namespace hal_impl {
15 void SetProcessPriority(int aPid, ProcessPriority aPriority) {
16 HAL_LOG("WindowsProcessPriority - SetProcessPriority(%d, %s)\n", aPid,
17 ProcessPriorityToString(aPriority));
19 nsAutoHandle processHandle(
20 ::OpenProcess(PROCESS_SET_INFORMATION, FALSE, aPid));
21 if (processHandle) {
22 DWORD priority = NORMAL_PRIORITY_CLASS;
23 if (aPriority == PROCESS_PRIORITY_BACKGROUND) {
24 priority = IDLE_PRIORITY_CLASS;
25 } else if (aPriority == PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE) {
26 priority = BELOW_NORMAL_PRIORITY_CLASS;
29 if (::SetPriorityClass(processHandle, priority)) {
30 HAL_LOG("WindowsProcessPriority - priority set to %d for pid %d\n",
31 aPriority, aPid);
36 } // namespace hal_impl
37 } // namespace mozilla