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_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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/memory/linked_ptr.h" | 15 #include "base/memory/linked_ptr.h" |
| 16 #include "components/gcm_driver/common/gcm_messages.h" | 16 #include "components/gcm_driver/common/gcm_messages.h" |
| 17 #include "components/gcm_driver/crypto/gcm_encryption_provider.h" | 17 #include "components/gcm_driver/crypto/gcm_encryption_provider.h" |
| 18 #include "components/gcm_driver/gcm_activity.h" | 18 #include "components/gcm_driver/gcm_activity.h" |
| 19 #include "components/gcm_driver/gcm_message_status.h" | |
| 19 #include "components/gcm_driver/registration_info.h" | 20 #include "components/gcm_driver/registration_info.h" |
| 20 | 21 |
| 21 template <class T> class scoped_refptr; | 22 template <class T> class scoped_refptr; |
| 22 | 23 |
| 23 namespace base { | 24 namespace base { |
| 24 class FilePath; | 25 class FilePath; |
| 25 class SequencedTaskRunner; | 26 class SequencedTaskRunner; |
| 26 class Timer; | 27 class Timer; |
| 27 } | 28 } |
| 28 | 29 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 RecordedActivities recorded_activities; | 133 RecordedActivities recorded_activities; |
| 133 }; | 134 }; |
| 134 | 135 |
| 135 // Information about account. | 136 // Information about account. |
| 136 struct AccountTokenInfo { | 137 struct AccountTokenInfo { |
| 137 std::string account_id; | 138 std::string account_id; |
| 138 std::string email; | 139 std::string email; |
| 139 std::string access_token; | 140 std::string access_token; |
| 140 }; | 141 }; |
| 141 | 142 |
| 143 typedef base::Callback<void(GCMMessageStatus)> MessageReceiptCallback; | |
|
Peter Beverloo
2017/01/13 01:46:11
Architecturally, why did you choose to keep this i
Peter Beverloo
2017/01/13 01:46:11
nit: C++11ize
using MessageReceiptCallback = base
harkness
2017/01/19 13:20:41
Done.
harkness
2017/01/19 13:20:41
The main architectural reason was to have it in th
| |
| 144 | |
| 142 // A delegate interface that allows the GCMClient instance to interact with | 145 // A delegate interface that allows the GCMClient instance to interact with |
| 143 // its caller, i.e. notifying asynchronous event. | 146 // its caller, i.e. notifying asynchronous event. |
| 144 class Delegate { | 147 class Delegate { |
| 145 public: | 148 public: |
| 146 // Called when the registration completed successfully or an error occurs. | 149 // Called when the registration completed successfully or an error occurs. |
| 147 // |registration_info|: the specific information required for the | 150 // |registration_info|: the specific information required for the |
| 148 // registration. | 151 // registration. |
| 149 // |registration_id|: non-empty if the registration completed successfully. | 152 // |registration_id|: non-empty if the registration completed successfully. |
| 150 // |result|: the type of the error if an error occured, success otherwise. | 153 // |result|: the type of the error if an error occured, success otherwise. |
| 151 virtual void OnRegisterFinished( | 154 virtual void OnRegisterFinished( |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 166 // |app_id|: application ID. | 169 // |app_id|: application ID. |
| 167 // |message_id|: ID of the message being sent. | 170 // |message_id|: ID of the message being sent. |
| 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 OnSendFinished(const std::string& app_id, | 172 virtual void OnSendFinished(const std::string& app_id, |
| 170 const std::string& message_id, | 173 const std::string& message_id, |
| 171 Result result) = 0; | 174 Result result) = 0; |
| 172 | 175 |
| 173 // Called when a message has been received. | 176 // Called when a message has been received. |
| 174 // |app_id|: application ID. | 177 // |app_id|: application ID. |
| 175 // |message|: message received. | 178 // |message|: message received. |
| 179 // |callback|: callback to invoke when processing the message is complete. | |
| 176 virtual void OnMessageReceived(const std::string& app_id, | 180 virtual void OnMessageReceived(const std::string& app_id, |
| 177 const IncomingMessage& message) = 0; | 181 const IncomingMessage& message, |
| 182 const MessageReceiptCallback& callback) = 0; | |
|
Peter Beverloo
2017/01/13 01:46:11
(This will largely apply to app handlers, but it's
harkness
2017/01/19 13:20:41
Done.
| |
| 178 | 183 |
| 179 // Called when some messages have been deleted from the server. | 184 // Called when some messages have been deleted from the server. |
| 180 // |app_id|: application ID. | 185 // |app_id|: application ID. |
| 181 virtual void OnMessagesDeleted(const std::string& app_id) = 0; | 186 virtual void OnMessagesDeleted(const std::string& app_id) = 0; |
| 182 | 187 |
| 183 // Called when a message failed to send to the server. | 188 // Called when a message failed to send to the server. |
| 184 // |app_id|: application ID. | 189 // |app_id|: application ID. |
| 185 // |send_error_detials|: Details of the send error event, like mesasge ID. | 190 // |send_error_detials|: Details of the send error event, like mesasge ID. |
| 186 virtual void OnMessageSendError( | 191 virtual void OnMessageSendError( |
| 187 const std::string& app_id, | 192 const std::string& app_id, |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 269 | 274 |
| 270 // Sends a message to a given receiver. Delegate::OnSendFinished will be | 275 // Sends a message to a given receiver. Delegate::OnSendFinished will be |
| 271 // called asynchronously upon completion. | 276 // called asynchronously upon completion. |
| 272 // |app_id|: application ID. | 277 // |app_id|: application ID. |
| 273 // |receiver_id|: registration ID of the receiver party. | 278 // |receiver_id|: registration ID of the receiver party. |
| 274 // |message|: message to be sent. | 279 // |message|: message to be sent. |
| 275 virtual void Send(const std::string& app_id, | 280 virtual void Send(const std::string& app_id, |
| 276 const std::string& receiver_id, | 281 const std::string& receiver_id, |
| 277 const OutgoingMessage& message) = 0; | 282 const OutgoingMessage& message) = 0; |
| 278 | 283 |
| 284 // Send a message to GCM with information about the final status of a | |
| 285 // previously received message. This can be run as a result of a callback | |
| 286 // being executed from an AppHandler. | |
| 287 virtual void SendMessageReceipt(const std::string& message_id, | |
| 288 const std::string& app_id, | |
| 289 GCMMessageStatus status) = 0; | |
|
Peter Beverloo
2017/01/13 01:46:11
This doesn't have to live in the gcm_client.h inte
harkness
2017/01/19 13:20:41
Good point! I've moved it.
| |
| 290 | |
| 279 // Records a decryption failure due to |result| for the |app_id|. | 291 // Records a decryption failure due to |result| for the |app_id|. |
| 280 virtual void RecordDecryptionFailure( | 292 virtual void RecordDecryptionFailure( |
| 281 const std::string& app_id, | 293 const std::string& app_id, |
| 282 GCMEncryptionProvider::DecryptionResult result) = 0; | 294 GCMEncryptionProvider::DecryptionResult result) = 0; |
| 283 | 295 |
| 284 // Enables or disables internal activity recording. | 296 // Enables or disables internal activity recording. |
| 285 virtual void SetRecording(bool recording) = 0; | 297 virtual void SetRecording(bool recording) = 0; |
| 286 | 298 |
| 287 // Clear all recorded GCM activity logs. | 299 // Clear all recorded GCM activity logs. |
| 288 virtual void ClearActivityLogs() = 0; | 300 virtual void ClearActivityLogs() = 0; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 328 // to be set, and allows that component to later revoke the setting. It should | 340 // to be set, and allows that component to later revoke the setting. It should |
| 329 // be unique. | 341 // be unique. |
| 330 virtual void AddHeartbeatInterval(const std::string& scope, | 342 virtual void AddHeartbeatInterval(const std::string& scope, |
| 331 int interval_ms) = 0; | 343 int interval_ms) = 0; |
| 332 virtual void RemoveHeartbeatInterval(const std::string& scope) = 0; | 344 virtual void RemoveHeartbeatInterval(const std::string& scope) = 0; |
| 333 }; | 345 }; |
| 334 | 346 |
| 335 } // namespace gcm | 347 } // namespace gcm |
| 336 | 348 |
| 337 #endif // COMPONENTS_GCM_DRIVER_GCM_CLIENT_H_ | 349 #endif // COMPONENTS_GCM_DRIVER_GCM_CLIENT_H_ |
| OLD | NEW |