Bug 1467572 - Part 10: Reuse the network throttling menu in the network monitor in...
[gecko.git] / hal / HalTypes.h
blobec602fe39f6f0376e107b3a9be1c2ac451e478a9
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_hal_Types_h
7 #define mozilla_hal_Types_h
9 #include "ipc/IPCMessageUtils.h"
10 #include "mozilla/Observer.h"
12 namespace mozilla {
13 namespace hal {
15 /**
16 * These constants specify special values for content process IDs. You can get
17 * a content process ID by calling ContentChild::GetID() or
18 * ContentParent::GetChildID().
20 const uint64_t CONTENT_PROCESS_ID_UNKNOWN = uint64_t(-1);
21 const uint64_t CONTENT_PROCESS_ID_MAIN = 0;
23 // Note that we rely on the order of this enum's entries. Higher priorities
24 // should have larger int values.
25 enum ProcessPriority {
26 PROCESS_PRIORITY_UNKNOWN = -1,
27 PROCESS_PRIORITY_BACKGROUND,
28 PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE,
29 PROCESS_PRIORITY_FOREGROUND_KEYBOARD,
30 // The special class for the preallocated process, high memory priority but
31 // low CPU priority.
32 PROCESS_PRIORITY_PREALLOC,
33 // Any priority greater than or equal to FOREGROUND is considered
34 // "foreground" for the purposes of priority testing, for example
35 // CurrentProcessIsForeground().
36 PROCESS_PRIORITY_FOREGROUND,
37 PROCESS_PRIORITY_FOREGROUND_HIGH,
38 PROCESS_PRIORITY_MASTER,
39 NUM_PROCESS_PRIORITY
42 /**
43 * Convert a ProcessPriority enum value to a string. The strings returned by
44 * this function are statically allocated; do not attempt to free one!
46 * If you pass an unknown process priority, we fatally assert in debug
47 * builds and otherwise return "???".
49 const char*
50 ProcessPriorityToString(ProcessPriority aPriority);
52 /**
53 * Used by ModifyWakeLock
55 enum WakeLockControl {
56 WAKE_LOCK_REMOVE_ONE = -1,
57 WAKE_LOCK_NO_CHANGE = 0,
58 WAKE_LOCK_ADD_ONE = 1,
59 NUM_WAKE_LOCK
62 } // namespace hal
63 } // namespace mozilla
65 namespace IPC {
67 /**
68 * WakeLockControl serializer.
70 template <>
71 struct ParamTraits<mozilla::hal::WakeLockControl>
72 : public ContiguousEnumSerializer<
73 mozilla::hal::WakeLockControl,
74 mozilla::hal::WAKE_LOCK_REMOVE_ONE,
75 mozilla::hal::NUM_WAKE_LOCK>
76 {};
78 template <>
79 struct ParamTraits<mozilla::hal::ProcessPriority>:
80 public ContiguousEnumSerializer<
81 mozilla::hal::ProcessPriority,
82 mozilla::hal::PROCESS_PRIORITY_UNKNOWN,
83 mozilla::hal::NUM_PROCESS_PRIORITY> {
87 } // namespace IPC
89 #endif // mozilla_hal_Types_h