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

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

Issue 23382008: Making OAuth2TokenService multi-login aware, updating callers, minor fixes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing to include the update to ProfileSyncService: r224220 Created 7 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 (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 "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/threading/non_thread_safe.h" 9 #include "base/threading/non_thread_safe.h"
10 #include "base/timer/timer.h" 10 #include "base/timer/timer.h"
11 #include "chrome/browser/invalidation/invalidation_service.h" 11 #include "chrome/browser/invalidation/invalidation_service.h"
12 #include "chrome/browser/invalidation/invalidator_storage.h" 12 #include "chrome/browser/invalidation/invalidator_storage.h"
13 #include "chrome/browser/signin/token_service.h" 13 #include "chrome/browser/signin/profile_oauth2_token_service.h"
14 #include "components/browser_context_keyed_service/browser_context_keyed_service .h" 14 #include "components/browser_context_keyed_service/browser_context_keyed_service .h"
15 #include "content/public/browser/notification_observer.h" 15 #include "content/public/browser/notification_observer.h"
16 #include "content/public/browser/notification_registrar.h" 16 #include "content/public/browser/notification_registrar.h"
17 #include "google_apis/gaia/oauth2_token_service.h" 17 #include "google_apis/gaia/oauth2_token_service.h"
18 #include "net/base/backoff_entry.h" 18 #include "net/base/backoff_entry.h"
19 #include "sync/notifier/invalidation_handler.h" 19 #include "sync/notifier/invalidation_handler.h"
20 #include "sync/notifier/invalidator_registrar.h" 20 #include "sync/notifier/invalidator_registrar.h"
21 21
22 class Profile; 22 class Profile;
23 class SigninManagerBase; 23 class SigninManagerBase;
24 24
25 namespace syncer { 25 namespace syncer {
26 class Invalidator; 26 class Invalidator;
27 } 27 }
28 28
29 namespace invalidation { 29 namespace invalidation {
30 30
31 // This InvalidationService wraps the C++ Invalidation Client (TICL) library. 31 // This InvalidationService wraps the C++ Invalidation Client (TICL) library.
32 // It provides invalidations for desktop platforms (Win, Mac, Linux). 32 // It provides invalidations for desktop platforms (Win, Mac, Linux).
33 class TiclInvalidationService 33 class TiclInvalidationService
34 : public base::NonThreadSafe, 34 : public base::NonThreadSafe,
35 public InvalidationService, 35 public InvalidationService,
36 public content::NotificationObserver, 36 public content::NotificationObserver,
37 public OAuth2TokenService::Consumer, 37 public OAuth2TokenService::Consumer,
38 public OAuth2TokenService::Observer,
38 public syncer::InvalidationHandler { 39 public syncer::InvalidationHandler {
39 public: 40 public:
40 TiclInvalidationService(SigninManagerBase* signin, 41 TiclInvalidationService(SigninManagerBase* signin,
41 TokenService* token_service, 42 ProfileOAuth2TokenService* oauth2_token_service,
42 OAuth2TokenService* oauth2_token_service,
43 Profile* profile); 43 Profile* profile);
44 virtual ~TiclInvalidationService(); 44 virtual ~TiclInvalidationService();
45 45
46 void Init(); 46 void Init();
47 47
48 // InvalidationService implementation. 48 // InvalidationService implementation.
49 // It is an error to have registered handlers when Shutdown() is called. 49 // It is an error to have registered handlers when Shutdown() is called.
50 virtual void RegisterInvalidationHandler( 50 virtual void RegisterInvalidationHandler(
51 syncer::InvalidationHandler* handler) OVERRIDE; 51 syncer::InvalidationHandler* handler) OVERRIDE;
52 virtual void UpdateRegisteredInvalidationIds( 52 virtual void UpdateRegisteredInvalidationIds(
(...skipping 16 matching lines...) Expand all
69 69
70 // OAuth2TokenService::Consumer implementation 70 // OAuth2TokenService::Consumer implementation
71 virtual void OnGetTokenSuccess( 71 virtual void OnGetTokenSuccess(
72 const OAuth2TokenService::Request* request, 72 const OAuth2TokenService::Request* request,
73 const std::string& access_token, 73 const std::string& access_token,
74 const base::Time& expiration_time) OVERRIDE; 74 const base::Time& expiration_time) OVERRIDE;
75 virtual void OnGetTokenFailure( 75 virtual void OnGetTokenFailure(
76 const OAuth2TokenService::Request* request, 76 const OAuth2TokenService::Request* request,
77 const GoogleServiceAuthError& error) OVERRIDE; 77 const GoogleServiceAuthError& error) OVERRIDE;
78 78
79 // OAuth2TokenService::Observer implementation
80 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE;
81 virtual void OnRefreshTokenRevoked(const std::string& account_id) OVERRIDE;
82
79 // syncer::InvalidationHandler implementation. 83 // syncer::InvalidationHandler implementation.
80 virtual void OnInvalidatorStateChange( 84 virtual void OnInvalidatorStateChange(
81 syncer::InvalidatorState state) OVERRIDE; 85 syncer::InvalidatorState state) OVERRIDE;
82 virtual void OnIncomingInvalidation( 86 virtual void OnIncomingInvalidation(
83 const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE; 87 const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE;
84 88
85 // Overrides BrowserContextKeyedService method. 89 // Overrides BrowserContextKeyedService method.
86 virtual void Shutdown() OVERRIDE; 90 virtual void Shutdown() OVERRIDE;
87 91
88 protected: 92 protected:
89 // Initializes with an injected invalidator. 93 // Initializes with an injected invalidator.
90 void InitForTest(syncer::Invalidator* invalidator); 94 void InitForTest(syncer::Invalidator* invalidator);
91 95
92 friend class TiclInvalidationServiceTestDelegate; 96 friend class TiclInvalidationServiceTestDelegate;
93 97
94 private: 98 private:
95 bool IsReadyToStart(); 99 bool IsReadyToStart();
96 bool IsStarted(); 100 bool IsStarted();
97 101
98 void StartInvalidator(); 102 void StartInvalidator();
99 void UpdateInvalidatorCredentials(); 103 void UpdateInvalidatorCredentials();
100 void StopInvalidator(); 104 void StopInvalidator();
101 void Logout(); 105 void Logout();
102 106
103 Profile *const profile_; 107 Profile *const profile_;
104 SigninManagerBase *const signin_manager_; 108 SigninManagerBase *const signin_manager_;
105 TokenService *const token_service_; 109 ProfileOAuth2TokenService *const oauth2_token_service_;
106 OAuth2TokenService *const oauth2_token_service_;
107 110
108 scoped_ptr<syncer::InvalidatorRegistrar> invalidator_registrar_; 111 scoped_ptr<syncer::InvalidatorRegistrar> invalidator_registrar_;
109 scoped_ptr<InvalidatorStorage> invalidator_storage_; 112 scoped_ptr<InvalidatorStorage> invalidator_storage_;
110 scoped_ptr<syncer::Invalidator> invalidator_; 113 scoped_ptr<syncer::Invalidator> invalidator_;
111 114
112 content::NotificationRegistrar notification_registrar_; 115 content::NotificationRegistrar notification_registrar_;
113 116
114 // TiclInvalidationService needs to remember access token in order to 117 // TiclInvalidationService needs to remember access token in order to
115 // invalidate it with OAuth2TokenService. 118 // invalidate it with OAuth2TokenService.
116 std::string access_token_; 119 std::string access_token_;
117 120
118 // TiclInvalidationService needs to hold reference to access_token_request_ 121 // TiclInvalidationService needs to hold reference to access_token_request_
119 // for the duration of request in order to receive callbacks. 122 // for the duration of request in order to receive callbacks.
120 scoped_ptr<OAuth2TokenService::Request> access_token_request_; 123 scoped_ptr<OAuth2TokenService::Request> access_token_request_;
121 base::OneShotTimer<TiclInvalidationService> request_access_token_retry_timer_; 124 base::OneShotTimer<TiclInvalidationService> request_access_token_retry_timer_;
122 net::BackoffEntry request_access_token_backoff_; 125 net::BackoffEntry request_access_token_backoff_;
123 126
124 DISALLOW_COPY_AND_ASSIGN(TiclInvalidationService); 127 DISALLOW_COPY_AND_ASSIGN(TiclInvalidationService);
125 }; 128 };
126 129
127 } // namespace invalidation 130 } // namespace invalidation
128 131
129 #endif // CHROME_BROWSER_INVALIDATION_TICL_INVALIDATION_SERVICE_H_ 132 #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