Source code

Revision control

Other Tools

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/. */
5
6
#ifndef mozilla_hal_Types_h
7
#define mozilla_hal_Types_h
8
9
#include "ipc/IPCMessageUtils.h"
10
#include "mozilla/Observer.h"
11
12
namespace mozilla {
13
namespace hal {
14
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().
19
*/
20
const uint64_t CONTENT_PROCESS_ID_UNKNOWN = uint64_t(-1);
21
const uint64_t CONTENT_PROCESS_ID_MAIN = 0;
22
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
40
};
41
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!
45
*
46
* If you pass an unknown process priority, we fatally assert in debug
47
* builds and otherwise return "???".
48
*/
49
const char* ProcessPriorityToString(ProcessPriority aPriority);
50
51
/**
52
* Used by ModifyWakeLock
53
*/
54
enum WakeLockControl {
55
WAKE_LOCK_REMOVE_ONE = -1,
56
WAKE_LOCK_NO_CHANGE = 0,
57
WAKE_LOCK_ADD_ONE = 1,
58
NUM_WAKE_LOCK
59
};
60
61
} // namespace hal
62
} // namespace mozilla
63
64
namespace IPC {
65
66
/**
67
* WakeLockControl serializer.
68
*/
69
template <>
70
struct ParamTraits<mozilla::hal::WakeLockControl>
71
: public ContiguousEnumSerializer<mozilla::hal::WakeLockControl,
72
mozilla::hal::WAKE_LOCK_REMOVE_ONE,
73
mozilla::hal::NUM_WAKE_LOCK> {};
74
75
template <>
76
struct ParamTraits<mozilla::hal::ProcessPriority>
77
: public ContiguousEnumSerializer<mozilla::hal::ProcessPriority,
78
mozilla::hal::PROCESS_PRIORITY_UNKNOWN,
79
mozilla::hal::NUM_PROCESS_PRIORITY> {};
80
81
} // namespace IPC
82
83
#endif // mozilla_hal_Types_h