OLD | NEW |
---|---|
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/memory/ref_counted.h" | |
10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
11 #include "base/prefs/pref_change_registrar.h" | 12 #include "base/prefs/pref_change_registrar.h" |
12 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
13 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
15 #include "base/values.h" | |
dcheng
2014/04/11 19:54:00
Why is this #include here?
bartfab (slow)
2014/04/14 09:20:08
Because line 155 defines a base::DictionaryValue m
| |
14 #include "chrome/browser/invalidation/invalidation_auth_provider.h" | 16 #include "chrome/browser/invalidation/invalidation_auth_provider.h" |
15 #include "chrome/browser/invalidation/invalidation_logger.h" | 17 #include "chrome/browser/invalidation/invalidation_logger.h" |
16 #include "chrome/browser/invalidation/invalidation_service.h" | 18 #include "chrome/browser/invalidation/invalidation_service.h" |
17 #include "chrome/browser/invalidation/invalidator_storage.h" | |
18 #include "components/keyed_service/core/keyed_service.h" | 19 #include "components/keyed_service/core/keyed_service.h" |
19 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 20 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
20 #include "google_apis/gaia/oauth2_token_service.h" | 21 #include "google_apis/gaia/oauth2_token_service.h" |
21 #include "net/base/backoff_entry.h" | 22 #include "net/base/backoff_entry.h" |
22 #include "sync/notifier/invalidation_handler.h" | 23 #include "sync/notifier/invalidation_handler.h" |
23 #include "sync/notifier/invalidator_registrar.h" | 24 #include "sync/notifier/invalidator_registrar.h" |
24 | 25 |
25 class Profile; | 26 class Profile; |
26 | 27 |
28 namespace net { | |
29 class URLRequestContextGetter; | |
30 } | |
31 | |
27 namespace syncer { | 32 namespace syncer { |
33 class InvalidationStateTracker; | |
28 class Invalidator; | 34 class Invalidator; |
29 } | 35 } |
30 | 36 |
31 namespace invalidation { | 37 namespace invalidation { |
32 class GCMInvalidationBridge; | 38 class GCMInvalidationBridge; |
33 | 39 |
34 // This InvalidationService wraps the C++ Invalidation Client (TICL) library. | 40 // This InvalidationService wraps the C++ Invalidation Client (TICL) library. |
35 // It provides invalidations for desktop platforms (Win, Mac, Linux). | 41 // It provides invalidations for desktop platforms (Win, Mac, Linux). |
36 class TiclInvalidationService : public base::NonThreadSafe, | 42 class TiclInvalidationService : public base::NonThreadSafe, |
37 public InvalidationService, | 43 public InvalidationService, |
38 public OAuth2TokenService::Consumer, | 44 public OAuth2TokenService::Consumer, |
39 public OAuth2TokenService::Observer, | 45 public OAuth2TokenService::Observer, |
40 public InvalidationAuthProvider::Observer, | 46 public InvalidationAuthProvider::Observer, |
41 public syncer::InvalidationHandler { | 47 public syncer::InvalidationHandler { |
42 public: | 48 public: |
43 enum InvalidationNetworkChannel { | 49 enum InvalidationNetworkChannel { |
44 PUSH_CLIENT_CHANNEL = 0, | 50 PUSH_CLIENT_CHANNEL = 0, |
45 GCM_NETWORK_CHANNEL = 1, | 51 GCM_NETWORK_CHANNEL = 1, |
46 | 52 |
47 // This enum is used in UMA_HISTOGRAM_ENUMERATION. Insert new values above | 53 // This enum is used in UMA_HISTOGRAM_ENUMERATION. Insert new values above |
48 // this line. | 54 // this line. |
49 NETWORK_CHANNELS_COUNT = 2 | 55 NETWORK_CHANNELS_COUNT = 2 |
50 }; | 56 }; |
51 | 57 |
52 TiclInvalidationService(scoped_ptr<InvalidationAuthProvider> auth_provider, | 58 TiclInvalidationService( |
53 Profile* profile); | 59 scoped_ptr<InvalidationAuthProvider> auth_provider, |
60 const scoped_refptr<net::URLRequestContextGetter>& request_context, | |
61 scoped_ptr<syncer::InvalidationStateTracker> invalidation_state_tracker, | |
62 Profile* profile); | |
54 virtual ~TiclInvalidationService(); | 63 virtual ~TiclInvalidationService(); |
55 | 64 |
56 void Init(); | 65 void Init(); |
57 | 66 |
58 // InvalidationService implementation. | 67 // InvalidationService implementation. |
59 // It is an error to have registered handlers when Shutdown() is called. | 68 // It is an error to have registered handlers when Shutdown() is called. |
60 virtual void RegisterInvalidationHandler( | 69 virtual void RegisterInvalidationHandler( |
61 syncer::InvalidationHandler* handler) OVERRIDE; | 70 syncer::InvalidationHandler* handler) OVERRIDE; |
62 virtual void UpdateRegisteredInvalidationIds( | 71 virtual void UpdateRegisteredInvalidationIds( |
63 syncer::InvalidationHandler* handler, | 72 syncer::InvalidationHandler* handler, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 | 121 |
113 void StartInvalidator(InvalidationNetworkChannel network_channel); | 122 void StartInvalidator(InvalidationNetworkChannel network_channel); |
114 void UpdateInvalidationNetworkChannel(); | 123 void UpdateInvalidationNetworkChannel(); |
115 void UpdateInvalidatorCredentials(); | 124 void UpdateInvalidatorCredentials(); |
116 void StopInvalidator(); | 125 void StopInvalidator(); |
117 | 126 |
118 Profile *const profile_; | 127 Profile *const profile_; |
119 scoped_ptr<InvalidationAuthProvider> auth_provider_; | 128 scoped_ptr<InvalidationAuthProvider> auth_provider_; |
120 | 129 |
121 scoped_ptr<syncer::InvalidatorRegistrar> invalidator_registrar_; | 130 scoped_ptr<syncer::InvalidatorRegistrar> invalidator_registrar_; |
122 scoped_ptr<InvalidatorStorage> invalidator_storage_; | 131 scoped_ptr<syncer::InvalidationStateTracker> invalidation_state_tracker_; |
123 scoped_ptr<syncer::Invalidator> invalidator_; | 132 scoped_ptr<syncer::Invalidator> invalidator_; |
124 | 133 |
125 // TiclInvalidationService needs to remember access token in order to | 134 // TiclInvalidationService needs to remember access token in order to |
126 // invalidate it with OAuth2TokenService. | 135 // invalidate it with OAuth2TokenService. |
127 std::string access_token_; | 136 std::string access_token_; |
128 | 137 |
129 // TiclInvalidationService needs to hold reference to access_token_request_ | 138 // TiclInvalidationService needs to hold reference to access_token_request_ |
130 // for the duration of request in order to receive callbacks. | 139 // for the duration of request in order to receive callbacks. |
131 scoped_ptr<OAuth2TokenService::Request> access_token_request_; | 140 scoped_ptr<OAuth2TokenService::Request> access_token_request_; |
132 base::OneShotTimer<TiclInvalidationService> request_access_token_retry_timer_; | 141 base::OneShotTimer<TiclInvalidationService> request_access_token_retry_timer_; |
133 net::BackoffEntry request_access_token_backoff_; | 142 net::BackoffEntry request_access_token_backoff_; |
134 | 143 |
135 PrefChangeRegistrar pref_change_registrar_; | 144 PrefChangeRegistrar pref_change_registrar_; |
136 InvalidationNetworkChannel network_channel_type_; | 145 InvalidationNetworkChannel network_channel_type_; |
137 scoped_ptr<GCMInvalidationBridge> gcm_invalidation_bridge_; | 146 scoped_ptr<GCMInvalidationBridge> gcm_invalidation_bridge_; |
147 scoped_refptr<net::URLRequestContextGetter> request_context_; | |
138 | 148 |
139 // The invalidation logger object we use to record state changes | 149 // The invalidation logger object we use to record state changes |
140 // and invalidations. | 150 // and invalidations. |
141 InvalidationLogger logger_; | 151 InvalidationLogger logger_; |
142 | 152 |
143 // Keep a copy of the important parameters used in network channel creation | 153 // Keep a copy of the important parameters used in network channel creation |
144 // for debugging. | 154 // for debugging. |
145 base::DictionaryValue network_channel_options_; | 155 base::DictionaryValue network_channel_options_; |
146 | 156 |
147 DISALLOW_COPY_AND_ASSIGN(TiclInvalidationService); | 157 DISALLOW_COPY_AND_ASSIGN(TiclInvalidationService); |
148 }; | 158 }; |
149 | 159 |
150 } // namespace invalidation | 160 } // namespace invalidation |
151 | 161 |
152 #endif // CHROME_BROWSER_INVALIDATION_TICL_INVALIDATION_SERVICE_H_ | 162 #endif // CHROME_BROWSER_INVALIDATION_TICL_INVALIDATION_SERVICE_H_ |
OLD | NEW |