OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_GCM_DRIVER_GCM_CLIENT_IMPL_H_ | 5 #ifndef COMPONENTS_GCM_DRIVER_GCM_CLIENT_IMPL_H_ |
6 #define COMPONENTS_GCM_DRIVER_GCM_CLIENT_IMPL_H_ | 6 #define COMPONENTS_GCM_DRIVER_GCM_CLIENT_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 virtual void CheckOut() OVERRIDE; | 94 virtual void CheckOut() OVERRIDE; |
95 virtual void Register(const std::string& app_id, | 95 virtual void Register(const std::string& app_id, |
96 const std::vector<std::string>& sender_ids) OVERRIDE; | 96 const std::vector<std::string>& sender_ids) OVERRIDE; |
97 virtual void Unregister(const std::string& app_id) OVERRIDE; | 97 virtual void Unregister(const std::string& app_id) OVERRIDE; |
98 virtual void Send(const std::string& app_id, | 98 virtual void Send(const std::string& app_id, |
99 const std::string& receiver_id, | 99 const std::string& receiver_id, |
100 const OutgoingMessage& message) OVERRIDE; | 100 const OutgoingMessage& message) OVERRIDE; |
101 virtual void SetRecording(bool recording) OVERRIDE; | 101 virtual void SetRecording(bool recording) OVERRIDE; |
102 virtual void ClearActivityLogs() OVERRIDE; | 102 virtual void ClearActivityLogs() OVERRIDE; |
103 virtual GCMStatistics GetStatistics() const OVERRIDE; | 103 virtual GCMStatistics GetStatistics() const OVERRIDE; |
104 virtual void SetAccountsForCheckin( | |
105 const std::map<std::string, std::string>& account_tokens, | |
106 bool account_removed) OVERRIDE; | |
104 | 107 |
105 // GCMStatsRecorder::Delegate implemenation. | 108 // GCMStatsRecorder::Delegate implemenation. |
106 virtual void OnActivityRecorded() OVERRIDE; | 109 virtual void OnActivityRecorded() OVERRIDE; |
107 | 110 |
108 // ConnectionFactory::ConnectionListener implementation. | 111 // ConnectionFactory::ConnectionListener implementation. |
109 virtual void OnConnected(const GURL& current_server, | 112 virtual void OnConnected(const GURL& current_server, |
110 const net::IPEndPoint& ip_endpoint) OVERRIDE; | 113 const net::IPEndPoint& ip_endpoint) OVERRIDE; |
111 virtual void OnDisconnected() OVERRIDE; | 114 virtual void OnDisconnected() OVERRIDE; |
112 | 115 |
113 private: | 116 private: |
114 // State representation of the GCMClient. | 117 // State representation of the GCMClient. |
115 // Any change made to this enum should have corresponding change in the | 118 // Any change made to this enum should have corresponding change in the |
116 // GetStateString(...) function. | 119 // GetStateString(...) function. |
117 enum State { | 120 enum State { |
118 // Uninitialized. | 121 // Uninitialized. |
119 UNINITIALIZED, | 122 UNINITIALIZED, |
120 // Initialized, | 123 // Initialized, |
121 INITIALIZED, | 124 INITIALIZED, |
122 // GCM store loading is in progress. | 125 // GCM store loading is in progress. |
123 LOADING, | 126 LOADING, |
124 // Initial device checkin is in progress. | 127 // Initial device checkin is in progress. |
125 INITIAL_DEVICE_CHECKIN, | 128 INITIAL_DEVICE_CHECKIN, |
126 // Ready to accept requests. | 129 // Ready to accept requests. |
127 READY, | 130 READY, |
128 }; | 131 }; |
129 | 132 |
130 // The check-in info for the user. Returned by the server. | 133 // The check-in info for the user. Returned by the server. |
fgorski
2014/07/10 20:20:08
update documentation
fgorski
2014/07/11 22:51:21
Done.
| |
131 struct CheckinInfo { | 134 struct CheckinInfo { |
132 CheckinInfo() : android_id(0), secret(0) {} | 135 CheckinInfo(); |
136 ~CheckinInfo(); | |
133 bool IsValid() const { return android_id != 0 && secret != 0; } | 137 bool IsValid() const { return android_id != 0 && secret != 0; } |
134 void Reset() { | 138 void Reset(); |
135 android_id = 0; | |
136 secret = 0; | |
137 } | |
138 | 139 |
139 uint64 android_id; | 140 uint64 android_id; |
140 uint64 secret; | 141 uint64 secret; |
142 uint64 last_checkin_accounts_count; | |
143 bool accounts_set; | |
144 std::map<std::string, std::string> account_tokens; | |
141 }; | 145 }; |
142 | 146 |
143 // Collection of pending registration requests. Keys are app IDs, while values | 147 // Collection of pending registration requests. Keys are app IDs, while values |
144 // are pending registration requests to obtain a registration ID for | 148 // are pending registration requests to obtain a registration ID for |
145 // requesting application. | 149 // requesting application. |
146 typedef std::map<std::string, RegistrationRequest*> | 150 typedef std::map<std::string, RegistrationRequest*> |
147 PendingRegistrationRequests; | 151 PendingRegistrationRequests; |
148 | 152 |
149 // Collection of pending unregistration requests. Keys are app IDs, while | 153 // Collection of pending unregistration requests. Keys are app IDs, while |
150 // values are pending unregistration requests to disable the registration ID | 154 // values are pending unregistration requests to disable the registration ID |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 | 196 |
193 // Callback passed to GCMStore::SetGServicesSettings. | 197 // Callback passed to GCMStore::SetGServicesSettings. |
194 void SetGServicesSettingsCallback(bool success); | 198 void SetGServicesSettingsCallback(bool success); |
195 | 199 |
196 // Schedules next periodic device checkin and makes sure there is at most one | 200 // Schedules next periodic device checkin and makes sure there is at most one |
197 // pending checkin at a time. This function is meant to be called after a | 201 // pending checkin at a time. This function is meant to be called after a |
198 // successful checkin. | 202 // successful checkin. |
199 void SchedulePeriodicCheckin(); | 203 void SchedulePeriodicCheckin(); |
200 // Gets the time until next checkin. | 204 // Gets the time until next checkin. |
201 base::TimeDelta GetTimeToNextCheckin() const; | 205 base::TimeDelta GetTimeToNextCheckin() const; |
202 // Callback for setting last checkin time in the |gcm_store_|. | 206 // Callback for setting last checkin time in the |gcm_store_|. |
fgorski
2014/07/10 20:20:08
update documentation
fgorski
2014/07/11 22:51:21
Done.
| |
203 void SetLastCheckinTimeCallback(bool success); | 207 void SetLastCheckinInfoCallback(bool success); |
204 | 208 |
205 // Callback for persisting device credentials in the |gcm_store_|. | 209 // Callback for persisting device credentials in the |gcm_store_|. |
206 void SetDeviceCredentialsCallback(bool success); | 210 void SetDeviceCredentialsCallback(bool success); |
207 | 211 |
208 // Callback for persisting registration info in the |gcm_store_|. | 212 // Callback for persisting registration info in the |gcm_store_|. |
209 void UpdateRegistrationCallback(bool success); | 213 void UpdateRegistrationCallback(bool success); |
210 | 214 |
211 // Completes the registration request. | 215 // Completes the registration request. |
212 void OnRegisterCompleted(const std::string& app_id, | 216 void OnRegisterCompleted(const std::string& app_id, |
213 const std::vector<std::string>& sender_ids, | 217 const std::vector<std::string>& sender_ids, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
298 | 302 |
299 // Factory for creating references in callbacks. | 303 // Factory for creating references in callbacks. |
300 base::WeakPtrFactory<GCMClientImpl> weak_ptr_factory_; | 304 base::WeakPtrFactory<GCMClientImpl> weak_ptr_factory_; |
301 | 305 |
302 DISALLOW_COPY_AND_ASSIGN(GCMClientImpl); | 306 DISALLOW_COPY_AND_ASSIGN(GCMClientImpl); |
303 }; | 307 }; |
304 | 308 |
305 } // namespace gcm | 309 } // namespace gcm |
306 | 310 |
307 #endif // COMPONENTS_GCM_DRIVER_GCM_CLIENT_IMPL_H_ | 311 #endif // COMPONENTS_GCM_DRIVER_GCM_CLIENT_IMPL_H_ |
OLD | NEW |