blob: f9fe0a9d974a21d2ed51f6f90e2ffe6029068c09 [file] [log] [blame]
[email protected]cd57f372014-06-09 17:13:061// Copyright 2014 The Chromium Authors. All rights reserved.
[email protected]e4097c82013-11-08 00:16:122// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]cd57f372014-06-09 17:13:065#ifndef COMPONENTS_GCM_DRIVER_GCM_CLIENT_IMPL_H_
6#define COMPONENTS_GCM_DRIVER_GCM_CLIENT_IMPL_H_
[email protected]e4097c82013-11-08 00:16:127
avi26062922015-12-26 00:14:188#include <stdint.h>
9
[email protected]b83122a92014-01-22 21:29:2910#include <map>
dchenga77e28eb2016-04-21 21:34:3711#include <memory>
[email protected]7df5ef22014-07-17 07:35:5812#include <set>
[email protected]b83122a92014-01-22 21:29:2913#include <string>
jianli7a0c9b62015-05-26 23:24:4714#include <utility>
[email protected]848b1b62014-01-30 23:51:0415#include <vector>
[email protected]b83122a92014-01-22 21:29:2916
[email protected]e4097c82013-11-08 00:16:1217#include "base/compiler_specific.h"
avi26062922015-12-26 00:14:1818#include "base/macros.h"
[email protected]79994f42014-01-16 16:05:3619#include "base/memory/ref_counted.h"
[email protected]955e0ff2014-01-31 20:42:1220#include "base/memory/weak_ptr.h"
Sebastien Marchandefda77e532019-01-25 22:53:5221#include "base/timer/timer.h"
[email protected]cd57f372014-06-09 17:13:0622#include "components/gcm_driver/gcm_client.h"
23#include "components/gcm_driver/gcm_stats_recorder_impl.h"
[email protected]b83122a92014-01-22 21:29:2924#include "google_apis/gcm/base/mcs_message.h"
25#include "google_apis/gcm/engine/gcm_store.h"
[email protected]06e45272014-05-06 03:41:3426#include "google_apis/gcm/engine/gservices_settings.h"
[email protected]b83122a92014-01-22 21:29:2927#include "google_apis/gcm/engine/mcs_client.h"
[email protected]b4dd0232014-02-08 02:37:3128#include "google_apis/gcm/engine/registration_request.h"
[email protected]0e88e1d12014-03-19 06:53:0829#include "google_apis/gcm/engine/unregistration_request.h"
[email protected]436bcb82014-04-18 00:40:5730#include "google_apis/gcm/protocol/android_checkin.pb.h"
[email protected]2c4d4cd2014-04-10 21:10:2231#include "google_apis/gcm/protocol/checkin.pb.h"
zea76342abf2016-11-01 17:26:0432#include "net/http/http_status_code.h"
Helen Li5f3d96a2018-08-10 20:37:2433#include "services/network/public/mojom/proxy_resolving_socket.mojom.h"
[email protected]e4097c82013-11-08 00:16:1234
[email protected]2bbe0a682014-03-26 00:08:3135class GURL;
36
[email protected]79994f42014-01-16 16:05:3637namespace base {
[email protected]955e0ff2014-01-31 20:42:1238class Clock;
[email protected]764c0442014-05-01 04:30:5539class Time;
[email protected]79994f42014-01-16 16:05:3640} // namespace base
41
[email protected]436bcb82014-04-18 00:40:5742namespace mcs_proto {
43class DataMessageStanza;
44} // namespace mcs_proto
45
Maks Orlovichc70c93c2018-07-12 02:45:4446namespace network {
Robbie McElrathb01499332018-09-25 00:53:1347class NetworkConnectionTracker;
Maks Orlovichc70c93c2018-07-12 02:45:4448class SharedURLLoaderFactory;
49} // namespace network
50
[email protected]e4097c82013-11-08 00:16:1251namespace gcm {
52
[email protected]b83122a92014-01-22 21:29:2953class CheckinRequest;
54class ConnectionFactory;
55class GCMClientImplTest;
[email protected]79994f42014-01-16 16:05:3656
[email protected]2bbe0a682014-03-26 00:08:3157// Helper class for building GCM internals. Allows tests to inject fake versions
58// as necessary.
[email protected]cd57f372014-06-09 17:13:0659class GCMInternalsBuilder {
[email protected]2bbe0a682014-03-26 00:08:3160 public:
61 GCMInternalsBuilder();
62 virtual ~GCMInternalsBuilder();
63
tzik48479d92018-03-20 15:20:4264 virtual base::Clock* GetClock();
dchenga77e28eb2016-04-21 21:34:3765 virtual std::unique_ptr<MCSClient> BuildMCSClient(
[email protected]2bbe0a682014-03-26 00:08:3166 const std::string& version,
67 base::Clock* clock,
68 ConnectionFactory* connection_factory,
[email protected]436bcb82014-04-18 00:40:5769 GCMStore* gcm_store,
Steven Zhub36394c2019-06-04 16:10:4670 scoped_refptr<base::SequencedTaskRunner> io_task_runner,
[email protected]436bcb82014-04-18 00:40:5771 GCMStatsRecorder* recorder);
dchenga77e28eb2016-04-21 21:34:3772 virtual std::unique_ptr<ConnectionFactory> BuildConnectionFactory(
[email protected]2bbe0a682014-03-26 00:08:3173 const std::vector<GURL>& endpoints,
74 const net::BackoffEntry::Policy& backoff_policy,
Helen Li5f3d96a2018-08-10 20:37:2475 base::RepeatingCallback<
76 void(network::mojom::ProxyResolvingSocketFactoryRequest)>
77 get_socket_factory_callback,
Steven Zhub36394c2019-06-04 16:10:4678 scoped_refptr<base::SequencedTaskRunner> io_task_runner,
Robbie McElrathb01499332018-09-25 00:53:1379 GCMStatsRecorder* recorder,
80 network::NetworkConnectionTracker* network_connection_tracker);
[email protected]2bbe0a682014-03-26 00:08:3181};
82
[email protected]b83122a92014-01-22 21:29:2983// Implements the GCM Client. It is used to coordinate MCS Client (communication
84// with MCS) and other pieces of GCM infrastructure like Registration and
85// Checkins. It also allows for registering user delegates that host
86// applications that send and receive messages.
[email protected]cd57f372014-06-09 17:13:0687class GCMClientImpl
[email protected]c31e1b52014-06-12 21:00:4788 : public GCMClient, public GCMStatsRecorder::Delegate,
89 public ConnectionFactory::ConnectionListener {
[email protected]e4097c82013-11-08 00:16:1290 public:
jianlif3e52af42015-01-21 23:18:4791 // State representation of the GCMClient.
92 // Any change made to this enum should have corresponding change in the
93 // GetStateString(...) function.
94 enum State {
95 // Uninitialized.
96 UNINITIALIZED,
97 // Initialized,
98 INITIALIZED,
99 // GCM store loading is in progress.
100 LOADING,
101 // GCM store is loaded.
102 LOADED,
103 // Initial device checkin is in progress.
104 INITIAL_DEVICE_CHECKIN,
105 // Ready to accept requests.
106 READY,
107 };
108
dchenga77e28eb2016-04-21 21:34:37109 explicit GCMClientImpl(
110 std::unique_ptr<GCMInternalsBuilder> internals_builder);
dcheng00ea022b2014-10-21 11:24:56111 ~GCMClientImpl() override;
[email protected]e4097c82013-11-08 00:16:12112
[email protected]c31e1b52014-06-12 21:00:47113 // GCMClient implementation.
dcheng00ea022b2014-10-21 11:24:56114 void Initialize(
[email protected]8ad80512014-05-23 09:40:47115 const ChromeBuildInfo& chrome_build_info,
[email protected]e2a4a8012014-02-07 22:32:52116 const base::FilePath& store_path,
117 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner,
Steven Zhub36394c2019-06-04 16:10:46118 scoped_refptr<base::SequencedTaskRunner> io_task_runner,
Helen Li5f3d96a2018-08-10 20:37:24119 base::RepeatingCallback<
120 void(network::mojom::ProxyResolvingSocketFactoryRequest)>
121 get_socket_factory_callback,
Maks Orlovichc70c93c2018-07-12 02:45:44122 const scoped_refptr<network::SharedURLLoaderFactory>& url_loader_factory,
Robbie McElrathb01499332018-09-25 00:53:13123 network::NetworkConnectionTracker* network_connection_tracker,
dchenga77e28eb2016-04-21 21:34:37124 std::unique_ptr<Encryptor> encryptor,
mostynbfe59f482014-10-06 15:04:46125 GCMClient::Delegate* delegate) override;
jianlif3e52af42015-01-21 23:18:47126 void Start(StartMode start_mode) override;
dcheng00ea022b2014-10-21 11:24:56127 void Stop() override;
Rayan Kanso3da434f2018-12-19 17:09:39128 void Register(scoped_refptr<RegistrationInfo> registration_info) override;
129 bool ValidateRegistration(scoped_refptr<RegistrationInfo> registration_info,
130 const std::string& registration_id) override;
131 void Unregister(scoped_refptr<RegistrationInfo> registration_info) override;
dcheng00ea022b2014-10-21 11:24:56132 void Send(const std::string& app_id,
133 const std::string& receiver_id,
134 const OutgoingMessage& message) override;
peteree284ba52016-02-01 11:53:28135 void RecordDecryptionFailure(const std::string& app_id,
Peter Beverlooa376e98c2017-06-27 15:55:37136 GCMDecryptionResult result) override;
dcheng00ea022b2014-10-21 11:24:56137 void SetRecording(bool recording) override;
138 void ClearActivityLogs() override;
139 GCMStatistics GetStatistics() const override;
140 void SetAccountTokens(
mostynbfe59f482014-10-06 15:04:46141 const std::vector<AccountTokenInfo>& account_tokens) override;
dcheng00ea022b2014-10-21 11:24:56142 void UpdateAccountMapping(const AccountMapping& account_mapping) override;
Tanmoy Mollikf6ec6b92019-08-12 16:19:55143 void RemoveAccountMapping(const CoreAccountId& account_id) override;
fgorski5df101702014-10-28 02:09:31144 void SetLastTokenFetchTime(const base::Time& time) override;
tzikb6c66b22018-07-06 12:14:16145 void UpdateHeartbeatTimer(
146 std::unique_ptr<base::RetainingOneShotTimer> timer) override;
jianli10018b2d2015-05-11 21:14:13147 void AddInstanceIDData(const std::string& app_id,
jianli7a0c9b62015-05-26 23:24:47148 const std::string& instance_id,
149 const std::string& extra_data) override;
jianli10018b2d2015-05-11 21:14:13150 void RemoveInstanceIDData(const std::string& app_id) override;
jianli7a0c9b62015-05-26 23:24:47151 void GetInstanceIDData(const std::string& app_id,
152 std::string* instance_id,
153 std::string* extra_data) override;
fgorski22754462015-05-14 00:05:22154 void AddHeartbeatInterval(const std::string& scope, int interval_ms) override;
155 void RemoveHeartbeatInterval(const std::string& scope) override;
[email protected]c31e1b52014-06-12 21:00:47156
157 // GCMStatsRecorder::Delegate implemenation.
dcheng00ea022b2014-10-21 11:24:56158 void OnActivityRecorded() override;
[email protected]e4097c82013-11-08 00:16:12159
[email protected]c31e1b52014-06-12 21:00:47160 // ConnectionFactory::ConnectionListener implementation.
dcheng00ea022b2014-10-21 11:24:56161 void OnConnected(const GURL& current_server,
162 const net::IPEndPoint& ip_endpoint) override;
163 void OnDisconnected() override;
[email protected]c31e1b52014-06-12 21:00:47164
[email protected]e4097c82013-11-08 00:16:12165 private:
[email protected]7df5ef22014-07-17 07:35:58166 // The check-in info for the device.
167 // TODO(fgorski): Convert to a class with explicit getters/setters.
[email protected]cd57f372014-06-09 17:13:06168 struct CheckinInfo {
[email protected]7df5ef22014-07-17 07:35:58169 CheckinInfo();
170 ~CheckinInfo();
[email protected]5799d052014-02-12 20:47:39171 bool IsValid() const { return android_id != 0 && secret != 0; }
[email protected]7df5ef22014-07-17 07:35:58172 void SnapshotCheckinAccounts();
173 void Reset();
[email protected]b83122a92014-01-22 21:29:29174
[email protected]7df5ef22014-07-17 07:35:58175 // Android ID of the device as assigned by the server.
avi26062922015-12-26 00:14:18176 uint64_t android_id;
[email protected]7df5ef22014-07-17 07:35:58177 // Security token of the device as assigned by the server.
avi26062922015-12-26 00:14:18178 uint64_t secret;
[email protected]7df5ef22014-07-17 07:35:58179 // True if accounts were already provided through SetAccountsForCheckin(),
180 // or when |last_checkin_accounts| was loaded as empty.
181 bool accounts_set;
182 // Map of account email addresses and OAuth2 tokens that will be sent to the
183 // checkin server on a next checkin.
184 std::map<std::string, std::string> account_tokens;
185 // As set of accounts last checkin was completed with.
186 std::set<std::string> last_checkin_accounts;
[email protected]848b1b62014-01-30 23:51:04187 };
188
zeae6e404182016-11-04 23:05:45189 // Reasons for resetting the GCM Store.
190 // Note: this enum is recorded into a histogram. Do not change enum value
191 // or order.
192 enum ResetReason {
193 LOAD_FAILURE, // GCM store failed to load, but the store exists.
194 CHECKIN_REJECTED, // Checkin was rejected by server.
195
196 RESET_REASON_COUNT,
197 };
198
jianli7a0c9b62015-05-26 23:24:47199 // Collection of pending registration requests. Keys are RegistrationInfo
200 // instance, while values are pending registration requests to obtain a
201 // registration ID for requesting application.
dchenga77e28eb2016-04-21 21:34:37202 using PendingRegistrationRequests =
Rayan Kanso3da434f2018-12-19 17:09:39203 std::map<scoped_refptr<RegistrationInfo>,
dchenga77e28eb2016-04-21 21:34:37204 std::unique_ptr<RegistrationRequest>,
205 RegistrationInfoComparer>;
[email protected]848b1b62014-01-30 23:51:04206
jianli7a0c9b62015-05-26 23:24:47207 // Collection of pending unregistration requests. Keys are RegistrationInfo
208 // instance, while values are pending unregistration requests to disable the
209 // registration ID currently assigned to the application.
limasdf20c5d7a2015-12-01 01:16:19210 using PendingUnregistrationRequests =
Rayan Kanso3da434f2018-12-19 17:09:39211 std::map<scoped_refptr<RegistrationInfo>,
dchenga77e28eb2016-04-21 21:34:37212 std::unique_ptr<UnregistrationRequest>,
limasdf20c5d7a2015-12-01 01:16:19213 RegistrationInfoComparer>;
[email protected]e4007042014-02-15 20:34:28214
[email protected]b83122a92014-01-22 21:29:29215 friend class GCMClientImplTest;
jianlic02d25e2015-05-27 22:24:31216 friend class GCMClientInstanceIDTest;
[email protected]b83122a92014-01-22 21:29:29217
[email protected]35601812014-03-07 19:52:43218 // Returns text representation of the enum State.
219 std::string GetStateString() const;
220
[email protected]b83122a92014-01-22 21:29:29221 // Callbacks for the MCSClient.
222 // Receives messages and dispatches them to relevant user delegates.
223 void OnMessageReceivedFromMCS(const gcm::MCSMessage& message);
224 // Receives confirmation of sent messages or information about errors.
avi26062922015-12-26 00:14:18225 void OnMessageSentToMCS(int64_t user_serial_number,
[email protected]b83122a92014-01-22 21:29:29226 const std::string& app_id,
227 const std::string& message_id,
228 MCSClient::MessageSendStatus status);
229 // Receives information about mcs_client_ errors.
230 void OnMCSError();
231
232 // Runs after GCM Store load is done to trigger continuation of the
233 // initialization.
dchenga77e28eb2016-04-21 21:34:37234 void OnLoadCompleted(std::unique_ptr<GCMStore::LoadResult> result);
jianlif3e52af42015-01-21 23:18:47235 // Starts the GCM.
236 void StartGCM();
[email protected]b83122a92014-01-22 21:29:29237 // Initializes mcs_client_, which handles the connection to MCS.
jianlif3e52af42015-01-21 23:18:47238 void InitializeMCSClient();
[email protected]b83122a92014-01-22 21:29:29239 // Complets the first time device checkin.
240 void OnFirstTimeDeviceCheckinCompleted(const CheckinInfo& checkin_info);
241 // Starts a login on mcs_client_.
242 void StartMCSLogin();
jianli00b4600f2015-02-10 23:32:49243 // Resets the GCM store when it is corrupted.
244 void ResetStore();
[email protected]86625df2014-01-31 03:47:58245 // Sets state to ready. This will initiate the MCS login and notify the
246 // delegates.
fgorski5df101702014-10-28 02:09:31247 void OnReady(const std::vector<AccountMapping>& account_mappings,
248 const base::Time& last_token_fetch_time);
[email protected]b83122a92014-01-22 21:29:29249
[email protected]5799d052014-02-12 20:47:39250 // Starts a first time device checkin.
[email protected]25b5f50e2014-04-03 08:27:23251 void StartCheckin();
[email protected]2c4d4cd2014-04-10 21:10:22252 // Completes the device checkin request by parsing the |checkin_response|.
253 // Function also cleans up the pending checkin.
254 void OnCheckinCompleted(
zea76342abf2016-11-01 17:26:04255 net::HttpStatusCode response_code,
[email protected]2c4d4cd2014-04-10 21:10:22256 const checkin_proto::AndroidCheckinResponse& checkin_response);
[email protected]06e45272014-05-06 03:41:34257
258 // Callback passed to GCMStore::SetGServicesSettings.
259 void SetGServicesSettingsCallback(bool success);
260
[email protected]764c0442014-05-01 04:30:55261 // Schedules next periodic device checkin and makes sure there is at most one
262 // pending checkin at a time. This function is meant to be called after a
263 // successful checkin.
264 void SchedulePeriodicCheckin();
265 // Gets the time until next checkin.
266 base::TimeDelta GetTimeToNextCheckin() const;
[email protected]7df5ef22014-07-17 07:35:58267 // Callback for setting last checkin information in the |gcm_store_|.
268 void SetLastCheckinInfoCallback(bool success);
[email protected]b83122a92014-01-22 21:29:29269
270 // Callback for persisting device credentials in the |gcm_store_|.
271 void SetDeviceCredentialsCallback(bool success);
272
[email protected]3a20a4d2014-03-21 22:54:21273 // Callback for persisting registration info in the |gcm_store_|.
274 void UpdateRegistrationCallback(bool success);
275
[email protected]72d4f252014-08-20 22:34:28276 // Callback for all store operations that do not try to recover, if write in
277 // |gcm_store_| fails.
278 void DefaultStoreCallback(bool success);
279
fgorski9a405102014-11-19 01:25:16280 // Callback for store operation where result does not matter.
281 void IgnoreWriteResultCallback(bool success);
282
jianli78b56042015-06-17 01:21:22283 // Callback for destroying the GCM store.
284 void DestroyStoreCallback(bool success);
285
286 // Callback for resetting the GCM store. The store will be reloaded.
jianli00b4600f2015-02-10 23:32:49287 void ResetStoreCallback(bool success);
288
[email protected]848b1b62014-01-30 23:51:04289 // Completes the registration request.
Rayan Kanso3da434f2018-12-19 17:09:39290 void OnRegisterCompleted(scoped_refptr<RegistrationInfo> registration_info,
291 RegistrationRequest::Status status,
292 const std::string& registration_id);
[email protected]848b1b62014-01-30 23:51:04293
[email protected]e4007042014-02-15 20:34:28294 // Completes the unregistration request.
Rayan Kanso3da434f2018-12-19 17:09:39295 void OnUnregisterCompleted(scoped_refptr<RegistrationInfo> registration_info,
296 UnregistrationRequest::Status status);
[email protected]e4007042014-02-15 20:34:28297
[email protected]d3a4b2e2014-02-27 13:46:54298 // Completes the GCM store destroy request.
299 void OnGCMStoreDestroyed(bool success);
300
[email protected]c6fe36b2014-03-11 10:58:12301 // Handles incoming data message and dispatches it the delegate of this class.
[email protected]b83122a92014-01-22 21:29:29302 void HandleIncomingMessage(const gcm::MCSMessage& message);
303
[email protected]c6fe36b2014-03-11 10:58:12304 // Fires OnMessageReceived event on the delegate of this class, based on the
305 // details in |data_message_stanza| and |message_data|.
306 void HandleIncomingDataMessage(
johnme627dc8c72016-08-19 21:49:39307 const std::string& app_id,
308 bool was_subtype,
[email protected]c6fe36b2014-03-11 10:58:12309 const mcs_proto::DataMessageStanza& data_message_stanza,
310 MessageData& message_data);
311
johnme409dc532016-12-13 23:43:42312 // Fires OnMessagesDeleted event on the delegate of this class, based on the
313 // details in |data_message_stanza| and |message_data|.
314 void HandleIncomingDeletedMessages(
315 const std::string& app_id,
316 const mcs_proto::DataMessageStanza& data_message_stanza,
317 MessageData& message_data);
318
johnme627dc8c72016-08-19 21:49:39319 // Fires OnMessageSendError event on the delegate of this class, based on the
[email protected]c6fe36b2014-03-11 10:58:12320 // details in |data_message_stanza| and |message_data|.
321 void HandleIncomingSendError(
johnme627dc8c72016-08-19 21:49:39322 const std::string& app_id,
[email protected]c6fe36b2014-03-11 10:58:12323 const mcs_proto::DataMessageStanza& data_message_stanza,
324 MessageData& message_data);
[email protected]848b1b62014-01-30 23:51:04325
jianlif3e52af42015-01-21 23:18:47326 // Is there any standalone app being registered for GCM?
327 bool HasStandaloneRegisteredApp() const;
328
jianli78b56042015-06-17 01:21:22329 // Destroys the store when it is not needed.
330 void DestroyStoreWhenNotNeeded();
331
332 // Reset all cahced values.
333 void ResetCache();
334
[email protected]2bbe0a682014-03-26 00:08:31335 // Builder for the GCM internals (mcs client, etc.).
dchenga77e28eb2016-04-21 21:34:37336 std::unique_ptr<GCMInternalsBuilder> internals_builder_;
[email protected]b83122a92014-01-22 21:29:29337
[email protected]436bcb82014-04-18 00:40:57338 // Recorder that logs GCM activities.
[email protected]025adfa2014-06-03 21:51:12339 GCMStatsRecorderImpl recorder_;
[email protected]436bcb82014-04-18 00:40:57340
[email protected]b83122a92014-01-22 21:29:29341 // State of the GCM Client Implementation.
342 State state_;
343
[email protected]7de78802014-05-10 19:49:40344 GCMClient::Delegate* delegate_;
[email protected]5799d052014-02-12 20:47:39345
jianlif3e52af42015-01-21 23:18:47346 // Flag to indicate if the GCM should be delay started until it is actually
347 // used in either of the following cases:
348 // 1) The GCM store contains the registration records.
349 // 2) GCM functionailities are explicitly called.
350 StartMode start_mode_;
351
[email protected]b83122a92014-01-22 21:29:29352 // Device checkin info (android ID and security token used by device).
353 CheckinInfo device_checkin_info_;
354
tzik48479d92018-03-20 15:20:42355 // Clock used for timing of retry logic. Passed in for testing.
356 base::Clock* clock_;
[email protected]b83122a92014-01-22 21:29:29357
358 // Information about the chrome build.
359 // TODO(fgorski): Check if it can be passed in constructor and made const.
[email protected]8ad80512014-05-23 09:40:47360 ChromeBuildInfo chrome_build_info_;
[email protected]b83122a92014-01-22 21:29:29361
362 // Persistent data store for keeping device credentials, messages and user to
363 // serial number mappings.
dchenga77e28eb2016-04-21 21:34:37364 std::unique_ptr<GCMStore> gcm_store_;
[email protected]b83122a92014-01-22 21:29:29365
jianlif3e52af42015-01-21 23:18:47366 // Data loaded from the GCM store.
dchenga77e28eb2016-04-21 21:34:37367 std::unique_ptr<GCMStore::LoadResult> load_result_;
jianlif3e52af42015-01-21 23:18:47368
jianli00b4600f2015-02-10 23:32:49369 // Tracks if the GCM store has been reset. This is used to prevent from
370 // resetting and loading from the store again and again.
371 bool gcm_store_reset_;
372
dchenga77e28eb2016-04-21 21:34:37373 std::unique_ptr<ConnectionFactory> connection_factory_;
Helen Li5f3d96a2018-08-10 20:37:24374 base::RepeatingCallback<void(
375 network::mojom::ProxyResolvingSocketFactoryRequest)>
376 get_socket_factory_callback_;
377
Maks Orlovichc70c93c2018-07-12 02:45:44378 scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory_;
[email protected]b83122a92014-01-22 21:29:29379
Robbie McElrathb01499332018-09-25 00:53:13380 network::NetworkConnectionTracker* network_connection_tracker_;
381
Steven Zhub36394c2019-06-04 16:10:46382 scoped_refptr<base::SequencedTaskRunner> io_task_runner_;
383
[email protected]b83122a92014-01-22 21:29:29384 // Controls receiving and sending of packets and reliable message queueing.
mmenkee65e7af2015-10-13 17:16:42385 // Must be destroyed before |network_session_|.
dchenga77e28eb2016-04-21 21:34:37386 std::unique_ptr<MCSClient> mcs_client_;
[email protected]b83122a92014-01-22 21:29:29387
dchenga77e28eb2016-04-21 21:34:37388 std::unique_ptr<CheckinRequest> checkin_request_;
[email protected]b83122a92014-01-22 21:29:29389
[email protected]3a20a4d2014-03-21 22:54:21390 // Cached registration info.
391 RegistrationInfoMap registrations_;
[email protected]848b1b62014-01-30 23:51:04392
[email protected]3a20a4d2014-03-21 22:54:21393 // Currently pending registration requests. GCMClientImpl owns the
394 // RegistrationRequests.
395 PendingRegistrationRequests pending_registration_requests_;
[email protected]3a20a4d2014-03-21 22:54:21396
397 // Currently pending unregistration requests. GCMClientImpl owns the
[email protected]e4007042014-02-15 20:34:28398 // UnregistrationRequests.
[email protected]3a20a4d2014-03-21 22:54:21399 PendingUnregistrationRequests pending_unregistration_requests_;
[email protected]e4007042014-02-15 20:34:28400
[email protected]764c0442014-05-01 04:30:55401 // G-services settings that were provided by MCS.
[email protected]06e45272014-05-06 03:41:34402 GServicesSettings gservices_settings_;
[email protected]764c0442014-05-01 04:30:55403
404 // Time of the last successful checkin.
405 base::Time last_checkin_time_;
406
jianli7a0c9b62015-05-26 23:24:47407 // Cached instance ID data, key is app ID and value is pair of instance ID
408 // and extra data.
409 std::map<std::string, std::pair<std::string, std::string>> instance_id_data_;
jianli10018b2d2015-05-11 21:14:13410
[email protected]764c0442014-05-01 04:30:55411 // Factory for creating references when scheduling periodic checkin.
Jeremy Roman5c341f6d2019-07-15 15:56:10412 base::WeakPtrFactory<GCMClientImpl> periodic_checkin_ptr_factory_{this};
[email protected]764c0442014-05-01 04:30:55413
jianli78b56042015-06-17 01:21:22414 // Factory for wiping out GCM store.
Jeremy Roman5c341f6d2019-07-15 15:56:10415 base::WeakPtrFactory<GCMClientImpl> destroying_gcm_store_ptr_factory_{this};
jianli78b56042015-06-17 01:21:22416
[email protected]955e0ff2014-01-31 20:42:12417 // Factory for creating references in callbacks.
Jeremy Roman5c341f6d2019-07-15 15:56:10418 base::WeakPtrFactory<GCMClientImpl> weak_ptr_factory_{this};
[email protected]955e0ff2014-01-31 20:42:12419
[email protected]e4097c82013-11-08 00:16:12420 DISALLOW_COPY_AND_ASSIGN(GCMClientImpl);
421};
422
423} // namespace gcm
424
[email protected]cd57f372014-06-09 17:13:06425#endif // COMPONENTS_GCM_DRIVER_GCM_CLIENT_IMPL_H_