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

Side by Side Diff: chrome/browser/invalidation/ticl_invalidation_service.h

Issue 255443005: Remove Profile dependency from TiclInvalidationService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compilation fix. Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 CHROME_BROWSER_INVALIDATION_TICL_INVALIDATION_SERVICE_H_ 5 #ifndef CHROME_BROWSER_INVALIDATION_TICL_INVALIDATION_SERVICE_H_
6 #define CHROME_BROWSER_INVALIDATION_TICL_INVALIDATION_SERVICE_H_ 6 #define CHROME_BROWSER_INVALIDATION_TICL_INVALIDATION_SERVICE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h"
11 #include "base/macros.h"
10 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
12 #include "base/prefs/pref_change_registrar.h"
13 #include "base/threading/non_thread_safe.h" 14 #include "base/threading/non_thread_safe.h"
14 #include "base/timer/timer.h" 15 #include "base/timer/timer.h"
15 #include "base/values.h" 16 #include "base/values.h"
16 #include "chrome/browser/invalidation/invalidation_logger.h" 17 #include "chrome/browser/invalidation/invalidation_logger.h"
17 #include "chrome/browser/invalidation/invalidation_service.h" 18 #include "chrome/browser/invalidation/invalidation_service.h"
19 #include "chrome/browser/invalidation/ticl_settings_provider.h"
18 #include "components/keyed_service/core/keyed_service.h" 20 #include "components/keyed_service/core/keyed_service.h"
19 #include "components/signin/core/browser/profile_oauth2_token_service.h"
20 #include "google_apis/gaia/identity_provider.h" 21 #include "google_apis/gaia/identity_provider.h"
21 #include "google_apis/gaia/oauth2_token_service.h" 22 #include "google_apis/gaia/oauth2_token_service.h"
22 #include "net/base/backoff_entry.h" 23 #include "net/base/backoff_entry.h"
23 #include "sync/notifier/invalidation_handler.h" 24 #include "sync/notifier/invalidation_handler.h"
24 #include "sync/notifier/invalidator_registrar.h" 25 #include "sync/notifier/invalidator_registrar.h"
25 26
26 class Profile;
27
28 namespace gcm { 27 namespace gcm {
29 class GCMService; 28 class GCMService;
30 } 29 }
31 30
32 namespace net { 31 namespace net {
33 class URLRequestContextGetter; 32 class URLRequestContextGetter;
34 } 33 }
35 34
36 namespace syncer { 35 namespace syncer {
37 class InvalidationStateTracker; 36 class InvalidationStateTracker;
38 class Invalidator; 37 class Invalidator;
39 } 38 }
40 39
41 namespace invalidation { 40 namespace invalidation {
42 class GCMInvalidationBridge; 41 class GCMInvalidationBridge;
43 42
44 // This InvalidationService wraps the C++ Invalidation Client (TICL) library. 43 // This InvalidationService wraps the C++ Invalidation Client (TICL) library.
45 // It provides invalidations for desktop platforms (Win, Mac, Linux). 44 // It provides invalidations for desktop platforms (Win, Mac, Linux).
46 class TiclInvalidationService : public base::NonThreadSafe, 45 class TiclInvalidationService : public base::NonThreadSafe,
47 public InvalidationService, 46 public InvalidationService,
48 public OAuth2TokenService::Consumer, 47 public OAuth2TokenService::Consumer,
49 public OAuth2TokenService::Observer, 48 public OAuth2TokenService::Observer,
50 public IdentityProvider::Observer, 49 public IdentityProvider::Observer,
50 public TiclSettingsProvider::Observer,
51 public syncer::InvalidationHandler { 51 public syncer::InvalidationHandler {
52 public: 52 public:
53 enum InvalidationNetworkChannel { 53 enum InvalidationNetworkChannel {
54 PUSH_CLIENT_CHANNEL = 0, 54 PUSH_CLIENT_CHANNEL = 0,
55 GCM_NETWORK_CHANNEL = 1, 55 GCM_NETWORK_CHANNEL = 1,
56 56
57 // This enum is used in UMA_HISTOGRAM_ENUMERATION. Insert new values above 57 // This enum is used in UMA_HISTOGRAM_ENUMERATION. Insert new values above
58 // this line. 58 // this line.
59 NETWORK_CHANNELS_COUNT = 2 59 NETWORK_CHANNELS_COUNT = 2
60 }; 60 };
61 61
62 TiclInvalidationService( 62 TiclInvalidationService(
63 scoped_ptr<IdentityProvider> identity_provider, 63 scoped_ptr<IdentityProvider> identity_provider,
64 scoped_ptr<TiclSettingsProvider> settings_provider,
64 gcm::GCMService* gcm_service, 65 gcm::GCMService* gcm_service,
65 const scoped_refptr<net::URLRequestContextGetter>& request_context, 66 const scoped_refptr<net::URLRequestContextGetter>& request_context);
66 Profile* profile);
67 virtual ~TiclInvalidationService(); 67 virtual ~TiclInvalidationService();
68 68
69 void Init( 69 void Init(
70 scoped_ptr<syncer::InvalidationStateTracker> invalidation_state_tracker); 70 scoped_ptr<syncer::InvalidationStateTracker> invalidation_state_tracker);
71 71
72 // InvalidationService implementation. 72 // InvalidationService implementation.
73 // It is an error to have registered handlers when Shutdown() is called. 73 // It is an error to have registered handlers when Shutdown() is called.
74 virtual void RegisterInvalidationHandler( 74 virtual void RegisterInvalidationHandler(
75 syncer::InvalidationHandler* handler) OVERRIDE; 75 syncer::InvalidationHandler* handler) OVERRIDE;
76 virtual void UpdateRegisteredInvalidationIds( 76 virtual void UpdateRegisteredInvalidationIds(
(...skipping 19 matching lines...) Expand all
96 const OAuth2TokenService::Request* request, 96 const OAuth2TokenService::Request* request,
97 const GoogleServiceAuthError& error) OVERRIDE; 97 const GoogleServiceAuthError& error) OVERRIDE;
98 98
99 // OAuth2TokenService::Observer implementation 99 // OAuth2TokenService::Observer implementation
100 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE; 100 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE;
101 virtual void OnRefreshTokenRevoked(const std::string& account_id) OVERRIDE; 101 virtual void OnRefreshTokenRevoked(const std::string& account_id) OVERRIDE;
102 102
103 // IdentityProvider::Observer implementation. 103 // IdentityProvider::Observer implementation.
104 virtual void OnActiveAccountLogout() OVERRIDE; 104 virtual void OnActiveAccountLogout() OVERRIDE;
105 105
106 // TiclSettingsProvider::Observer implementation.
107 virtual void OnUseGCMChannelChanged() OVERRIDE;
108
106 // syncer::InvalidationHandler implementation. 109 // syncer::InvalidationHandler implementation.
107 virtual void OnInvalidatorStateChange( 110 virtual void OnInvalidatorStateChange(
108 syncer::InvalidatorState state) OVERRIDE; 111 syncer::InvalidatorState state) OVERRIDE;
109 virtual void OnIncomingInvalidation( 112 virtual void OnIncomingInvalidation(
110 const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE; 113 const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE;
111 virtual std::string GetOwnerName() const OVERRIDE; 114 virtual std::string GetOwnerName() const OVERRIDE;
112 115
113 // Overrides KeyedService method. 116 // Overrides KeyedService method.
114 virtual void Shutdown() OVERRIDE; 117 virtual void Shutdown() OVERRIDE;
115 118
116 protected: 119 protected:
117 // Initializes with an injected invalidator. 120 // Initializes with an injected invalidator.
118 void InitForTest( 121 void InitForTest(
119 scoped_ptr<syncer::InvalidationStateTracker> invalidation_state_tracker, 122 scoped_ptr<syncer::InvalidationStateTracker> invalidation_state_tracker,
120 syncer::Invalidator* invalidator); 123 syncer::Invalidator* invalidator);
121 124
125 private:
122 friend class TiclInvalidationServiceTestDelegate; 126 friend class TiclInvalidationServiceTestDelegate;
123 friend class TiclInvalidationServiceChannelTest; 127 friend class TiclProfileSettingsProviderTest;
124 128
125 private:
126 bool IsReadyToStart(); 129 bool IsReadyToStart();
127 bool IsStarted() const; 130 bool IsStarted() const;
128 131
129 void StartInvalidator(InvalidationNetworkChannel network_channel); 132 void StartInvalidator(InvalidationNetworkChannel network_channel);
130 void UpdateInvalidationNetworkChannel(); 133 void UpdateInvalidationNetworkChannel();
131 void UpdateInvalidatorCredentials(); 134 void UpdateInvalidatorCredentials();
132 void StopInvalidator(); 135 void StopInvalidator();
133 136
134 Profile *const profile_;
135 scoped_ptr<IdentityProvider> identity_provider_; 137 scoped_ptr<IdentityProvider> identity_provider_;
138 scoped_ptr<TiclSettingsProvider> settings_provider_;
136 139
137 scoped_ptr<syncer::InvalidatorRegistrar> invalidator_registrar_; 140 scoped_ptr<syncer::InvalidatorRegistrar> invalidator_registrar_;
138 scoped_ptr<syncer::InvalidationStateTracker> invalidation_state_tracker_; 141 scoped_ptr<syncer::InvalidationStateTracker> invalidation_state_tracker_;
139 scoped_ptr<syncer::Invalidator> invalidator_; 142 scoped_ptr<syncer::Invalidator> invalidator_;
140 143
141 // TiclInvalidationService needs to remember access token in order to 144 // TiclInvalidationService needs to remember access token in order to
142 // invalidate it with OAuth2TokenService. 145 // invalidate it with OAuth2TokenService.
143 std::string access_token_; 146 std::string access_token_;
144 147
145 // TiclInvalidationService needs to hold reference to access_token_request_ 148 // TiclInvalidationService needs to hold reference to access_token_request_
146 // for the duration of request in order to receive callbacks. 149 // for the duration of request in order to receive callbacks.
147 scoped_ptr<OAuth2TokenService::Request> access_token_request_; 150 scoped_ptr<OAuth2TokenService::Request> access_token_request_;
148 base::OneShotTimer<TiclInvalidationService> request_access_token_retry_timer_; 151 base::OneShotTimer<TiclInvalidationService> request_access_token_retry_timer_;
149 net::BackoffEntry request_access_token_backoff_; 152 net::BackoffEntry request_access_token_backoff_;
150 153
151 PrefChangeRegistrar pref_change_registrar_;
152 InvalidationNetworkChannel network_channel_type_; 154 InvalidationNetworkChannel network_channel_type_;
153 gcm::GCMService* gcm_service_; 155 gcm::GCMService* gcm_service_;
154 scoped_ptr<GCMInvalidationBridge> gcm_invalidation_bridge_; 156 scoped_ptr<GCMInvalidationBridge> gcm_invalidation_bridge_;
155 scoped_refptr<net::URLRequestContextGetter> request_context_; 157 scoped_refptr<net::URLRequestContextGetter> request_context_;
156 158
157 // The invalidation logger object we use to record state changes 159 // The invalidation logger object we use to record state changes
158 // and invalidations. 160 // and invalidations.
159 InvalidationLogger logger_; 161 InvalidationLogger logger_;
160 162
161 // Keep a copy of the important parameters used in network channel creation 163 // Keep a copy of the important parameters used in network channel creation
162 // for debugging. 164 // for debugging.
163 base::DictionaryValue network_channel_options_; 165 base::DictionaryValue network_channel_options_;
164 166
165 DISALLOW_COPY_AND_ASSIGN(TiclInvalidationService); 167 DISALLOW_COPY_AND_ASSIGN(TiclInvalidationService);
166 }; 168 };
167 169
168 } // namespace invalidation 170 } // namespace invalidation
169 171
170 #endif // CHROME_BROWSER_INVALIDATION_TICL_INVALIDATION_SERVICE_H_ 172 #endif // CHROME_BROWSER_INVALIDATION_TICL_INVALIDATION_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/invalidation/invalidation_service_factory.cc ('k') | chrome/browser/invalidation/ticl_invalidation_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698