| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 const OutgoingMessage& message, | 134 const OutgoingMessage& message, |
| 135 const SendCallback& callback); | 135 const SendCallback& callback); |
| 136 | 136 |
| 137 // Get the public encryption key and the authentication secret associated with | 137 // Get the public encryption key and the authentication secret associated with |
| 138 // |app_id|. If none have been associated with |app_id| yet, they will be | 138 // |app_id|. If none have been associated with |app_id| yet, they will be |
| 139 // created. The |callback| will be invoked when it is available. Only use with | 139 // created. The |callback| will be invoked when it is available. Only use with |
| 140 // GCM registrations; use InstanceID::GetEncryptionInfo for InstanceID tokens. | 140 // GCM registrations; use InstanceID::GetEncryptionInfo for InstanceID tokens. |
| 141 void GetEncryptionInfo(const std::string& app_id, | 141 void GetEncryptionInfo(const std::string& app_id, |
| 142 const GetEncryptionInfoCallback& callback); | 142 const GetEncryptionInfoCallback& callback); |
| 143 | 143 |
| 144 // Send a message to GCM with information about the final status of a |
| 145 // previously received message. This can berun as a result of a callback being |
| 146 // executed from an AppHandler. |
| 147 void SendMessageReceipt(const std::string& message_id, |
| 148 const std::string& app_id, |
| 149 int status); |
| 150 |
| 144 const GCMAppHandlerMap& app_handlers() const { return app_handlers_; } | 151 const GCMAppHandlerMap& app_handlers() const { return app_handlers_; } |
| 145 | 152 |
| 146 // This method must be called before destroying the GCMDriver. Once it has | 153 // This method must be called before destroying the GCMDriver. Once it has |
| 147 // been called, no other GCMDriver methods may be used. | 154 // been called, no other GCMDriver methods may be used. |
| 148 virtual void Shutdown(); | 155 virtual void Shutdown(); |
| 149 | 156 |
| 150 // Called when the user signs in to or out of a GAIA account. | 157 // Called when the user signs in to or out of a GAIA account. |
| 151 virtual void OnSignedIn() = 0; | 158 virtual void OnSignedIn() = 0; |
| 152 virtual void OnSignedOut() = 0; | 159 virtual void OnSignedOut() = 0; |
| 153 | 160 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 // works in context of a signed in entity (e.g. browser profile where user is | 199 // works in context of a signed in entity (e.g. browser profile where user is |
| 193 // signed into sync). | 200 // signed into sync). |
| 194 // |account_tokens|: list of email addresses, account IDs and OAuth2 access | 201 // |account_tokens|: list of email addresses, account IDs and OAuth2 access |
| 195 // tokens. | 202 // tokens. |
| 196 virtual void SetAccountTokens( | 203 virtual void SetAccountTokens( |
| 197 const std::vector<GCMClient::AccountTokenInfo>& account_tokens) = 0; | 204 const std::vector<GCMClient::AccountTokenInfo>& account_tokens) = 0; |
| 198 | 205 |
| 199 // Updates the |account_mapping| information in persistent store. | 206 // Updates the |account_mapping| information in persistent store. |
| 200 virtual void UpdateAccountMapping(const AccountMapping& account_mapping) = 0; | 207 virtual void UpdateAccountMapping(const AccountMapping& account_mapping) = 0; |
| 201 | 208 |
| 202 // Removes the account mapping information reated to |account_id| from | 209 // Removes the account mapping information related to |account_id| from |
| 203 // persistent store. | 210 // persistent store. |
| 204 virtual void RemoveAccountMapping(const std::string& account_id) = 0; | 211 virtual void RemoveAccountMapping(const std::string& account_id) = 0; |
| 205 | 212 |
| 206 // Getter and setter of last token fetch time. | 213 // Getter and setter of last token fetch time. |
| 207 virtual base::Time GetLastTokenFetchTime() = 0; | 214 virtual base::Time GetLastTokenFetchTime() = 0; |
| 208 virtual void SetLastTokenFetchTime(const base::Time& time) = 0; | 215 virtual void SetLastTokenFetchTime(const base::Time& time) = 0; |
| 209 | 216 |
| 210 // Sets whether or not GCM should try to wake the system from suspend in order | 217 // Sets whether or not GCM should try to wake the system from suspend in order |
| 211 // to send a heartbeat message. | 218 // to send a heartbeat message. |
| 212 virtual void WakeFromSuspendForHeartbeat(bool wake) = 0; | 219 virtual void WakeFromSuspendForHeartbeat(bool wake) = 0; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 const IncomingMessage& message); | 315 const IncomingMessage& message); |
| 309 | 316 |
| 310 // Called after unregistration completes in order to trigger the pending | 317 // Called after unregistration completes in order to trigger the pending |
| 311 // registration. | 318 // registration. |
| 312 void RegisterAfterUnregister( | 319 void RegisterAfterUnregister( |
| 313 const std::string& app_id, | 320 const std::string& app_id, |
| 314 const std::vector<std::string>& normalized_sender_ids, | 321 const std::vector<std::string>& normalized_sender_ids, |
| 315 const UnregisterCallback& unregister_callback, | 322 const UnregisterCallback& unregister_callback, |
| 316 GCMClient::Result result); | 323 GCMClient::Result result); |
| 317 | 324 |
| 325 void SendMessageReceiptCallback(const std::string& message_id, |
| 326 GCMClient::Result result); |
| 327 |
| 318 // Callback map (from app_id to callback) for Register. | 328 // Callback map (from app_id to callback) for Register. |
| 319 std::map<std::string, RegisterCallback> register_callbacks_; | 329 std::map<std::string, RegisterCallback> register_callbacks_; |
| 320 | 330 |
| 321 // Callback map (from app_id to callback) for Unregister. | 331 // Callback map (from app_id to callback) for Unregister. |
| 322 std::map<std::string, UnregisterCallback> unregister_callbacks_; | 332 std::map<std::string, UnregisterCallback> unregister_callbacks_; |
| 323 | 333 |
| 324 // Callback map (from <app_id, message_id> to callback) for Send. | 334 // Callback map (from <app_id, message_id> to callback) for Send. |
| 325 std::map<std::pair<std::string, std::string>, SendCallback> send_callbacks_; | 335 std::map<std::pair<std::string, std::string>, SendCallback> send_callbacks_; |
| 326 | 336 |
| 327 // The encryption provider, used for key management and decryption of | 337 // The encryption provider, used for key management and decryption of |
| 328 // encrypted, incoming messages. | 338 // encrypted, incoming messages. |
| 329 GCMEncryptionProvider encryption_provider_; | 339 GCMEncryptionProvider encryption_provider_; |
| 330 | 340 |
| 331 // App handler map (from app_id to handler pointer). | 341 // App handler map (from app_id to handler pointer). |
| 332 // The handler is not owned. | 342 // The handler is not owned. |
| 333 GCMAppHandlerMap app_handlers_; | 343 GCMAppHandlerMap app_handlers_; |
| 334 | 344 |
| 335 // The default handler when no app handler can be found in the map. | 345 // The default handler when no app handler can be found in the map. |
| 336 DefaultGCMAppHandler default_app_handler_; | 346 DefaultGCMAppHandler default_app_handler_; |
| 337 | 347 |
| 338 base::WeakPtrFactory<GCMDriver> weak_ptr_factory_; | 348 base::WeakPtrFactory<GCMDriver> weak_ptr_factory_; |
| 339 | 349 |
| 340 DISALLOW_COPY_AND_ASSIGN(GCMDriver); | 350 DISALLOW_COPY_AND_ASSIGN(GCMDriver); |
| 341 }; | 351 }; |
| 342 | 352 |
| 343 } // namespace gcm | 353 } // namespace gcm |
| 344 | 354 |
| 345 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ | 355 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ |
| OLD | NEW |