OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef WebSyncRegistration_h | 5 #ifndef WebSyncRegistration_h |
6 #define WebSyncRegistration_h | 6 #define WebSyncRegistration_h |
7 | 7 |
8 #include "public/platform/WebPrivatePtr.h" | 8 #include "public/platform/WebPrivatePtr.h" |
9 #include "public/platform/WebString.h" | 9 #include "public/platform/WebString.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 struct WebSyncRegistration { | 13 struct WebSyncRegistration { |
14 enum NetworkType { | 14 enum NetworkState { |
15 NetworkTypeAny = 0, | 15 NetworkStateAny = 0, |
16 NetworkTypeOffline, | 16 NetworkStateAvoidCellular, |
17 NetworkTypeOnline, | 17 NetworkStateOnline, |
18 NetworkTypeNonMobile, | 18 NetworkStateLast = NetworkStateOnline |
19 NetworkTypeLast = NetworkTypeNonMobile | 19 }; |
| 20 |
| 21 enum PowerState { |
| 22 PowerStateAuto = 0, |
| 23 PowerStateAvoidDraining, |
| 24 PowerStateLast = PowerStateAvoidDraining |
| 25 }; |
| 26 |
| 27 enum { UNREGISTERED_SYNC_ID = -1}; |
| 28 |
| 29 enum Periodicity { |
| 30 PeriodicityPeriodic = 0, |
| 31 PeriodicityOneShot, |
| 32 PeriodicityLast = PeriodicityOneShot |
20 }; | 33 }; |
21 | 34 |
22 WebSyncRegistration() | 35 WebSyncRegistration() |
23 : id("") | 36 : id(UNREGISTERED_SYNC_ID) |
24 , minDelayMs(0) | 37 , periodicity(PeriodicityOneShot) |
25 , maxDelayMs(0) | 38 , tag("") |
26 , minPeriodMs(0) | 39 , minPeriodMs(0) |
27 , minRequiredNetwork(NetworkType::NetworkTypeAny) | 40 , networkState(NetworkState::NetworkStateOnline) |
28 , allowOnBattery(true) | 41 , powerState(PowerState::PowerStateAuto) |
29 , idleRequired(false) | |
30 { | 42 { |
31 } | 43 } |
32 | 44 |
33 WebSyncRegistration(const WebString& registrationId, unsigned long minDelayM
s, | 45 WebSyncRegistration(int64_t id, Periodicity periodicity, |
34 unsigned long maxDelayMs, unsigned long minPeriodMs, NetworkType minRequ
iredNetwork, | 46 const WebString& registrationTag, unsigned long minPeriodMs, |
35 bool allowOnBattery, bool idleRequired) | 47 NetworkState networkState, PowerState powerState) |
36 : id(registrationId) | 48 : id(id) |
37 , minDelayMs(minDelayMs) | 49 , periodicity(periodicity) |
38 , maxDelayMs(maxDelayMs) | 50 , tag(registrationTag) |
39 , minPeriodMs(minPeriodMs) | 51 , minPeriodMs(minPeriodMs) |
40 , minRequiredNetwork(minRequiredNetwork) | 52 , networkState(networkState) |
41 , allowOnBattery(allowOnBattery) | 53 , powerState(powerState) |
42 , idleRequired(idleRequired) | |
43 { | 54 { |
44 } | 55 } |
45 | 56 |
46 WebString id; | 57 /* Internal identity; not exposed to JS API. */ |
| 58 int64_t id; |
47 | 59 |
48 /* Minimum delay before sync event (or first sync event, if periodic,) in | 60 /* Internal flag; not directly exposed to JS API. |
49 * milliseconds. */ | 61 * Instead, this determines whether this object is represented in JS as a |
50 unsigned long minDelayMs; | 62 * SyncRegistration or a PeriodicSyncRegistration. |
| 63 */ |
| 64 Periodicity periodicity; |
51 | 65 |
52 /* Maximum delay before sync event (or first sync event, if periodic,) in | 66 WebString tag; |
53 * milliseconds. 0 means no maximum delay. If this value is greater than 0, | |
54 * then it should not be less than minDelayMs for the registration to be | |
55 * meaningful. | |
56 */ | |
57 unsigned long maxDelayMs; | |
58 | 67 |
59 /* Minimum time between periodic sync events, in milliseconds. A 0 value | 68 /* Minimum time between periodic sync events, in milliseconds. A 0 value |
60 * here means that the event is a one-shot (not periodic.) | 69 * here means that the event is a one-shot (not periodic.) |
61 */ | 70 */ |
62 unsigned long minPeriodMs; | 71 unsigned long minPeriodMs; |
63 | 72 |
64 NetworkType minRequiredNetwork; | 73 NetworkState networkState; |
65 bool allowOnBattery; | 74 PowerState powerState; |
66 bool idleRequired; | |
67 }; | 75 }; |
68 | 76 |
69 } // namespace blink | 77 } // namespace blink |
70 | 78 |
71 #endif // WebSyncRegistration_h | 79 #endif // WebSyncRegistration_h |
OLD | NEW |