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/BitSet.h"
11 #include "mozilla/Observer.h"
12 #include "mozilla/TimeStamp.h"
13 #include "mozilla/UniquePtr.h"
19 * These constants specify special values for content process IDs. You can get
20 * a content process ID by calling ContentChild::GetID() or
21 * ContentParent::GetChildID().
23 const uint64_t CONTENT_PROCESS_ID_UNKNOWN
= uint64_t(-1);
24 const uint64_t CONTENT_PROCESS_ID_MAIN
= 0;
26 // Note that we rely on the order of this enum's entries. Higher priorities
27 // should have larger int values.
28 enum ProcessPriority
{
29 PROCESS_PRIORITY_UNKNOWN
= -1,
30 PROCESS_PRIORITY_BACKGROUND
,
31 PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE
,
32 PROCESS_PRIORITY_FOREGROUND_KEYBOARD
,
33 // The special class for the preallocated process, high memory priority but
35 PROCESS_PRIORITY_PREALLOC
,
36 // Any priority greater than or equal to FOREGROUND is considered
37 // "foreground" for the purposes of priority testing, for example
38 // CurrentProcessIsForeground().
39 PROCESS_PRIORITY_FOREGROUND
,
40 PROCESS_PRIORITY_FOREGROUND_HIGH
,
41 PROCESS_PRIORITY_PARENT_PROCESS
,
46 * Convert a ProcessPriority enum value to a string. The strings returned by
47 * this function are statically allocated; do not attempt to free one!
49 * If you pass an unknown process priority, we fatally assert in debug
50 * builds and otherwise return "???".
52 const char* ProcessPriorityToString(ProcessPriority aPriority
);
55 * Used by ModifyWakeLock
57 enum WakeLockControl
{
58 WAKE_LOCK_REMOVE_ONE
= -1,
59 WAKE_LOCK_NO_CHANGE
= 0,
60 WAKE_LOCK_ADD_ONE
= 1,
65 * Represents a workload shared by a group of threads that should be completed
66 * in a target duration each cycle.
68 * This is created using hal::CreatePerformanceHintSession(). Each cycle, the
69 * actual work duration should be reported using ReportActualWorkDuration(). The
70 * system can then adjust the scheduling accordingly in order to achieve the
73 class PerformanceHintSession
{
75 virtual ~PerformanceHintSession() = default;
77 // Updates the session's target work duration for each cycle.
78 virtual void UpdateTargetWorkDuration(TimeDuration aDuration
) = 0;
80 // Reports the session's actual work duration for a cycle.
81 virtual void ReportActualWorkDuration(TimeDuration aDuration
) = 0;
85 * Categorizes the CPUs on the system in to big, medium, and little classes.
87 * A set bit in each bitset indicates that the CPU of that index belongs to that
88 * class. If the CPUs are fully homogeneous they are all categorized as big. If
89 * there are only 2 classes, they are categorized as either big or little.
90 * Finally, if there are >= 3 classes, the remainder will be categorized as
93 * If there are more than MAX_CPUS present we are unable to represent this
96 struct HeterogeneousCpuInfo
{
97 // We use a max of 32 because this was initially implemented only for Android
98 // where we are unlikely to need more CPUs than that, and it simplifies
99 // dealing with cpu_set_t as CPU_SETSIZE is 32 on 32-bit Android.
100 // If there are more than 32 CPU cores, the implementation should try to fill
101 // first mBigCpus before adding anything to mMediumCpus or mLittleCpus.
102 static const size_t MAX_CPUS
= 32;
103 size_t mTotalNumCpus
;
104 mozilla::BitSet
<MAX_CPUS
> mLittleCpus
;
105 mozilla::BitSet
<MAX_CPUS
> mMediumCpus
;
106 mozilla::BitSet
<MAX_CPUS
> mBigCpus
;
110 } // namespace mozilla
115 * WakeLockControl serializer.
118 struct ParamTraits
<mozilla::hal::WakeLockControl
>
119 : public ContiguousEnumSerializer
<mozilla::hal::WakeLockControl
,
120 mozilla::hal::WAKE_LOCK_REMOVE_ONE
,
121 mozilla::hal::NUM_WAKE_LOCK
> {};
124 struct ParamTraits
<mozilla::hal::ProcessPriority
>
125 : public ContiguousEnumSerializer
<mozilla::hal::ProcessPriority
,
126 mozilla::hal::PROCESS_PRIORITY_UNKNOWN
,
127 mozilla::hal::NUM_PROCESS_PRIORITY
> {};
131 #endif // mozilla_hal_Types_h