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 <stdint.h> |
| 9 |
8 #include <map> | 10 #include <map> |
9 #include <set> | 11 #include <set> |
10 #include <string> | 12 #include <string> |
11 #include <utility> | 13 #include <utility> |
12 #include <vector> | 14 #include <vector> |
13 | 15 |
14 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
| 17 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
17 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
18 #include "components/gcm_driver/gcm_client.h" | 21 #include "components/gcm_driver/gcm_client.h" |
19 #include "components/gcm_driver/gcm_stats_recorder_impl.h" | 22 #include "components/gcm_driver/gcm_stats_recorder_impl.h" |
20 #include "google_apis/gcm/base/mcs_message.h" | 23 #include "google_apis/gcm/base/mcs_message.h" |
21 #include "google_apis/gcm/engine/gcm_store.h" | 24 #include "google_apis/gcm/engine/gcm_store.h" |
22 #include "google_apis/gcm/engine/gservices_settings.h" | 25 #include "google_apis/gcm/engine/gservices_settings.h" |
23 #include "google_apis/gcm/engine/mcs_client.h" | 26 #include "google_apis/gcm/engine/mcs_client.h" |
24 #include "google_apis/gcm/engine/registration_request.h" | 27 #include "google_apis/gcm/engine/registration_request.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 // The check-in info for the device. | 150 // The check-in info for the device. |
148 // TODO(fgorski): Convert to a class with explicit getters/setters. | 151 // TODO(fgorski): Convert to a class with explicit getters/setters. |
149 struct CheckinInfo { | 152 struct CheckinInfo { |
150 CheckinInfo(); | 153 CheckinInfo(); |
151 ~CheckinInfo(); | 154 ~CheckinInfo(); |
152 bool IsValid() const { return android_id != 0 && secret != 0; } | 155 bool IsValid() const { return android_id != 0 && secret != 0; } |
153 void SnapshotCheckinAccounts(); | 156 void SnapshotCheckinAccounts(); |
154 void Reset(); | 157 void Reset(); |
155 | 158 |
156 // Android ID of the device as assigned by the server. | 159 // Android ID of the device as assigned by the server. |
157 uint64 android_id; | 160 uint64_t android_id; |
158 // Security token of the device as assigned by the server. | 161 // Security token of the device as assigned by the server. |
159 uint64 secret; | 162 uint64_t secret; |
160 // True if accounts were already provided through SetAccountsForCheckin(), | 163 // True if accounts were already provided through SetAccountsForCheckin(), |
161 // or when |last_checkin_accounts| was loaded as empty. | 164 // or when |last_checkin_accounts| was loaded as empty. |
162 bool accounts_set; | 165 bool accounts_set; |
163 // Map of account email addresses and OAuth2 tokens that will be sent to the | 166 // Map of account email addresses and OAuth2 tokens that will be sent to the |
164 // checkin server on a next checkin. | 167 // checkin server on a next checkin. |
165 std::map<std::string, std::string> account_tokens; | 168 std::map<std::string, std::string> account_tokens; |
166 // As set of accounts last checkin was completed with. | 169 // As set of accounts last checkin was completed with. |
167 std::set<std::string> last_checkin_accounts; | 170 std::set<std::string> last_checkin_accounts; |
168 }; | 171 }; |
169 | 172 |
(...skipping 15 matching lines...) Expand all Loading... |
185 friend class GCMClientImplTest; | 188 friend class GCMClientImplTest; |
186 friend class GCMClientInstanceIDTest; | 189 friend class GCMClientInstanceIDTest; |
187 | 190 |
188 // Returns text representation of the enum State. | 191 // Returns text representation of the enum State. |
189 std::string GetStateString() const; | 192 std::string GetStateString() const; |
190 | 193 |
191 // Callbacks for the MCSClient. | 194 // Callbacks for the MCSClient. |
192 // Receives messages and dispatches them to relevant user delegates. | 195 // Receives messages and dispatches them to relevant user delegates. |
193 void OnMessageReceivedFromMCS(const gcm::MCSMessage& message); | 196 void OnMessageReceivedFromMCS(const gcm::MCSMessage& message); |
194 // Receives confirmation of sent messages or information about errors. | 197 // Receives confirmation of sent messages or information about errors. |
195 void OnMessageSentToMCS(int64 user_serial_number, | 198 void OnMessageSentToMCS(int64_t user_serial_number, |
196 const std::string& app_id, | 199 const std::string& app_id, |
197 const std::string& message_id, | 200 const std::string& message_id, |
198 MCSClient::MessageSendStatus status); | 201 MCSClient::MessageSendStatus status); |
199 // Receives information about mcs_client_ errors. | 202 // Receives information about mcs_client_ errors. |
200 void OnMCSError(); | 203 void OnMCSError(); |
201 | 204 |
202 // Runs after GCM Store load is done to trigger continuation of the | 205 // Runs after GCM Store load is done to trigger continuation of the |
203 // initialization. | 206 // initialization. |
204 void OnLoadCompleted(scoped_ptr<GCMStore::LoadResult> result); | 207 void OnLoadCompleted(scoped_ptr<GCMStore::LoadResult> result); |
205 // Starts the GCM. | 208 // Starts the GCM. |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 | 374 |
372 // Factory for creating references in callbacks. | 375 // Factory for creating references in callbacks. |
373 base::WeakPtrFactory<GCMClientImpl> weak_ptr_factory_; | 376 base::WeakPtrFactory<GCMClientImpl> weak_ptr_factory_; |
374 | 377 |
375 DISALLOW_COPY_AND_ASSIGN(GCMClientImpl); | 378 DISALLOW_COPY_AND_ASSIGN(GCMClientImpl); |
376 }; | 379 }; |
377 | 380 |
378 } // namespace gcm | 381 } // namespace gcm |
379 | 382 |
380 #endif // COMPONENTS_GCM_DRIVER_GCM_CLIENT_IMPL_H_ | 383 #endif // COMPONENTS_GCM_DRIVER_GCM_CLIENT_IMPL_H_ |
OLD | NEW |