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 NetworkState { | 14 enum NetworkState { |
15 NetworkStateAny = 0, | 15 NetworkStateAny = 0, |
16 NetworkStateAvoidCellular, | 16 NetworkStateAvoidCellular, |
17 NetworkStateOnline, | 17 NetworkStateOnline, |
18 NetworkStateLast = NetworkStateOnline | 18 NetworkStateLast = NetworkStateOnline |
19 }; | 19 }; |
20 | 20 |
21 enum PowerState { | |
22 PowerStateAuto = 0, | |
23 PowerStateAvoidDraining, | |
24 PowerStateLast = PowerStateAvoidDraining | |
25 }; | |
26 | |
27 enum { UNREGISTERED_SYNC_ID = -1}; | 21 enum { UNREGISTERED_SYNC_ID = -1}; |
28 | 22 |
29 enum Periodicity { | 23 enum Periodicity { |
30 PeriodicityPeriodic = 0, | 24 PeriodicityPeriodic = 0, |
31 PeriodicityOneShot, | 25 PeriodicityOneShot, |
32 PeriodicityLast = PeriodicityOneShot | 26 PeriodicityLast = PeriodicityOneShot |
33 }; | 27 }; |
34 | 28 |
35 WebSyncRegistration() | 29 WebSyncRegistration() |
36 : id(UNREGISTERED_SYNC_ID) | 30 : id(UNREGISTERED_SYNC_ID) |
37 , periodicity(PeriodicityOneShot) | 31 , periodicity(PeriodicityOneShot) |
38 , tag("") | 32 , tag("") |
39 , minPeriodMs(0) | 33 , minPeriodMs(0) |
40 , networkState(NetworkState::NetworkStateOnline) | 34 , networkState(NetworkState::NetworkStateOnline) |
41 , powerState(PowerState::PowerStateAuto) | |
42 { | 35 { |
43 } | 36 } |
44 | 37 |
45 WebSyncRegistration(int64_t id, Periodicity periodicity, | 38 WebSyncRegistration(int64_t id, Periodicity periodicity, |
46 const WebString& registrationTag, unsigned long minPeriodMs, | 39 const WebString& registrationTag, unsigned long minPeriodMs, |
47 NetworkState networkState, PowerState powerState) | 40 NetworkState networkState) |
48 : id(id) | 41 : id(id) |
49 , periodicity(periodicity) | 42 , periodicity(periodicity) |
50 , tag(registrationTag) | 43 , tag(registrationTag) |
51 , minPeriodMs(minPeriodMs) | 44 , minPeriodMs(minPeriodMs) |
52 , networkState(networkState) | 45 , networkState(networkState) |
53 , powerState(powerState) | |
54 { | 46 { |
55 } | 47 } |
56 | 48 |
57 /* Internal identity; not exposed to JS API. */ | 49 /* Internal identity; not exposed to JS API. */ |
58 int64_t id; | 50 int64_t id; |
59 | 51 |
60 /* Internal flag; not directly exposed to JS API. | 52 /* Internal flag; not directly exposed to JS API. |
61 * Instead, this determines whether this object is represented in JS as a | 53 * Instead, this determines whether this object is represented in JS as a |
62 * SyncRegistration or a PeriodicSyncRegistration. | 54 * SyncRegistration or a PeriodicSyncRegistration. |
63 */ | 55 */ |
64 Periodicity periodicity; | 56 Periodicity periodicity; |
65 | 57 |
66 WebString tag; | 58 WebString tag; |
67 | 59 |
68 /* Minimum time between periodic sync events, in milliseconds. A 0 value | 60 /* Minimum time between periodic sync events, in milliseconds. A 0 value |
69 * here means that the event is a one-shot (not periodic.) | 61 * here means that the event is a one-shot (not periodic.) |
70 */ | 62 */ |
71 unsigned long minPeriodMs; | 63 unsigned long minPeriodMs; |
72 | 64 |
73 NetworkState networkState; | 65 NetworkState networkState; |
74 PowerState powerState; | |
75 }; | 66 }; |
76 | 67 |
77 } // namespace blink | 68 } // namespace blink |
78 | 69 |
79 #endif // WebSyncRegistration_h | 70 #endif // WebSyncRegistration_h |
OLD | NEW |