| 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_INVALIDATION_IMPL_GCM_INVALIDATION_BRIDGE_H_ | 5 #ifndef COMPONENTS_INVALIDATION_IMPL_GCM_INVALIDATION_BRIDGE_H_ |
| 6 #define COMPONENTS_INVALIDATION_IMPL_GCM_INVALIDATION_BRIDGE_H_ | 6 #define COMPONENTS_INVALIDATION_IMPL_GCM_INVALIDATION_BRIDGE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/threading/non_thread_safe.h" | 13 #include "base/sequence_checker.h" |
| 14 #include "components/gcm_driver/common/gcm_messages.h" | 14 #include "components/gcm_driver/common/gcm_messages.h" |
| 15 #include "components/gcm_driver/gcm_app_handler.h" | 15 #include "components/gcm_driver/gcm_app_handler.h" |
| 16 #include "components/gcm_driver/gcm_client.h" | 16 #include "components/gcm_driver/gcm_client.h" |
| 17 #include "components/gcm_driver/gcm_connection_observer.h" | 17 #include "components/gcm_driver/gcm_connection_observer.h" |
| 18 #include "components/invalidation/impl/gcm_network_channel_delegate.h" | 18 #include "components/invalidation/impl/gcm_network_channel_delegate.h" |
| 19 #include "google_apis/gaia/oauth2_token_service.h" | 19 #include "google_apis/gaia/oauth2_token_service.h" |
| 20 | 20 |
| 21 class IdentityProvider; | 21 class IdentityProvider; |
| 22 | 22 |
| 23 namespace base { | 23 namespace base { |
| 24 class SingleThreadTaskRunner; | 24 class SingleThreadTaskRunner; |
| 25 } // namespace base | 25 } // namespace base |
| 26 | 26 |
| 27 namespace gcm { | 27 namespace gcm { |
| 28 class GCMDriver; | 28 class GCMDriver; |
| 29 } // namespace gcm | 29 } // namespace gcm |
| 30 | 30 |
| 31 namespace invalidation { | 31 namespace invalidation { |
| 32 | 32 |
| 33 // GCMInvalidationBridge and GCMInvalidationBridge::Core implement functions | 33 // GCMInvalidationBridge and GCMInvalidationBridge::Core implement functions |
| 34 // needed for GCMNetworkChannel. GCMInvalidationBridge lives on UI thread while | 34 // needed for GCMNetworkChannel. GCMInvalidationBridge lives on UI thread while |
| 35 // Core lives on IO thread. Core implements GCMNetworkChannelDelegate and posts | 35 // Core lives on IO thread. Core implements GCMNetworkChannelDelegate and posts |
| 36 // all function calls to GCMInvalidationBridge which does actual work to perform | 36 // all function calls to GCMInvalidationBridge which does actual work to perform |
| 37 // them. | 37 // them. |
| 38 class GCMInvalidationBridge : public gcm::GCMAppHandler, | 38 class GCMInvalidationBridge : public gcm::GCMAppHandler, |
| 39 public gcm::GCMConnectionObserver, | 39 public gcm::GCMConnectionObserver, |
| 40 public OAuth2TokenService::Consumer, | 40 public OAuth2TokenService::Consumer { |
| 41 public base::NonThreadSafe { | |
| 42 public: | 41 public: |
| 43 class Core; | 42 class Core; |
| 44 | 43 |
| 45 GCMInvalidationBridge(gcm::GCMDriver* gcm_driver, | 44 GCMInvalidationBridge(gcm::GCMDriver* gcm_driver, |
| 46 IdentityProvider* identity_provider); | 45 IdentityProvider* identity_provider); |
| 47 ~GCMInvalidationBridge() override; | 46 ~GCMInvalidationBridge() override; |
| 48 | 47 |
| 49 // OAuth2TokenService::Consumer implementation. | 48 // OAuth2TokenService::Consumer implementation. |
| 50 void OnGetTokenSuccess(const OAuth2TokenService::Request* request, | 49 void OnGetTokenSuccess(const OAuth2TokenService::Request* request, |
| 51 const std::string& access_token, | 50 const std::string& access_token, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 99 |
| 101 base::WeakPtr<Core> core_; | 100 base::WeakPtr<Core> core_; |
| 102 scoped_refptr<base::SingleThreadTaskRunner> core_thread_task_runner_; | 101 scoped_refptr<base::SingleThreadTaskRunner> core_thread_task_runner_; |
| 103 | 102 |
| 104 // Fields related to RequestToken function. | 103 // Fields related to RequestToken function. |
| 105 std::unique_ptr<OAuth2TokenService::Request> access_token_request_; | 104 std::unique_ptr<OAuth2TokenService::Request> access_token_request_; |
| 106 syncer::GCMNetworkChannelDelegate::RequestTokenCallback | 105 syncer::GCMNetworkChannelDelegate::RequestTokenCallback |
| 107 request_token_callback_; | 106 request_token_callback_; |
| 108 bool subscribed_for_incoming_messages_; | 107 bool subscribed_for_incoming_messages_; |
| 109 | 108 |
| 109 SEQUENCE_CHECKER(sequence_checker_); |
| 110 |
| 110 base::WeakPtrFactory<GCMInvalidationBridge> weak_factory_; | 111 base::WeakPtrFactory<GCMInvalidationBridge> weak_factory_; |
| 111 | 112 |
| 112 DISALLOW_COPY_AND_ASSIGN(GCMInvalidationBridge); | 113 DISALLOW_COPY_AND_ASSIGN(GCMInvalidationBridge); |
| 113 }; | 114 }; |
| 114 | 115 |
| 115 } // namespace invalidation | 116 } // namespace invalidation |
| 116 | 117 |
| 117 #endif // COMPONENTS_INVALIDATION_IMPL_GCM_INVALIDATION_BRIDGE_H_ | 118 #endif // COMPONENTS_INVALIDATION_IMPL_GCM_INVALIDATION_BRIDGE_H_ |
| OLD | NEW |