Chromium Code Reviews| 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_DRIVER_H_ | 5 #ifndef COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ |
| 6 #define COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ | 6 #define COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 // instead multiple simultaneous registrations are allowed. | 102 // instead multiple simultaneous registrations are allowed. |
| 103 // |app_id|: application ID. | 103 // |app_id|: application ID. |
| 104 // |sender_ids|: list of IDs of the servers that are allowed to send the | 104 // |sender_ids|: list of IDs of the servers that are allowed to send the |
| 105 // messages to the application. These IDs are assigned by the | 105 // messages to the application. These IDs are assigned by the |
| 106 // Google API Console. | 106 // Google API Console. |
| 107 // |callback|: to be called once the asynchronous operation is done. | 107 // |callback|: to be called once the asynchronous operation is done. |
| 108 void Register(const std::string& app_id, | 108 void Register(const std::string& app_id, |
| 109 const std::vector<std::string>& sender_ids, | 109 const std::vector<std::string>& sender_ids, |
| 110 const RegisterCallback& callback); | 110 const RegisterCallback& callback); |
| 111 | 111 |
| 112 // Unregisters all sender_ids for an app. Only works on non-Android. | 112 // Unregisters all sender_ids for an app. Only works on non-Android. Will also |
| 113 // remove any encryption keys associated with the |app_id|. | |
| 113 // |app_id|: application ID. | 114 // |app_id|: application ID. |
| 114 // |callback|: to be called once the asynchronous operation is done. | 115 // |callback|: to be called once the asynchronous operation is done. |
| 115 void Unregister(const std::string& app_id, | 116 void Unregister(const std::string& app_id, |
| 116 const UnregisterCallback& callback); | 117 const UnregisterCallback& callback); |
| 117 | 118 |
| 118 // Unregisters an (app_id, sender_id) pair from using GCM. Only works on | 119 // Unregisters an (app_id, sender_id) pair from using GCM. Only works on |
| 119 // Android. | 120 // Android. Will also remove any encryption keys associated with the |app_id|. |
| 120 // TODO(jianli): Switch to using GCM's unsubscribe API. | 121 // TODO(jianli): Switch to using GCM's unsubscribe API. |
| 121 // |app_id|: application ID. | 122 // |app_id|: application ID. |
| 122 // |sender_id|: the sender ID that was passed when registering. | 123 // |sender_id|: the sender ID that was passed when registering. |
| 123 // |callback|: to be called once the asynchronous operation is done. | 124 // |callback|: to be called once the asynchronous operation is done. |
| 124 void UnregisterWithSenderId(const std::string& app_id, | 125 void UnregisterWithSenderId(const std::string& app_id, |
| 125 const std::string& sender_id, | 126 const std::string& sender_id, |
| 126 const UnregisterCallback& callback); | 127 const UnregisterCallback& callback); |
| 127 | 128 |
| 128 // Sends a message to a given receiver. | 129 // Sends a message to a given receiver. |
| 129 // |app_id|: application ID. | 130 // |app_id|: application ID. |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 259 // Platform-specific implementation of recording message decryption failures. | 260 // Platform-specific implementation of recording message decryption failures. |
| 260 virtual void RecordDecryptionFailure( | 261 virtual void RecordDecryptionFailure( |
| 261 const std::string& app_id, | 262 const std::string& app_id, |
| 262 GCMEncryptionProvider::DecryptionFailure reason) = 0; | 263 GCMEncryptionProvider::DecryptionFailure reason) = 0; |
| 263 | 264 |
| 264 // Runs the Register callback. | 265 // Runs the Register callback. |
| 265 void RegisterFinished(const std::string& app_id, | 266 void RegisterFinished(const std::string& app_id, |
| 266 const std::string& registration_id, | 267 const std::string& registration_id, |
| 267 GCMClient::Result result); | 268 GCMClient::Result result); |
| 268 | 269 |
| 270 // To be called when a registration for |app_id| has been unregistered, having | |
| 271 // |result| as the result of the unregistration. Will remove any encryption | |
| 272 // information associated with the |app_id| and then calls UnregisterFinished. | |
| 273 void UnregisterRemoveEncryptionInfo(const std::string& app_id, | |
|
Nicolas Zea
2016/02/16 22:59:22
nit: maybe rename to RemoveEncryptionInfoAfterUnre
Peter Beverloo
2016/02/17 10:20:24
Done.
| |
| 274 GCMClient::Result result); | |
| 275 | |
| 269 // Runs the Unregister callback. | 276 // Runs the Unregister callback. |
| 270 void UnregisterFinished(const std::string& app_id, | 277 void UnregisterFinished(const std::string& app_id, GCMClient::Result result); |
| 271 GCMClient::Result result); | |
| 272 | 278 |
| 273 // Runs the Send callback. | 279 // Runs the Send callback. |
| 274 void SendFinished(const std::string& app_id, | 280 void SendFinished(const std::string& app_id, |
| 275 const std::string& message_id, | 281 const std::string& message_id, |
| 276 GCMClient::Result result); | 282 GCMClient::Result result); |
| 277 | 283 |
| 278 bool HasRegisterCallback(const std::string& app_id); | 284 bool HasRegisterCallback(const std::string& app_id); |
| 279 | 285 |
| 280 void ClearCallbacks(); | 286 void ClearCallbacks(); |
| 281 | 287 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 321 DefaultGCMAppHandler default_app_handler_; | 327 DefaultGCMAppHandler default_app_handler_; |
| 322 | 328 |
| 323 base::WeakPtrFactory<GCMDriver> weak_ptr_factory_; | 329 base::WeakPtrFactory<GCMDriver> weak_ptr_factory_; |
| 324 | 330 |
| 325 DISALLOW_COPY_AND_ASSIGN(GCMDriver); | 331 DISALLOW_COPY_AND_ASSIGN(GCMDriver); |
| 326 }; | 332 }; |
| 327 | 333 |
| 328 } // namespace gcm | 334 } // namespace gcm |
| 329 | 335 |
| 330 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ | 336 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ |
| OLD | NEW |