Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(347)

Side by Side Diff: components/invalidation/gcm_invalidation_bridge.h

Issue 515763002: [GCM] Extracting GCMConnectionObserver from GCMAppHandler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing CR feedback Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_GCM_INVALIDATION_BRIDGE_H_ 5 #ifndef COMPONENTS_INVALIDATION_GCM_INVALIDATION_BRIDGE_H_
6 #define COMPONENTS_INVALIDATION_GCM_INVALIDATION_BRIDGE_H_ 6 #define COMPONENTS_INVALIDATION_GCM_INVALIDATION_BRIDGE_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/threading/non_thread_safe.h" 11 #include "base/threading/non_thread_safe.h"
12 #include "components/gcm_driver/gcm_app_handler.h" 12 #include "components/gcm_driver/gcm_app_handler.h"
13 #include "components/gcm_driver/gcm_client.h" 13 #include "components/gcm_driver/gcm_client.h"
14 #include "components/gcm_driver/gcm_connection_observer.h"
14 #include "components/invalidation/gcm_network_channel_delegate.h" 15 #include "components/invalidation/gcm_network_channel_delegate.h"
15 #include "google_apis/gaia/oauth2_token_service.h" 16 #include "google_apis/gaia/oauth2_token_service.h"
16 17
17 class IdentityProvider; 18 class IdentityProvider;
18 19
19 namespace base { 20 namespace base {
20 class SingleThreadTaskRunner; 21 class SingleThreadTaskRunner;
21 } // namespace base 22 } // namespace base
22 23
23 namespace gcm { 24 namespace gcm {
24 class GCMDriver; 25 class GCMDriver;
25 } // namespace gcm 26 } // namespace gcm
26 27
27 namespace invalidation { 28 namespace invalidation {
28 29
29 // GCMInvalidationBridge and GCMInvalidationBridge::Core implement functions 30 // GCMInvalidationBridge and GCMInvalidationBridge::Core implement functions
30 // needed for GCMNetworkChannel. GCMInvalidationBridge lives on UI thread while 31 // needed for GCMNetworkChannel. GCMInvalidationBridge lives on UI thread while
31 // Core lives on IO thread. Core implements GCMNetworkChannelDelegate and posts 32 // Core lives on IO thread. Core implements GCMNetworkChannelDelegate and posts
32 // all function calls to GCMInvalidationBridge which does actual work to perform 33 // all function calls to GCMInvalidationBridge which does actual work to perform
33 // them. 34 // them.
34 class GCMInvalidationBridge : public gcm::GCMAppHandler, 35 class GCMInvalidationBridge : public gcm::GCMAppHandler,
36 public gcm::GCMConnectionObserver,
35 public OAuth2TokenService::Consumer, 37 public OAuth2TokenService::Consumer,
36 public base::NonThreadSafe { 38 public base::NonThreadSafe {
37 public: 39 public:
38 class Core; 40 class Core;
39 41
40 GCMInvalidationBridge(gcm::GCMDriver* gcm_driver, 42 GCMInvalidationBridge(gcm::GCMDriver* gcm_driver,
41 IdentityProvider* identity_provider); 43 IdentityProvider* identity_provider);
42 virtual ~GCMInvalidationBridge(); 44 virtual ~GCMInvalidationBridge();
43 45
44 // OAuth2TokenService::Consumer implementation. 46 // OAuth2TokenService::Consumer implementation.
45 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, 47 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
46 const std::string& access_token, 48 const std::string& access_token,
47 const base::Time& expiration_time) OVERRIDE; 49 const base::Time& expiration_time) OVERRIDE;
48 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, 50 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request,
49 const GoogleServiceAuthError& error) OVERRIDE; 51 const GoogleServiceAuthError& error) OVERRIDE;
50 52
51 // gcm::GCMAppHandler implementation. 53 // gcm::GCMAppHandler implementation.
52 virtual void ShutdownHandler() OVERRIDE; 54 virtual void ShutdownHandler() OVERRIDE;
53 virtual void OnMessage( 55 virtual void OnMessage(
54 const std::string& app_id, 56 const std::string& app_id,
55 const gcm::GCMClient::IncomingMessage& message) OVERRIDE; 57 const gcm::GCMClient::IncomingMessage& message) OVERRIDE;
56 virtual void OnMessagesDeleted(const std::string& app_id) OVERRIDE; 58 virtual void OnMessagesDeleted(const std::string& app_id) OVERRIDE;
57 virtual void OnSendError( 59 virtual void OnSendError(
58 const std::string& app_id, 60 const std::string& app_id,
59 const gcm::GCMClient::SendErrorDetails& send_error_details) OVERRIDE; 61 const gcm::GCMClient::SendErrorDetails& send_error_details) OVERRIDE;
60 virtual void OnSendAcknowledged(const std::string& app_id, 62 virtual void OnSendAcknowledged(const std::string& app_id,
61 const std::string& message_id) OVERRIDE; 63 const std::string& message_id) OVERRIDE;
64
65 // gcm::GCMConnectionObserver implementation.
62 virtual void OnConnected(const net::IPEndPoint& ip_endpoint) OVERRIDE; 66 virtual void OnConnected(const net::IPEndPoint& ip_endpoint) OVERRIDE;
63 virtual void OnDisconnected() OVERRIDE; 67 virtual void OnDisconnected() OVERRIDE;
64 68
65 scoped_ptr<syncer::GCMNetworkChannelDelegate> CreateDelegate(); 69 scoped_ptr<syncer::GCMNetworkChannelDelegate> CreateDelegate();
66 70
67 void CoreInitializationDone( 71 void CoreInitializationDone(
68 base::WeakPtr<Core> core, 72 base::WeakPtr<Core> core,
69 scoped_refptr<base::SingleThreadTaskRunner> core_thread_task_runner); 73 scoped_refptr<base::SingleThreadTaskRunner> core_thread_task_runner);
70 74
71 // Functions reflecting GCMNetworkChannelDelegate interface. These are called 75 // Functions reflecting GCMNetworkChannelDelegate interface. These are called
(...skipping 25 matching lines...) Expand all
97 bool subscribed_for_incoming_messages_; 101 bool subscribed_for_incoming_messages_;
98 102
99 base::WeakPtrFactory<GCMInvalidationBridge> weak_factory_; 103 base::WeakPtrFactory<GCMInvalidationBridge> weak_factory_;
100 104
101 DISALLOW_COPY_AND_ASSIGN(GCMInvalidationBridge); 105 DISALLOW_COPY_AND_ASSIGN(GCMInvalidationBridge);
102 }; 106 };
103 107
104 } // namespace invalidation 108 } // namespace invalidation
105 109
106 #endif // COMPONENTS_INVALIDATION_GCM_INVALIDATION_BRIDGE_H_ 110 #endif // COMPONENTS_INVALIDATION_GCM_INVALIDATION_BRIDGE_H_
OLDNEW
« no previous file with comments | « components/gcm_driver/gcm_driver_desktop_unittest.cc ('k') | components/invalidation/gcm_invalidation_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698