[email protected] | cd57f37 | 2014-06-09 17:13:06 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
[email protected] | e4097c8 | 2013-11-08 00:16:12 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | cd57f37 | 2014-06-09 17:13:06 | [diff] [blame] | 5 | #ifndef COMPONENTS_GCM_DRIVER_GCM_CLIENT_H_ |
| 6 | #define COMPONENTS_GCM_DRIVER_GCM_CLIENT_H_ |
[email protected] | e4097c8 | 2013-11-08 00:16:12 | [diff] [blame] | 7 | |
avi | 2606292 | 2015-12-26 00:14:18 | [diff] [blame] | 8 | #include <stdint.h> |
| 9 | |
[email protected] | e4097c8 | 2013-11-08 00:16:12 | [diff] [blame] | 10 | #include <map> |
dcheng | a77e28eb | 2016-04-21 21:34:37 | [diff] [blame] | 11 | #include <memory> |
[email protected] | e4097c8 | 2013-11-08 00:16:12 | [diff] [blame] | 12 | #include <string> |
| 13 | #include <vector> |
| 14 | |
jianli | 7a0c9b6 | 2015-05-26 23:24:47 | [diff] [blame] | 15 | #include "base/memory/linked_ptr.h" |
mvanouwerkerk | f8633deb | 2015-07-13 11:04:06 | [diff] [blame] | 16 | #include "components/gcm_driver/common/gcm_messages.h" |
[email protected] | cd57f37 | 2014-06-09 17:13:06 | [diff] [blame] | 17 | #include "components/gcm_driver/gcm_activity.h" |
jianli | 7a0c9b6 | 2015-05-26 23:24:47 | [diff] [blame] | 18 | #include "components/gcm_driver/registration_info.h" |
[email protected] | e4097c8 | 2013-11-08 00:16:12 | [diff] [blame] | 19 | |
[email protected] | e2a4a801 | 2014-02-07 22:32:52 | [diff] [blame] | 20 | template <class T> class scoped_refptr; |
| 21 | |
| 22 | namespace base { |
| 23 | class FilePath; |
| 24 | class SequencedTaskRunner; |
chirantan | 192a921 | 2014-12-06 03:30:45 | [diff] [blame] | 25 | class Timer; |
[email protected] | e2a4a801 | 2014-02-07 22:32:52 | [diff] [blame] | 26 | } |
| 27 | |
[email protected] | e2a4a801 | 2014-02-07 22:32:52 | [diff] [blame] | 28 | namespace net { |
[email protected] | fc6078a | 2014-06-14 08:28:43 | [diff] [blame] | 29 | class IPEndPoint; |
[email protected] | e2a4a801 | 2014-02-07 22:32:52 | [diff] [blame] | 30 | class URLRequestContextGetter; |
| 31 | } |
| 32 | |
[email protected] | e4097c8 | 2013-11-08 00:16:12 | [diff] [blame] | 33 | namespace gcm { |
| 34 | |
[email protected] | 72d4f25 | 2014-08-20 22:34:28 | [diff] [blame] | 35 | struct AccountMapping; |
Peter Beverloo | a376e98c | 2017-06-27 15:55:37 | [diff] [blame] | 36 | class Encryptor; |
| 37 | enum class GCMDecryptionResult; |
[email protected] | 446f73c2 | 2014-05-14 20:47:18 | [diff] [blame] | 38 | |
[email protected] | e4097c8 | 2013-11-08 00:16:12 | [diff] [blame] | 39 | // Interface that encapsulates the network communications with the Google Cloud |
| 40 | // Messaging server. This interface is not supposed to be thread-safe. |
[email protected] | cd57f37 | 2014-06-09 17:13:06 | [diff] [blame] | 41 | class GCMClient { |
[email protected] | e4097c8 | 2013-11-08 00:16:12 | [diff] [blame] | 42 | public: |
jianli | f3e52af4 | 2015-01-21 23:18:47 | [diff] [blame] | 43 | // Controls how GCM is being started. At first, GCMClient will be initialized |
| 44 | // and GCM store will be loaded. Then GCM connection may or may not be |
| 45 | // initiated depending on this enum value. |
| 46 | enum StartMode { |
| 47 | // GCM should be started only when it is being actually used. If no |
| 48 | // registration record is found, GCM will not kick off. |
| 49 | DELAYED_START, |
| 50 | // GCM should be started immediately. |
| 51 | IMMEDIATE_START |
| 52 | }; |
| 53 | |
johnme | ef71bd0 | 2017-02-09 17:45:56 | [diff] [blame] | 54 | // Used for UMA. Can add enum values, but never renumber or delete and reuse. |
[email protected] | e4097c8 | 2013-11-08 00:16:12 | [diff] [blame] | 55 | enum Result { |
| 56 | // Successful operation. |
| 57 | SUCCESS, |
[email protected] | b16a7c5 | 2013-11-20 01:18:59 | [diff] [blame] | 58 | // Invalid parameter. |
| 59 | INVALID_PARAMETER, |
[email protected] | 9d7e5c0 | 2014-05-21 03:09:03 | [diff] [blame] | 60 | // GCM is disabled. |
| 61 | GCM_DISABLED, |
[email protected] | b16a7c5 | 2013-11-20 01:18:59 | [diff] [blame] | 62 | // Previous asynchronous operation is still pending to finish. Certain |
| 63 | // operation, like register, is only allowed one at a time. |
| 64 | ASYNC_OPERATION_PENDING, |
[email protected] | e4097c8 | 2013-11-08 00:16:12 | [diff] [blame] | 65 | // Network socket error. |
| 66 | NETWORK_ERROR, |
| 67 | // Problem at the server. |
| 68 | SERVER_ERROR, |
| 69 | // Exceeded the specified TTL during message sending. |
| 70 | TTL_EXCEEDED, |
| 71 | // Other errors. |
johnme | ef71bd0 | 2017-02-09 17:45:56 | [diff] [blame] | 72 | UNKNOWN_ERROR, |
| 73 | |
| 74 | // Used for UMA. Keep LAST_RESULT up to date and sync with histograms.xml. |
| 75 | LAST_RESULT = UNKNOWN_ERROR |
[email protected] | e4097c8 | 2013-11-08 00:16:12 | [diff] [blame] | 76 | }; |
| 77 | |
[email protected] | 8ad8051 | 2014-05-23 09:40:47 | [diff] [blame] | 78 | enum ChromePlatform { |
| 79 | PLATFORM_WIN, |
| 80 | PLATFORM_MAC, |
| 81 | PLATFORM_LINUX, |
| 82 | PLATFORM_CROS, |
| 83 | PLATFORM_IOS, |
| 84 | PLATFORM_ANDROID, |
Daniel Bratell | e3c10f3 | 2018-02-05 15:03:38 | [diff] [blame] | 85 | PLATFORM_UNSPECIFIED |
[email protected] | 8ad8051 | 2014-05-23 09:40:47 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | enum ChromeChannel { |
| 89 | CHANNEL_STABLE, |
| 90 | CHANNEL_BETA, |
| 91 | CHANNEL_DEV, |
| 92 | CHANNEL_CANARY, |
| 93 | CHANNEL_UNKNOWN |
| 94 | }; |
| 95 | |
[email protected] | cd57f37 | 2014-06-09 17:13:06 | [diff] [blame] | 96 | struct ChromeBuildInfo { |
[email protected] | 8ad8051 | 2014-05-23 09:40:47 | [diff] [blame] | 97 | ChromeBuildInfo(); |
| 98 | ~ChromeBuildInfo(); |
| 99 | |
| 100 | ChromePlatform platform; |
| 101 | ChromeChannel channel; |
| 102 | std::string version; |
johnme | 627dc8c7 | 2016-08-19 21:49:39 | [diff] [blame] | 103 | std::string product_category_for_subtypes; |
[email protected] | 8ad8051 | 2014-05-23 09:40:47 | [diff] [blame] | 104 | }; |
| 105 | |
[email protected] | c6fe36b | 2014-03-11 10:58:12 | [diff] [blame] | 106 | // Detailed information of the Send Error event. |
[email protected] | cd57f37 | 2014-06-09 17:13:06 | [diff] [blame] | 107 | struct SendErrorDetails { |
[email protected] | c6fe36b | 2014-03-11 10:58:12 | [diff] [blame] | 108 | SendErrorDetails(); |
vmpstr | b6449d51 | 2016-02-25 23:55:40 | [diff] [blame] | 109 | SendErrorDetails(const SendErrorDetails& other); |
[email protected] | c6fe36b | 2014-03-11 10:58:12 | [diff] [blame] | 110 | ~SendErrorDetails(); |
| 111 | |
| 112 | std::string message_id; |
| 113 | MessageData additional_data; |
| 114 | Result result; |
| 115 | }; |
| 116 | |
[email protected] | 3560181 | 2014-03-07 19:52:43 | [diff] [blame] | 117 | // Internal states and activity statistics of a GCM client. |
[email protected] | cd57f37 | 2014-06-09 17:13:06 | [diff] [blame] | 118 | struct GCMStatistics { |
[email protected] | 3560181 | 2014-03-07 19:52:43 | [diff] [blame] | 119 | public: |
| 120 | GCMStatistics(); |
vmpstr | b6449d51 | 2016-02-25 23:55:40 | [diff] [blame] | 121 | GCMStatistics(const GCMStatistics& other); |
[email protected] | 3560181 | 2014-03-07 19:52:43 | [diff] [blame] | 122 | ~GCMStatistics(); |
| 123 | |
[email protected] | 436bcb8 | 2014-04-18 00:40:57 | [diff] [blame] | 124 | bool is_recording; |
[email protected] | 3560181 | 2014-03-07 19:52:43 | [diff] [blame] | 125 | bool gcm_client_created; |
| 126 | std::string gcm_client_state; |
| 127 | bool connection_client_created; |
| 128 | std::string connection_state; |
zea | 76342abf | 2016-11-01 17:26:04 | [diff] [blame] | 129 | base::Time last_checkin; |
| 130 | base::Time next_checkin; |
avi | 2606292 | 2015-12-26 00:14:18 | [diff] [blame] | 131 | uint64_t android_id; |
Peter Beverloo | f946918 | 2018-05-03 20:46:52 | [diff] [blame^] | 132 | uint64_t android_secret; |
[email protected] | 436bcb8 | 2014-04-18 00:40:57 | [diff] [blame] | 133 | std::vector<std::string> registered_app_ids; |
| 134 | int send_queue_size; |
| 135 | int resend_queue_size; |
| 136 | |
[email protected] | 5da9380 | 2014-05-24 01:35:01 | [diff] [blame] | 137 | RecordedActivities recorded_activities; |
[email protected] | 3560181 | 2014-03-07 19:52:43 | [diff] [blame] | 138 | }; |
| 139 | |
fgorski | c104731 | 2014-09-04 16:48:54 | [diff] [blame] | 140 | // Information about account. |
| 141 | struct AccountTokenInfo { |
| 142 | std::string account_id; |
| 143 | std::string email; |
| 144 | std::string access_token; |
| 145 | }; |
| 146 | |
[email protected] | e4097c8 | 2013-11-08 00:16:12 | [diff] [blame] | 147 | // A delegate interface that allows the GCMClient instance to interact with |
| 148 | // its caller, i.e. notifying asynchronous event. |
| 149 | class Delegate { |
| 150 | public: |
[email protected] | e4097c8 | 2013-11-08 00:16:12 | [diff] [blame] | 151 | // Called when the registration completed successfully or an error occurs. |
jianli | 7a0c9b6 | 2015-05-26 23:24:47 | [diff] [blame] | 152 | // |registration_info|: the specific information required for the |
| 153 | // registration. |
[email protected] | e4097c8 | 2013-11-08 00:16:12 | [diff] [blame] | 154 | // |registration_id|: non-empty if the registration completed successfully. |
| 155 | // |result|: the type of the error if an error occured, success otherwise. |
jianli | 7a0c9b6 | 2015-05-26 23:24:47 | [diff] [blame] | 156 | virtual void OnRegisterFinished( |
| 157 | const linked_ptr<RegistrationInfo>& registration_info, |
| 158 | const std::string& registration_id, |
| 159 | Result result) = 0; |
[email protected] | e4097c8 | 2013-11-08 00:16:12 | [diff] [blame] | 160 | |
[email protected] | e400704 | 2014-02-15 20:34:28 | [diff] [blame] | 161 | // Called when the unregistration completed. |
jianli | 7a0c9b6 | 2015-05-26 23:24:47 | [diff] [blame] | 162 | // |registration_info|: the specific information required for the |
| 163 | // registration. |
[email protected] | 0e88e1d1 | 2014-03-19 06:53:08 | [diff] [blame] | 164 | // |result|: result of the unregistration. |
jianli | 7a0c9b6 | 2015-05-26 23:24:47 | [diff] [blame] | 165 | virtual void OnUnregisterFinished( |
| 166 | const linked_ptr<RegistrationInfo>& registration_info, |
| 167 | GCMClient::Result result) = 0; |
[email protected] | e400704 | 2014-02-15 20:34:28 | [diff] [blame] | 168 | |
[email protected] | e4097c8 | 2013-11-08 00:16:12 | [diff] [blame] | 169 | // Called when the message is scheduled to send successfully or an error |
| 170 | // occurs. |
| 171 | // |app_id|: application ID. |
| 172 | // |message_id|: ID of the message being sent. |
| 173 | // |result|: the type of the error if an error occured, success otherwise. |
| 174 | virtual void OnSendFinished(const std::string& app_id, |
| 175 | const std::string& message_id, |
| 176 | Result result) = 0; |
| 177 | |
| 178 | // Called when a message has been received. |
| 179 | // |app_id|: application ID. |
[email protected] | e4097c8 | 2013-11-08 00:16:12 | [diff] [blame] | 180 | // |message|: message received. |
| 181 | virtual void OnMessageReceived(const std::string& app_id, |
[email protected] | e4097c8 | 2013-11-08 00:16:12 | [diff] [blame] | 182 | const IncomingMessage& message) = 0; |
| 183 | |
| 184 | // Called when some messages have been deleted from the server. |
| 185 | // |app_id|: application ID. |
| 186 | virtual void OnMessagesDeleted(const std::string& app_id) = 0; |
| 187 | |
| 188 | // Called when a message failed to send to the server. |
| 189 | // |app_id|: application ID. |
[email protected] | c6fe36b | 2014-03-11 10:58:12 | [diff] [blame] | 190 | // |send_error_detials|: Details of the send error event, like mesasge ID. |
| 191 | virtual void OnMessageSendError( |
| 192 | const std::string& app_id, |
| 193 | const SendErrorDetails& send_error_details) = 0; |
[email protected] | e4097c8 | 2013-11-08 00:16:12 | [diff] [blame] | 194 | |
[email protected] | 292af2b2 | 2014-08-06 19:42:45 | [diff] [blame] | 195 | // Called when a message was acknowledged by the GCM server. |
| 196 | // |app_id|: application ID. |
| 197 | // |message_id|: ID of the acknowledged message. |
| 198 | virtual void OnSendAcknowledged(const std::string& app_id, |
| 199 | const std::string& message_id) = 0; |
| 200 | |
[email protected] | 86625df | 2014-01-31 03:47:58 | [diff] [blame] | 201 | // Called when the GCM becomes ready. To get to this state, GCMClient |
| 202 | // finished loading from the GCM store and retrieved the device check-in |
| 203 | // from the server if it hadn't yet. |
fgorski | d578c18b | 2014-09-24 23:40:17 | [diff] [blame] | 204 | // |account_mappings|: a persisted list of accounts mapped to this GCM |
| 205 | // client. |
fgorski | 5df10170 | 2014-10-28 02:09:31 | [diff] [blame] | 206 | // |last_token_fetch_time|: time of a last successful token fetch. |
| 207 | virtual void OnGCMReady(const std::vector<AccountMapping>& account_mappings, |
| 208 | const base::Time& last_token_fetch_time) = 0; |
[email protected] | 7de7880 | 2014-05-10 19:49:40 | [diff] [blame] | 209 | |
| 210 | // Called when activities are being recorded and a new activity has just |
| 211 | // been recorded. |
| 212 | virtual void OnActivityRecorded() = 0; |
[email protected] | fc6078a | 2014-06-14 08:28:43 | [diff] [blame] | 213 | |
| 214 | // Called when a new connection is established and a successful handshake |
| 215 | // has been performed. |
| 216 | virtual void OnConnected(const net::IPEndPoint& ip_endpoint) = 0; |
| 217 | |
| 218 | // Called when the connection is interrupted. |
| 219 | virtual void OnDisconnected() = 0; |
johnme | 93ec793 | 2016-11-17 14:26:58 | [diff] [blame] | 220 | |
| 221 | // Called when the GCM store is reset (e.g. due to corruption), which |
| 222 | // changes the device ID, invalidating all prior registrations. |
| 223 | virtual void OnStoreReset() = 0; |
[email protected] | e4097c8 | 2013-11-08 00:16:12 | [diff] [blame] | 224 | }; |
| 225 | |
[email protected] | 0db11822 | 2014-01-22 01:37:59 | [diff] [blame] | 226 | GCMClient(); |
| 227 | virtual ~GCMClient(); |
[email protected] | 1b1c3cd | 2013-12-17 18:40:04 | [diff] [blame] | 228 | |
[email protected] | d3a4b2e | 2014-02-27 13:46:54 | [diff] [blame] | 229 | // Begins initialization of the GCM Client. This will not trigger a |
| 230 | // connection. |
[email protected] | 8ad8051 | 2014-05-23 09:40:47 | [diff] [blame] | 231 | // |chrome_build_info|: chrome info, i.e., version, channel and etc. |
[email protected] | 5799d05 | 2014-02-12 20:47:39 | [diff] [blame] | 232 | // |store_path|: path to the GCM store. |
| 233 | // |blocking_task_runner|: for running blocking file tasks. |
mmenke | e65e7af | 2015-10-13 17:16:42 | [diff] [blame] | 234 | // |url_request_context_getter|: for url requests. The GCMClient must be |
| 235 | // deleted before the Getter's underlying URLRequestContext. |
[email protected] | 5799d05 | 2014-02-12 20:47:39 | [diff] [blame] | 236 | // |delegate|: the delegate whose methods will be called asynchronously in |
mmenke | e65e7af | 2015-10-13 17:16:42 | [diff] [blame] | 237 | // response to events and messages. |
[email protected] | e2a4a801 | 2014-02-07 22:32:52 | [diff] [blame] | 238 | virtual void Initialize( |
[email protected] | 8ad8051 | 2014-05-23 09:40:47 | [diff] [blame] | 239 | const ChromeBuildInfo& chrome_build_info, |
[email protected] | e2a4a801 | 2014-02-07 22:32:52 | [diff] [blame] | 240 | const base::FilePath& store_path, |
| 241 | const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, |
| 242 | const scoped_refptr<net::URLRequestContextGetter>& |
[email protected] | 5799d05 | 2014-02-12 20:47:39 | [diff] [blame] | 243 | url_request_context_getter, |
dcheng | a77e28eb | 2016-04-21 21:34:37 | [diff] [blame] | 244 | std::unique_ptr<Encryptor> encryptor, |
[email protected] | 5799d05 | 2014-02-12 20:47:39 | [diff] [blame] | 245 | Delegate* delegate) = 0; |
[email protected] | e2a4a801 | 2014-02-07 22:32:52 | [diff] [blame] | 246 | |
jianli | f3e52af4 | 2015-01-21 23:18:47 | [diff] [blame] | 247 | // This will initiate the GCM connection only if |start_mode| means to start |
| 248 | // the GCM immediately or the GCM registration records are found in the store. |
| 249 | // Note that it is OK to call Start multiple times and the implementation |
| 250 | // should handle it gracefully. |
| 251 | virtual void Start(StartMode start_mode) = 0; |
[email protected] | d3a4b2e | 2014-02-27 13:46:54 | [diff] [blame] | 252 | |
[email protected] | 21fee548 | 2014-03-05 00:57:15 | [diff] [blame] | 253 | // Stops using the GCM service. This will not erase the persisted data. |
| 254 | virtual void Stop() = 0; |
| 255 | |
jianli | 7a0c9b6 | 2015-05-26 23:24:47 | [diff] [blame] | 256 | // Registers with the server to access the provided service. |
| 257 | // Delegate::OnRegisterFinished will be called asynchronously upon completion. |
| 258 | // |registration_info|: the specific information required for the |
| 259 | // registration. For GCM, it will contain app id and |
| 260 | // sender IDs. For InstanceID, it will contain app_id, |
| 261 | // authorized entity and scope. |
| 262 | virtual void Register( |
| 263 | const linked_ptr<RegistrationInfo>& registration_info) = 0; |
[email protected] | e4097c8 | 2013-11-08 00:16:12 | [diff] [blame] | 264 | |
johnme | 6576ecf | 2017-04-03 19:26:28 | [diff] [blame] | 265 | // Checks that the provided |registration_id| (aka token for Instance ID |
| 266 | // registrations) matches the stored registration info. Also checks sender IDs |
| 267 | // match for GCM registrations. |
| 268 | virtual bool ValidateRegistration( |
| 269 | const linked_ptr<RegistrationInfo>& registration_info, |
| 270 | const std::string& registration_id) = 0; |
| 271 | |
jianli | 7a0c9b6 | 2015-05-26 23:24:47 | [diff] [blame] | 272 | // Unregisters from the server to stop accessing the provided service. |
[email protected] | e4097c8 | 2013-11-08 00:16:12 | [diff] [blame] | 273 | // Delegate::OnUnregisterFinished will be called asynchronously upon |
| 274 | // completion. |
jianli | 7a0c9b6 | 2015-05-26 23:24:47 | [diff] [blame] | 275 | // |registration_info|: the specific information required for the |
| 276 | // registration. For GCM, it will contain app id (sender |
| 277 | // IDs can be ingored). For InstanceID, it will contain |
| 278 | // app id, authorized entity and scope. |
| 279 | virtual void Unregister( |
| 280 | const linked_ptr<RegistrationInfo>& registration_info) = 0; |
[email protected] | e4097c8 | 2013-11-08 00:16:12 | [diff] [blame] | 281 | |
| 282 | // Sends a message to a given receiver. Delegate::OnSendFinished will be |
| 283 | // called asynchronously upon completion. |
[email protected] | e4097c8 | 2013-11-08 00:16:12 | [diff] [blame] | 284 | // |app_id|: application ID. |
| 285 | // |receiver_id|: registration ID of the receiver party. |
| 286 | // |message|: message to be sent. |
[email protected] | 5799d05 | 2014-02-12 20:47:39 | [diff] [blame] | 287 | virtual void Send(const std::string& app_id, |
[email protected] | e4097c8 | 2013-11-08 00:16:12 | [diff] [blame] | 288 | const std::string& receiver_id, |
| 289 | const OutgoingMessage& message) = 0; |
[email protected] | 3560181 | 2014-03-07 19:52:43 | [diff] [blame] | 290 | |
peter | 266a2aa4 | 2016-02-19 18:51:39 | [diff] [blame] | 291 | // Records a decryption failure due to |result| for the |app_id|. |
Peter Beverloo | a376e98c | 2017-06-27 15:55:37 | [diff] [blame] | 292 | virtual void RecordDecryptionFailure(const std::string& app_id, |
| 293 | GCMDecryptionResult result) = 0; |
peter | ee284ba5 | 2016-02-01 11:53:28 | [diff] [blame] | 294 | |
[email protected] | 436bcb8 | 2014-04-18 00:40:57 | [diff] [blame] | 295 | // Enables or disables internal activity recording. |
| 296 | virtual void SetRecording(bool recording) = 0; |
| 297 | |
| 298 | // Clear all recorded GCM activity logs. |
| 299 | virtual void ClearActivityLogs() = 0; |
| 300 | |
[email protected] | 3560181 | 2014-03-07 19:52:43 | [diff] [blame] | 301 | // Gets internal states and statistics. |
| 302 | virtual GCMStatistics GetStatistics() const = 0; |
[email protected] | 7df5ef2 | 2014-07-17 07:35:58 | [diff] [blame] | 303 | |
| 304 | // Sets a list of accounts with OAuth2 tokens for the next checkin. |
fgorski | 58b9dfc | 2014-09-29 16:46:18 | [diff] [blame] | 305 | // |account_tokens|: list of email addresses, account IDs and OAuth2 access |
| 306 | // tokens. |
| 307 | virtual void SetAccountTokens( |
| 308 | const std::vector<AccountTokenInfo>& account_tokens) = 0; |
[email protected] | 72d4f25 | 2014-08-20 22:34:28 | [diff] [blame] | 309 | |
| 310 | // Persists the |account_mapping| in the store. |
| 311 | virtual void UpdateAccountMapping(const AccountMapping& account_mapping) = 0; |
| 312 | |
| 313 | // Removes the account mapping related to |account_id| from the persistent |
| 314 | // store. |
| 315 | virtual void RemoveAccountMapping(const std::string& account_id) = 0; |
fgorski | 5df10170 | 2014-10-28 02:09:31 | [diff] [blame] | 316 | |
| 317 | // Sets last token fetch time in persistent store. |
| 318 | virtual void SetLastTokenFetchTime(const base::Time& time) = 0; |
chirantan | 192a921 | 2014-12-06 03:30:45 | [diff] [blame] | 319 | |
| 320 | // Updates the timer used by the HeartbeatManager for sending heartbeats. |
dcheng | a77e28eb | 2016-04-21 21:34:37 | [diff] [blame] | 321 | virtual void UpdateHeartbeatTimer(std::unique_ptr<base::Timer> timer) = 0; |
jianli | 10018b2d | 2015-05-11 21:14:13 | [diff] [blame] | 322 | |
| 323 | // Adds the Instance ID data for a specific app to the persistent store. |
| 324 | virtual void AddInstanceIDData(const std::string& app_id, |
jianli | 7a0c9b6 | 2015-05-26 23:24:47 | [diff] [blame] | 325 | const std::string& instance_id, |
| 326 | const std::string& extra_data) = 0; |
jianli | 10018b2d | 2015-05-11 21:14:13 | [diff] [blame] | 327 | |
| 328 | // Removes the Instance ID data for a specific app from the persistent store. |
| 329 | virtual void RemoveInstanceIDData(const std::string& app_id) = 0; |
| 330 | |
| 331 | // Retrieves the Instance ID data for a specific app from the persistent |
| 332 | // store. |
jianli | 7a0c9b6 | 2015-05-26 23:24:47 | [diff] [blame] | 333 | virtual void GetInstanceIDData(const std::string& app_id, |
| 334 | std::string* instance_id, |
| 335 | std::string* extra_data) = 0; |
fgorski | 2275446 | 2015-05-14 00:05:22 | [diff] [blame] | 336 | |
| 337 | // Gets and sets custom heartbeat interval for the MCS connection. |
| 338 | // |scope| is used to identify the component that requests a custom interval |
| 339 | // to be set, and allows that component to later revoke the setting. It should |
| 340 | // be unique. |
| 341 | virtual void AddHeartbeatInterval(const std::string& scope, |
| 342 | int interval_ms) = 0; |
| 343 | virtual void RemoveHeartbeatInterval(const std::string& scope) = 0; |
[email protected] | e4097c8 | 2013-11-08 00:16:12 | [diff] [blame] | 344 | }; |
| 345 | |
| 346 | } // namespace gcm |
| 347 | |
[email protected] | cd57f37 | 2014-06-09 17:13:06 | [diff] [blame] | 348 | #endif // COMPONENTS_GCM_DRIVER_GCM_CLIENT_H_ |