Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: components/gcm_driver/gcm_client.h

Issue 1137463003: Support getting and deleting token for Instance ID. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Patch to land Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/gcm_driver/fake_gcm_driver.cc ('k') | components/gcm_driver/gcm_client_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_H_ 5 #ifndef COMPONENTS_GCM_DRIVER_GCM_CLIENT_H_
6 #define COMPONENTS_GCM_DRIVER_GCM_CLIENT_H_ 6 #define COMPONENTS_GCM_DRIVER_GCM_CLIENT_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/memory/linked_ptr.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "components/gcm_driver/gcm_activity.h" 15 #include "components/gcm_driver/gcm_activity.h"
16 #include "components/gcm_driver/registration_info.h"
15 17
16 template <class T> class scoped_refptr; 18 template <class T> class scoped_refptr;
17 19
18 class GURL; 20 class GURL;
19 21
20 namespace base { 22 namespace base {
21 class FilePath; 23 class FilePath;
22 class SequencedTaskRunner; 24 class SequencedTaskRunner;
23 class Timer; 25 class Timer;
24 } 26 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 std::string account_id; 158 std::string account_id;
157 std::string email; 159 std::string email;
158 std::string access_token; 160 std::string access_token;
159 }; 161 };
160 162
161 // A delegate interface that allows the GCMClient instance to interact with 163 // A delegate interface that allows the GCMClient instance to interact with
162 // its caller, i.e. notifying asynchronous event. 164 // its caller, i.e. notifying asynchronous event.
163 class Delegate { 165 class Delegate {
164 public: 166 public:
165 // Called when the registration completed successfully or an error occurs. 167 // Called when the registration completed successfully or an error occurs.
166 // |app_id|: application ID. 168 // |registration_info|: the specific information required for the
169 // registration.
167 // |registration_id|: non-empty if the registration completed successfully. 170 // |registration_id|: non-empty if the registration completed successfully.
168 // |result|: the type of the error if an error occured, success otherwise. 171 // |result|: the type of the error if an error occured, success otherwise.
169 virtual void OnRegisterFinished(const std::string& app_id, 172 virtual void OnRegisterFinished(
170 const std::string& registration_id, 173 const linked_ptr<RegistrationInfo>& registration_info,
171 Result result) = 0; 174 const std::string& registration_id,
175 Result result) = 0;
172 176
173 // Called when the unregistration completed. 177 // Called when the unregistration completed.
174 // |app_id|: application ID. 178 // |registration_info|: the specific information required for the
179 // registration.
175 // |result|: result of the unregistration. 180 // |result|: result of the unregistration.
176 virtual void OnUnregisterFinished(const std::string& app_id, 181 virtual void OnUnregisterFinished(
177 GCMClient::Result result) = 0; 182 const linked_ptr<RegistrationInfo>& registration_info,
183 GCMClient::Result result) = 0;
178 184
179 // Called when the message is scheduled to send successfully or an error 185 // Called when the message is scheduled to send successfully or an error
180 // occurs. 186 // occurs.
181 // |app_id|: application ID. 187 // |app_id|: application ID.
182 // |message_id|: ID of the message being sent. 188 // |message_id|: ID of the message being sent.
183 // |result|: the type of the error if an error occured, success otherwise. 189 // |result|: the type of the error if an error occured, success otherwise.
184 virtual void OnSendFinished(const std::string& app_id, 190 virtual void OnSendFinished(const std::string& app_id,
185 const std::string& message_id, 191 const std::string& message_id,
186 Result result) = 0; 192 Result result) = 0;
187 193
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 257
252 // This will initiate the GCM connection only if |start_mode| means to start 258 // This will initiate the GCM connection only if |start_mode| means to start
253 // the GCM immediately or the GCM registration records are found in the store. 259 // the GCM immediately or the GCM registration records are found in the store.
254 // Note that it is OK to call Start multiple times and the implementation 260 // Note that it is OK to call Start multiple times and the implementation
255 // should handle it gracefully. 261 // should handle it gracefully.
256 virtual void Start(StartMode start_mode) = 0; 262 virtual void Start(StartMode start_mode) = 0;
257 263
258 // Stops using the GCM service. This will not erase the persisted data. 264 // Stops using the GCM service. This will not erase the persisted data.
259 virtual void Stop() = 0; 265 virtual void Stop() = 0;
260 266
261 // Registers the application for GCM. Delegate::OnRegisterFinished will be 267 // Registers with the server to access the provided service.
262 // called asynchronously upon completion. 268 // Delegate::OnRegisterFinished will be called asynchronously upon completion.
263 // |app_id|: application ID. 269 // |registration_info|: the specific information required for the
264 // |sender_ids|: list of IDs of the servers that are allowed to send the 270 // registration. For GCM, it will contain app id and
265 // messages to the application. These IDs are assigned by the 271 // sender IDs. For InstanceID, it will contain app_id,
266 // Google API Console. 272 // authorized entity and scope.
267 virtual void Register(const std::string& app_id, 273 virtual void Register(
268 const std::vector<std::string>& sender_ids) = 0; 274 const linked_ptr<RegistrationInfo>& registration_info) = 0;
269 275
270 // Unregisters the application from GCM when it is uninstalled. 276 // Unregisters from the server to stop accessing the provided service.
271 // Delegate::OnUnregisterFinished will be called asynchronously upon 277 // Delegate::OnUnregisterFinished will be called asynchronously upon
272 // completion. 278 // completion.
273 // |app_id|: application ID. 279 // |registration_info|: the specific information required for the
274 virtual void Unregister(const std::string& app_id) = 0; 280 // registration. For GCM, it will contain app id (sender
281 // IDs can be ingored). For InstanceID, it will contain
282 // app id, authorized entity and scope.
283 virtual void Unregister(
284 const linked_ptr<RegistrationInfo>& registration_info) = 0;
275 285
276 // Sends a message to a given receiver. Delegate::OnSendFinished will be 286 // Sends a message to a given receiver. Delegate::OnSendFinished will be
277 // called asynchronously upon completion. 287 // called asynchronously upon completion.
278 // |app_id|: application ID. 288 // |app_id|: application ID.
279 // |receiver_id|: registration ID of the receiver party. 289 // |receiver_id|: registration ID of the receiver party.
280 // |message|: message to be sent. 290 // |message|: message to be sent.
281 virtual void Send(const std::string& app_id, 291 virtual void Send(const std::string& app_id,
282 const std::string& receiver_id, 292 const std::string& receiver_id,
283 const OutgoingMessage& message) = 0; 293 const OutgoingMessage& message) = 0;
284 294
(...skipping 20 matching lines...) Expand all
305 virtual void RemoveAccountMapping(const std::string& account_id) = 0; 315 virtual void RemoveAccountMapping(const std::string& account_id) = 0;
306 316
307 // Sets last token fetch time in persistent store. 317 // Sets last token fetch time in persistent store.
308 virtual void SetLastTokenFetchTime(const base::Time& time) = 0; 318 virtual void SetLastTokenFetchTime(const base::Time& time) = 0;
309 319
310 // Updates the timer used by the HeartbeatManager for sending heartbeats. 320 // Updates the timer used by the HeartbeatManager for sending heartbeats.
311 virtual void UpdateHeartbeatTimer(scoped_ptr<base::Timer> timer) = 0; 321 virtual void UpdateHeartbeatTimer(scoped_ptr<base::Timer> timer) = 0;
312 322
313 // Adds the Instance ID data for a specific app to the persistent store. 323 // Adds the Instance ID data for a specific app to the persistent store.
314 virtual void AddInstanceIDData(const std::string& app_id, 324 virtual void AddInstanceIDData(const std::string& app_id,
315 const std::string& instance_id_data) = 0; 325 const std::string& instance_id,
326 const std::string& extra_data) = 0;
316 327
317 // Removes the Instance ID data for a specific app from the persistent store. 328 // Removes the Instance ID data for a specific app from the persistent store.
318 virtual void RemoveInstanceIDData(const std::string& app_id) = 0; 329 virtual void RemoveInstanceIDData(const std::string& app_id) = 0;
319 330
320 // Retrieves the Instance ID data for a specific app from the persistent 331 // Retrieves the Instance ID data for a specific app from the persistent
321 // store. 332 // store.
322 virtual std::string GetInstanceIDData(const std::string& app_id) = 0; 333 virtual void GetInstanceIDData(const std::string& app_id,
334 std::string* instance_id,
335 std::string* extra_data) = 0;
323 336
324 // Gets and sets custom heartbeat interval for the MCS connection. 337 // Gets and sets custom heartbeat interval for the MCS connection.
325 // |scope| is used to identify the component that requests a custom interval 338 // |scope| is used to identify the component that requests a custom interval
326 // to be set, and allows that component to later revoke the setting. It should 339 // to be set, and allows that component to later revoke the setting. It should
327 // be unique. 340 // be unique.
328 virtual void AddHeartbeatInterval(const std::string& scope, 341 virtual void AddHeartbeatInterval(const std::string& scope,
329 int interval_ms) = 0; 342 int interval_ms) = 0;
330 virtual void RemoveHeartbeatInterval(const std::string& scope) = 0; 343 virtual void RemoveHeartbeatInterval(const std::string& scope) = 0;
331 }; 344 };
332 345
333 } // namespace gcm 346 } // namespace gcm
334 347
335 #endif // COMPONENTS_GCM_DRIVER_GCM_CLIENT_H_ 348 #endif // COMPONENTS_GCM_DRIVER_GCM_CLIENT_H_
OLDNEW
« no previous file with comments | « components/gcm_driver/fake_gcm_driver.cc ('k') | components/gcm_driver/gcm_client_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698