| 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> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
| 17 #include "components/gcm_driver/common/gcm_messages.h" | 17 #include "components/gcm_driver/common/gcm_messages.h" |
| 18 #include "components/gcm_driver/crypto/gcm_encryption_provider.h" | 18 #include "components/gcm_driver/crypto/gcm_encryption_provider.h" |
| 19 #include "components/gcm_driver/default_gcm_app_handler.h" | 19 #include "components/gcm_driver/default_gcm_app_handler.h" |
| 20 #include "components/gcm_driver/gcm_client.h" | 20 #include "components/gcm_driver/gcm_client.h" |
| 21 #include "components/gcm_driver/gcm_message_status.h" |
| 21 | 22 |
| 22 namespace base { | 23 namespace base { |
| 23 class FilePath; | 24 class FilePath; |
| 24 class SequencedTaskRunner; | 25 class SequencedTaskRunner; |
| 25 } | 26 } |
| 26 | 27 |
| 27 namespace gcm { | 28 namespace gcm { |
| 28 | 29 |
| 29 class GCMAppHandler; | 30 class GCMAppHandler; |
| 30 class GCMConnectionObserver; | 31 class GCMConnectionObserver; |
| (...skipping 161 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 | 193 // works in context of a signed in entity (e.g. browser profile where user is |
| 193 // signed into sync). | 194 // signed into sync). |
| 194 // |account_tokens|: list of email addresses, account IDs and OAuth2 access | 195 // |account_tokens|: list of email addresses, account IDs and OAuth2 access |
| 195 // tokens. | 196 // tokens. |
| 196 virtual void SetAccountTokens( | 197 virtual void SetAccountTokens( |
| 197 const std::vector<GCMClient::AccountTokenInfo>& account_tokens) = 0; | 198 const std::vector<GCMClient::AccountTokenInfo>& account_tokens) = 0; |
| 198 | 199 |
| 199 // Updates the |account_mapping| information in persistent store. | 200 // Updates the |account_mapping| information in persistent store. |
| 200 virtual void UpdateAccountMapping(const AccountMapping& account_mapping) = 0; | 201 virtual void UpdateAccountMapping(const AccountMapping& account_mapping) = 0; |
| 201 | 202 |
| 202 // Removes the account mapping information reated to |account_id| from | 203 // Removes the account mapping information related to |account_id| from |
| 203 // persistent store. | 204 // persistent store. |
| 204 virtual void RemoveAccountMapping(const std::string& account_id) = 0; | 205 virtual void RemoveAccountMapping(const std::string& account_id) = 0; |
| 205 | 206 |
| 206 // Getter and setter of last token fetch time. | 207 // Getter and setter of last token fetch time. |
| 207 virtual base::Time GetLastTokenFetchTime() = 0; | 208 virtual base::Time GetLastTokenFetchTime() = 0; |
| 208 virtual void SetLastTokenFetchTime(const base::Time& time) = 0; | 209 virtual void SetLastTokenFetchTime(const base::Time& time) = 0; |
| 209 | 210 |
| 210 // Sets whether or not GCM should try to wake the system from suspend in order | 211 // Sets whether or not GCM should try to wake the system from suspend in order |
| 211 // to send a heartbeat message. | 212 // to send a heartbeat message. |
| 212 virtual void WakeFromSuspendForHeartbeat(bool wake) = 0; | 213 virtual void WakeFromSuspendForHeartbeat(bool wake) = 0; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 const std::string& message_id, | 284 const std::string& message_id, |
| 284 GCMClient::Result result); | 285 GCMClient::Result result); |
| 285 | 286 |
| 286 bool HasRegisterCallback(const std::string& app_id); | 287 bool HasRegisterCallback(const std::string& app_id); |
| 287 | 288 |
| 288 void ClearCallbacks(); | 289 void ClearCallbacks(); |
| 289 | 290 |
| 290 // Dispatches the OnMessage event to the app handler associated with |app_id|. | 291 // Dispatches the OnMessage event to the app handler associated with |app_id|. |
| 291 // If |message| has been encrypted, it will be decrypted asynchronously and | 292 // If |message| has been encrypted, it will be decrypted asynchronously and |
| 292 // dispatched when the decryption operation was successful. Otherwise, the | 293 // dispatched when the decryption operation was successful. Otherwise, the |
| 293 // |message| will be dispatched immediately to the handler for |app_id|. | 294 // |message| will be dispatched immediately to the handler for |app_id|. The |
| 295 // |optional_receipt_callback| must be invoked on the UI thread. |
| 294 void DispatchMessage(const std::string& app_id, | 296 void DispatchMessage(const std::string& app_id, |
| 295 const IncomingMessage& message); | 297 const IncomingMessage& message, |
| 298 const MessageReceiptCallback& optional_receipt_callback); |
| 296 | 299 |
| 297 private: | 300 private: |
| 298 // Common code shared by Unregister and UnregisterWithSenderId. | 301 // Common code shared by Unregister and UnregisterWithSenderId. |
| 299 void UnregisterInternal(const std::string& app_id, | 302 void UnregisterInternal(const std::string& app_id, |
| 300 const std::string* sender_id, | 303 const std::string* sender_id, |
| 301 const UnregisterCallback& callback); | 304 const UnregisterCallback& callback); |
| 302 | 305 |
| 303 // Dispatches the OnMessage event to the app handler associated with |app_id| | 306 // Dispatches the OnMessage event to the app handler associated with |app_id| |
| 304 // if |result| indicates that it is safe to do so, or will report a decryption | 307 // if |result| indicates that it is safe to do so, or will report a decryption |
| 305 // failure for the |app_id| otherwise. | 308 // failure for the |app_id| otherwise. |
| 306 void DispatchMessageInternal(const std::string& app_id, | 309 void DispatchMessageInternal( |
| 307 GCMEncryptionProvider::DecryptionResult result, | 310 const std::string& app_id, |
| 308 const IncomingMessage& message); | 311 const MessageReceiptCallback& optional_receipt_callback, |
| 312 GCMEncryptionProvider::DecryptionResult result, |
| 313 const IncomingMessage& message); |
| 309 | 314 |
| 310 // Called after unregistration completes in order to trigger the pending | 315 // Called after unregistration completes in order to trigger the pending |
| 311 // registration. | 316 // registration. |
| 312 void RegisterAfterUnregister( | 317 void RegisterAfterUnregister( |
| 313 const std::string& app_id, | 318 const std::string& app_id, |
| 314 const std::vector<std::string>& normalized_sender_ids, | 319 const std::vector<std::string>& normalized_sender_ids, |
| 315 const UnregisterCallback& unregister_callback, | 320 const UnregisterCallback& unregister_callback, |
| 316 GCMClient::Result result); | 321 GCMClient::Result result); |
| 317 | 322 |
| 318 // Callback map (from app_id to callback) for Register. | 323 // Callback map (from app_id to callback) for Register. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 336 DefaultGCMAppHandler default_app_handler_; | 341 DefaultGCMAppHandler default_app_handler_; |
| 337 | 342 |
| 338 base::WeakPtrFactory<GCMDriver> weak_ptr_factory_; | 343 base::WeakPtrFactory<GCMDriver> weak_ptr_factory_; |
| 339 | 344 |
| 340 DISALLOW_COPY_AND_ASSIGN(GCMDriver); | 345 DISALLOW_COPY_AND_ASSIGN(GCMDriver); |
| 341 }; | 346 }; |
| 342 | 347 |
| 343 } // namespace gcm | 348 } // namespace gcm |
| 344 | 349 |
| 345 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ | 350 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_H_ |
| OLD | NEW |