Bug 1849470 - Update in-tree zlib to version 1.3. r=aosmond
[gecko.git] / hal / HalTypes.h
blob47b2be0e263d61f310c9f42833d4261f1d5d9ebe
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/EnumSerializer.h"
10 #include "mozilla/Observer.h"
11 #include "mozilla/TimeStamp.h"
12 #include "mozilla/UniquePtr.h"
14 namespace mozilla {
15 namespace hal {
17 /**
18 * These constants specify special values for content process IDs. You can get
19 * a content process ID by calling ContentChild::GetID() or
20 * ContentParent::GetChildID().
22 const uint64_t CONTENT_PROCESS_ID_UNKNOWN = uint64_t(-1);
23 const uint64_t CONTENT_PROCESS_ID_MAIN = 0;
25 // Note that we rely on the order of this enum's entries. Higher priorities
26 // should have larger int values.
27 enum ProcessPriority {
28 PROCESS_PRIORITY_UNKNOWN = -1,
29 PROCESS_PRIORITY_BACKGROUND,
30 PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE,
31 PROCESS_PRIORITY_FOREGROUND_KEYBOARD,
32 // The special class for the preallocated process, high memory priority but
33 // low CPU priority.
34 PROCESS_PRIORITY_PREALLOC,
35 // Any priority greater than or equal to FOREGROUND is considered
36 // "foreground" for the purposes of priority testing, for example
37 // CurrentProcessIsForeground().
38 PROCESS_PRIORITY_FOREGROUND,
39 PROCESS_PRIORITY_FOREGROUND_HIGH,
40 PROCESS_PRIORITY_PARENT_PROCESS,
41 NUM_PROCESS_PRIORITY
44 /**
45 * Convert a ProcessPriority enum value to a string. The strings returned by
46 * this function are statically allocated; do not attempt to free one!
48 * If you pass an unknown process priority, we fatally assert in debug
49 * builds and otherwise return "???".
51 const char* ProcessPriorityToString(ProcessPriority aPriority);
53 /**
54 * Used by ModifyWakeLock
56 enum WakeLockControl {
57 WAKE_LOCK_REMOVE_ONE = -1,
58 WAKE_LOCK_NO_CHANGE = 0,
59 WAKE_LOCK_ADD_ONE = 1,
60 NUM_WAKE_LOCK
63 /**
64 * Represents a workload shared by a group of threads that should be completed
65 * in a target duration each cycle.
67 * This is created using hal::CreatePerformanceHintSession(). Each cycle, the
68 * actual work duration should be reported using ReportActualWorkDuration(). The
69 * system can then adjust the scheduling accordingly in order to achieve the
70 * target.
72 class PerformanceHintSession {
73 public:
74 virtual ~PerformanceHintSession() = default;
76 // Updates the session's target work duration for each cycle.
77 virtual void UpdateTargetWorkDuration(TimeDuration aDuration) = 0;
79 // Reports the session's actual work duration for a cycle.
80 virtual void ReportActualWorkDuration(TimeDuration aDuration) = 0;
83 } // namespace hal
84 } // namespace mozilla
86 namespace IPC {
88 /**
89 * WakeLockControl serializer.
91 template <>
92 struct ParamTraits<mozilla::hal::WakeLockControl>
93 : public ContiguousEnumSerializer<mozilla::hal::WakeLockControl,
94 mozilla::hal::WAKE_LOCK_REMOVE_ONE,
95 mozilla::hal::NUM_WAKE_LOCK> {};
97 template <>
98 struct ParamTraits<mozilla::hal::ProcessPriority>
99 : public ContiguousEnumSerializer<mozilla::hal::ProcessPriority,
100 mozilla::hal::PROCESS_PRIORITY_UNKNOWN,
101 mozilla::hal::NUM_PROCESS_PRIORITY> {};
103 } // namespace IPC
105 #endif // mozilla_hal_Types_h