hal/HalTypes.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef mozilla_hal_Types_h
michael@0 7 #define mozilla_hal_Types_h
michael@0 8
michael@0 9 #include "ipc/IPCMessageUtils.h"
michael@0 10 #include "mozilla/Observer.h"
michael@0 11
michael@0 12 namespace mozilla {
michael@0 13 namespace hal {
michael@0 14
michael@0 15 /**
michael@0 16 * These constants specify special values for content process IDs. You can get
michael@0 17 * a content process ID by calling ContentChild::GetID() or
michael@0 18 * ContentParent::GetChildID().
michael@0 19 */
michael@0 20 const uint64_t CONTENT_PROCESS_ID_UNKNOWN = uint64_t(-1);
michael@0 21 const uint64_t CONTENT_PROCESS_ID_MAIN = 0;
michael@0 22
michael@0 23 /**
michael@0 24 * These are defined by libhardware, specifically, hardware/libhardware/include/hardware/lights.h
michael@0 25 * in the gonk subsystem.
michael@0 26 * If these change and are exposed to JS, make sure nsIHal.idl is updated as well.
michael@0 27 */
michael@0 28 enum LightType {
michael@0 29 eHalLightID_Backlight = 0,
michael@0 30 eHalLightID_Keyboard = 1,
michael@0 31 eHalLightID_Buttons = 2,
michael@0 32 eHalLightID_Battery = 3,
michael@0 33 eHalLightID_Notifications = 4,
michael@0 34 eHalLightID_Attention = 5,
michael@0 35 eHalLightID_Bluetooth = 6,
michael@0 36 eHalLightID_Wifi = 7,
michael@0 37 eHalLightID_Count = 8 // This should stay at the end
michael@0 38 };
michael@0 39 enum LightMode {
michael@0 40 eHalLightMode_User = 0, // brightness is managed by user setting
michael@0 41 eHalLightMode_Sensor = 1, // brightness is managed by a light sensor
michael@0 42 eHalLightMode_Count
michael@0 43 };
michael@0 44 enum FlashMode {
michael@0 45 eHalLightFlash_None = 0,
michael@0 46 eHalLightFlash_Timed = 1, // timed flashing. Use flashOnMS and flashOffMS for timing
michael@0 47 eHalLightFlash_Hardware = 2, // hardware assisted flashing
michael@0 48 eHalLightFlash_Count
michael@0 49 };
michael@0 50
michael@0 51 enum ShutdownMode {
michael@0 52 eHalShutdownMode_Unknown = -1,
michael@0 53 eHalShutdownMode_PowerOff = 0,
michael@0 54 eHalShutdownMode_Reboot = 1,
michael@0 55 eHalShutdownMode_Restart = 2,
michael@0 56 eHalShutdownMode_Count = 3
michael@0 57 };
michael@0 58
michael@0 59 class SwitchEvent;
michael@0 60
michael@0 61 enum SwitchDevice {
michael@0 62 SWITCH_DEVICE_UNKNOWN = -1,
michael@0 63 SWITCH_HEADPHONES,
michael@0 64 SWITCH_USB,
michael@0 65 NUM_SWITCH_DEVICE
michael@0 66 };
michael@0 67
michael@0 68 enum SwitchState {
michael@0 69 SWITCH_STATE_UNKNOWN = -1,
michael@0 70 SWITCH_STATE_ON,
michael@0 71 SWITCH_STATE_OFF,
michael@0 72 SWITCH_STATE_HEADSET, // Headphone with microphone
michael@0 73 SWITCH_STATE_HEADPHONE, // without microphone
michael@0 74 NUM_SWITCH_STATE
michael@0 75 };
michael@0 76
michael@0 77 typedef Observer<SwitchEvent> SwitchObserver;
michael@0 78
michael@0 79 // Note that we rely on the order of this enum's entries. Higher priorities
michael@0 80 // should have larger int values.
michael@0 81 enum ProcessPriority {
michael@0 82 PROCESS_PRIORITY_UNKNOWN = -1,
michael@0 83 PROCESS_PRIORITY_BACKGROUND,
michael@0 84 PROCESS_PRIORITY_BACKGROUND_HOMESCREEN,
michael@0 85 PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE,
michael@0 86 PROCESS_PRIORITY_FOREGROUND_KEYBOARD,
michael@0 87 // The special class for the preallocated process, high memory priority but
michael@0 88 // low CPU priority.
michael@0 89 PROCESS_PRIORITY_PREALLOC,
michael@0 90 // Any priority greater than or equal to FOREGROUND is considered
michael@0 91 // "foreground" for the purposes of priority testing, for example
michael@0 92 // CurrentProcessIsForeground().
michael@0 93 PROCESS_PRIORITY_FOREGROUND,
michael@0 94 PROCESS_PRIORITY_FOREGROUND_HIGH,
michael@0 95 PROCESS_PRIORITY_MASTER,
michael@0 96 NUM_PROCESS_PRIORITY
michael@0 97 };
michael@0 98
michael@0 99 enum ProcessCPUPriority {
michael@0 100 PROCESS_CPU_PRIORITY_LOW,
michael@0 101 PROCESS_CPU_PRIORITY_NORMAL,
michael@0 102 NUM_PROCESS_CPU_PRIORITY
michael@0 103 };
michael@0 104
michael@0 105 // Convert a ProcessPriority enum value (with an optional ProcessCPUPriority)
michael@0 106 // to a string. The strings returned by this function are statically
michael@0 107 // allocated; do not attempt to free one!
michael@0 108 //
michael@0 109 // If you pass an unknown process priority (or NUM_PROCESS_PRIORITY), we
michael@0 110 // fatally assert in debug builds and otherwise return "???".
michael@0 111 const char*
michael@0 112 ProcessPriorityToString(ProcessPriority aPriority);
michael@0 113
michael@0 114 const char*
michael@0 115 ProcessPriorityToString(ProcessPriority aPriority,
michael@0 116 ProcessCPUPriority aCPUPriority);
michael@0 117
michael@0 118 /**
michael@0 119 * Used by ModifyWakeLock
michael@0 120 */
michael@0 121 enum WakeLockControl {
michael@0 122 WAKE_LOCK_REMOVE_ONE = -1,
michael@0 123 WAKE_LOCK_NO_CHANGE = 0,
michael@0 124 WAKE_LOCK_ADD_ONE = 1,
michael@0 125 NUM_WAKE_LOCK
michael@0 126 };
michael@0 127
michael@0 128 class FMRadioOperationInformation;
michael@0 129
michael@0 130 enum FMRadioOperation {
michael@0 131 FM_RADIO_OPERATION_UNKNOWN = -1,
michael@0 132 FM_RADIO_OPERATION_ENABLE,
michael@0 133 FM_RADIO_OPERATION_DISABLE,
michael@0 134 FM_RADIO_OPERATION_SEEK,
michael@0 135 FM_RADIO_OPERATION_TUNE,
michael@0 136 NUM_FM_RADIO_OPERATION
michael@0 137 };
michael@0 138
michael@0 139 enum FMRadioOperationStatus {
michael@0 140 FM_RADIO_OPERATION_STATUS_UNKNOWN = -1,
michael@0 141 FM_RADIO_OPERATION_STATUS_SUCCESS,
michael@0 142 FM_RADIO_OPERATION_STATUS_FAIL,
michael@0 143 NUM_FM_RADIO_OPERATION_STATUS
michael@0 144 };
michael@0 145
michael@0 146 enum FMRadioSeekDirection {
michael@0 147 FM_RADIO_SEEK_DIRECTION_UNKNOWN = -1,
michael@0 148 FM_RADIO_SEEK_DIRECTION_UP,
michael@0 149 FM_RADIO_SEEK_DIRECTION_DOWN,
michael@0 150 NUM_FM_RADIO_SEEK_DIRECTION
michael@0 151 };
michael@0 152
michael@0 153 enum FMRadioCountry {
michael@0 154 FM_RADIO_COUNTRY_UNKNOWN = -1,
michael@0 155 FM_RADIO_COUNTRY_US, //USA
michael@0 156 FM_RADIO_COUNTRY_EU,
michael@0 157 FM_RADIO_COUNTRY_JP_STANDARD,
michael@0 158 FM_RADIO_COUNTRY_JP_WIDE,
michael@0 159 FM_RADIO_COUNTRY_DE, //Germany
michael@0 160 FM_RADIO_COUNTRY_AW, //Aruba
michael@0 161 FM_RADIO_COUNTRY_AU, //Australlia
michael@0 162 FM_RADIO_COUNTRY_BS, //Bahamas
michael@0 163 FM_RADIO_COUNTRY_BD, //Bangladesh
michael@0 164 FM_RADIO_COUNTRY_CY, //Cyprus
michael@0 165 FM_RADIO_COUNTRY_VA, //Vatican
michael@0 166 FM_RADIO_COUNTRY_CO, //Colombia
michael@0 167 FM_RADIO_COUNTRY_KR, //Korea
michael@0 168 FM_RADIO_COUNTRY_DK, //Denmark
michael@0 169 FM_RADIO_COUNTRY_EC, //Ecuador
michael@0 170 FM_RADIO_COUNTRY_ES, //Spain
michael@0 171 FM_RADIO_COUNTRY_FI, //Finland
michael@0 172 FM_RADIO_COUNTRY_FR, //France
michael@0 173 FM_RADIO_COUNTRY_GM, //Gambia
michael@0 174 FM_RADIO_COUNTRY_HU, //Hungary
michael@0 175 FM_RADIO_COUNTRY_IN, //India
michael@0 176 FM_RADIO_COUNTRY_IR, //Iran
michael@0 177 FM_RADIO_COUNTRY_IT, //Italy
michael@0 178 FM_RADIO_COUNTRY_KW, //Kuwait
michael@0 179 FM_RADIO_COUNTRY_LT, //Lithuania
michael@0 180 FM_RADIO_COUNTRY_ML, //Mali
michael@0 181 FM_RADIO_COUNTRY_MA, //Morocco
michael@0 182 FM_RADIO_COUNTRY_NO, //Norway
michael@0 183 FM_RADIO_COUNTRY_NZ, //New Zealand
michael@0 184 FM_RADIO_COUNTRY_OM, //Oman
michael@0 185 FM_RADIO_COUNTRY_PG, //Papua New Guinea
michael@0 186 FM_RADIO_COUNTRY_NL, //Netherlands
michael@0 187 FM_RADIO_COUNTRY_QA, //Qatar
michael@0 188 FM_RADIO_COUNTRY_CZ, //Czech Republic
michael@0 189 FM_RADIO_COUNTRY_UK, //United Kingdom of Great Britain and Northern Ireland
michael@0 190 FM_RADIO_COUNTRY_RW, //Rwandese Republic
michael@0 191 FM_RADIO_COUNTRY_SN, //Senegal
michael@0 192 FM_RADIO_COUNTRY_SG, //Singapore
michael@0 193 FM_RADIO_COUNTRY_SI, //Slovenia
michael@0 194 FM_RADIO_COUNTRY_ZA, //South Africa
michael@0 195 FM_RADIO_COUNTRY_SE, //Sweden
michael@0 196 FM_RADIO_COUNTRY_CH, //Switzerland
michael@0 197 FM_RADIO_COUNTRY_TW, //Taiwan
michael@0 198 FM_RADIO_COUNTRY_TR, //Turkey
michael@0 199 FM_RADIO_COUNTRY_UA, //Ukraine
michael@0 200 FM_RADIO_COUNTRY_USER_DEFINED,
michael@0 201 NUM_FM_RADIO_COUNTRY
michael@0 202 };
michael@0 203
michael@0 204 typedef Observer<FMRadioOperationInformation> FMRadioObserver;
michael@0 205 } // namespace hal
michael@0 206 } // namespace mozilla
michael@0 207
michael@0 208 namespace IPC {
michael@0 209
michael@0 210 /**
michael@0 211 * Light type serializer.
michael@0 212 */
michael@0 213 template <>
michael@0 214 struct ParamTraits<mozilla::hal::LightType>
michael@0 215 : public ContiguousEnumSerializer<
michael@0 216 mozilla::hal::LightType,
michael@0 217 mozilla::hal::eHalLightID_Backlight,
michael@0 218 mozilla::hal::eHalLightID_Count>
michael@0 219 {};
michael@0 220
michael@0 221 /**
michael@0 222 * Light mode serializer.
michael@0 223 */
michael@0 224 template <>
michael@0 225 struct ParamTraits<mozilla::hal::LightMode>
michael@0 226 : public ContiguousEnumSerializer<
michael@0 227 mozilla::hal::LightMode,
michael@0 228 mozilla::hal::eHalLightMode_User,
michael@0 229 mozilla::hal::eHalLightMode_Count>
michael@0 230 {};
michael@0 231
michael@0 232 /**
michael@0 233 * Flash mode serializer.
michael@0 234 */
michael@0 235 template <>
michael@0 236 struct ParamTraits<mozilla::hal::FlashMode>
michael@0 237 : public ContiguousEnumSerializer<
michael@0 238 mozilla::hal::FlashMode,
michael@0 239 mozilla::hal::eHalLightFlash_None,
michael@0 240 mozilla::hal::eHalLightFlash_Count>
michael@0 241 {};
michael@0 242
michael@0 243 /**
michael@0 244 * Serializer for ShutdownMode.
michael@0 245 */
michael@0 246 template <>
michael@0 247 struct ParamTraits<mozilla::hal::ShutdownMode>
michael@0 248 : public ContiguousEnumSerializer<
michael@0 249 mozilla::hal::ShutdownMode,
michael@0 250 mozilla::hal::eHalShutdownMode_Unknown,
michael@0 251 mozilla::hal::eHalShutdownMode_Count>
michael@0 252 {};
michael@0 253
michael@0 254 /**
michael@0 255 * WakeLockControl serializer.
michael@0 256 */
michael@0 257 template <>
michael@0 258 struct ParamTraits<mozilla::hal::WakeLockControl>
michael@0 259 : public ContiguousEnumSerializer<
michael@0 260 mozilla::hal::WakeLockControl,
michael@0 261 mozilla::hal::WAKE_LOCK_REMOVE_ONE,
michael@0 262 mozilla::hal::NUM_WAKE_LOCK>
michael@0 263 {};
michael@0 264
michael@0 265 /**
michael@0 266 * Serializer for SwitchState
michael@0 267 */
michael@0 268 template <>
michael@0 269 struct ParamTraits<mozilla::hal::SwitchState>:
michael@0 270 public ContiguousEnumSerializer<
michael@0 271 mozilla::hal::SwitchState,
michael@0 272 mozilla::hal::SWITCH_STATE_UNKNOWN,
michael@0 273 mozilla::hal::NUM_SWITCH_STATE> {
michael@0 274 };
michael@0 275
michael@0 276 /**
michael@0 277 * Serializer for SwitchDevice
michael@0 278 */
michael@0 279 template <>
michael@0 280 struct ParamTraits<mozilla::hal::SwitchDevice>:
michael@0 281 public ContiguousEnumSerializer<
michael@0 282 mozilla::hal::SwitchDevice,
michael@0 283 mozilla::hal::SWITCH_DEVICE_UNKNOWN,
michael@0 284 mozilla::hal::NUM_SWITCH_DEVICE> {
michael@0 285 };
michael@0 286
michael@0 287 template <>
michael@0 288 struct ParamTraits<mozilla::hal::ProcessPriority>:
michael@0 289 public ContiguousEnumSerializer<
michael@0 290 mozilla::hal::ProcessPriority,
michael@0 291 mozilla::hal::PROCESS_PRIORITY_UNKNOWN,
michael@0 292 mozilla::hal::NUM_PROCESS_PRIORITY> {
michael@0 293 };
michael@0 294
michael@0 295 /**
michael@0 296 * Serializer for FMRadioOperation
michael@0 297 */
michael@0 298 template <>
michael@0 299 struct ParamTraits<mozilla::hal::FMRadioOperation>:
michael@0 300 public ContiguousEnumSerializer<
michael@0 301 mozilla::hal::FMRadioOperation,
michael@0 302 mozilla::hal::FM_RADIO_OPERATION_UNKNOWN,
michael@0 303 mozilla::hal::NUM_FM_RADIO_OPERATION>
michael@0 304 {};
michael@0 305
michael@0 306 /**
michael@0 307 * Serializer for FMRadioOperationStatus
michael@0 308 */
michael@0 309 template <>
michael@0 310 struct ParamTraits<mozilla::hal::FMRadioOperationStatus>:
michael@0 311 public ContiguousEnumSerializer<
michael@0 312 mozilla::hal::FMRadioOperationStatus,
michael@0 313 mozilla::hal::FM_RADIO_OPERATION_STATUS_UNKNOWN,
michael@0 314 mozilla::hal::NUM_FM_RADIO_OPERATION_STATUS>
michael@0 315 {};
michael@0 316
michael@0 317 /**
michael@0 318 * Serializer for FMRadioSeekDirection
michael@0 319 */
michael@0 320 template <>
michael@0 321 struct ParamTraits<mozilla::hal::FMRadioSeekDirection>:
michael@0 322 public ContiguousEnumSerializer<
michael@0 323 mozilla::hal::FMRadioSeekDirection,
michael@0 324 mozilla::hal::FM_RADIO_SEEK_DIRECTION_UNKNOWN,
michael@0 325 mozilla::hal::NUM_FM_RADIO_SEEK_DIRECTION>
michael@0 326 {};
michael@0 327
michael@0 328 /**
michael@0 329 * Serializer for FMRadioCountry
michael@0 330 **/
michael@0 331 template <>
michael@0 332 struct ParamTraits<mozilla::hal::FMRadioCountry>:
michael@0 333 public ContiguousEnumSerializer<
michael@0 334 mozilla::hal::FMRadioCountry,
michael@0 335 mozilla::hal::FM_RADIO_COUNTRY_UNKNOWN,
michael@0 336 mozilla::hal::NUM_FM_RADIO_COUNTRY>
michael@0 337 {};
michael@0 338
michael@0 339 } // namespace IPC
michael@0 340
michael@0 341 #endif // mozilla_hal_Types_h

mercurial