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

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

Issue 179843002: Make invalidations work for Chrome OS Kiosk Apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge error leading to uninitialized memory access. Created 6 years, 9 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>
9
8 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
9 #include "base/threading/non_thread_safe.h" 11 #include "base/threading/non_thread_safe.h"
10 #include "base/timer/timer.h" 12 #include "base/timer/timer.h"
13 #include "chrome/browser/invalidation/invalidation_auth_provider.h"
11 #include "chrome/browser/invalidation/invalidation_logger.h" 14 #include "chrome/browser/invalidation/invalidation_logger.h"
12 #include "chrome/browser/invalidation/invalidation_service.h" 15 #include "chrome/browser/invalidation/invalidation_service.h"
13 #include "chrome/browser/invalidation/invalidator_storage.h" 16 #include "chrome/browser/invalidation/invalidator_storage.h"
14 #include "chrome/browser/signin/signin_manager.h"
15 #include "components/keyed_service/core/keyed_service.h" 17 #include "components/keyed_service/core/keyed_service.h"
16 #include "components/signin/core/profile_oauth2_token_service.h" 18 #include "components/signin/core/profile_oauth2_token_service.h"
17 #include "google_apis/gaia/oauth2_token_service.h" 19 #include "google_apis/gaia/oauth2_token_service.h"
18 #include "net/base/backoff_entry.h" 20 #include "net/base/backoff_entry.h"
19 #include "sync/notifier/invalidation_handler.h" 21 #include "sync/notifier/invalidation_handler.h"
20 #include "sync/notifier/invalidator_registrar.h" 22 #include "sync/notifier/invalidator_registrar.h"
21 23
22 class Profile; 24 class Profile;
23 25
24 namespace syncer { 26 namespace syncer {
25 class Invalidator; 27 class Invalidator;
26 } 28 }
27 29
28 namespace invalidation { 30 namespace invalidation {
29 class GCMInvalidationBridge; 31 class GCMInvalidationBridge;
30 32
31 // This InvalidationService wraps the C++ Invalidation Client (TICL) library. 33 // This InvalidationService wraps the C++ Invalidation Client (TICL) library.
32 // It provides invalidations for desktop platforms (Win, Mac, Linux). 34 // It provides invalidations for desktop platforms (Win, Mac, Linux).
33 class TiclInvalidationService : public base::NonThreadSafe, 35 class TiclInvalidationService : public base::NonThreadSafe,
34 public InvalidationService, 36 public InvalidationService,
35 public OAuth2TokenService::Consumer, 37 public OAuth2TokenService::Consumer,
36 public OAuth2TokenService::Observer, 38 public OAuth2TokenService::Observer,
37 public SigninManagerBase::Observer, 39 public InvalidationAuthProvider::Observer,
38 public syncer::InvalidationHandler { 40 public syncer::InvalidationHandler {
39 public: 41 public:
40 TiclInvalidationService(SigninManagerBase* signin, 42 TiclInvalidationService(scoped_ptr<InvalidationAuthProvider> auth_provider,
41 ProfileOAuth2TokenService* oauth2_token_service,
42 Profile* profile); 43 Profile* profile);
43 virtual ~TiclInvalidationService(); 44 virtual ~TiclInvalidationService();
44 45
45 void Init(); 46 void Init();
46 47
47 // InvalidationService implementation. 48 // InvalidationService implementation.
48 // 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.
49 virtual void RegisterInvalidationHandler( 50 virtual void RegisterInvalidationHandler(
50 syncer::InvalidationHandler* handler) OVERRIDE; 51 syncer::InvalidationHandler* handler) OVERRIDE;
51 virtual void UpdateRegisteredInvalidationIds( 52 virtual void UpdateRegisteredInvalidationIds(
52 syncer::InvalidationHandler* handler, 53 syncer::InvalidationHandler* handler,
53 const syncer::ObjectIdSet& ids) OVERRIDE; 54 const syncer::ObjectIdSet& ids) OVERRIDE;
54 virtual void UnregisterInvalidationHandler( 55 virtual void UnregisterInvalidationHandler(
55 syncer::InvalidationHandler* handler) OVERRIDE; 56 syncer::InvalidationHandler* handler) OVERRIDE;
56 virtual syncer::InvalidatorState GetInvalidatorState() const OVERRIDE; 57 virtual syncer::InvalidatorState GetInvalidatorState() const OVERRIDE;
57 virtual std::string GetInvalidatorClientId() const OVERRIDE; 58 virtual std::string GetInvalidatorClientId() const OVERRIDE;
58 virtual InvalidationLogger* GetInvalidationLogger() OVERRIDE; 59 virtual InvalidationLogger* GetInvalidationLogger() OVERRIDE;
59 virtual void RequestDetailedStatus( 60 virtual void RequestDetailedStatus(
60 base::Callback<void(const base::DictionaryValue&)> caller) OVERRIDE; 61 base::Callback<void(const base::DictionaryValue&)> caller) OVERRIDE;
62 virtual InvalidationAuthProvider* GetInvalidationAuthProvider() OVERRIDE;
61 63
62 void RequestAccessToken(); 64 void RequestAccessToken();
63 65
64 // OAuth2TokenService::Consumer implementation 66 // OAuth2TokenService::Consumer implementation
65 virtual void OnGetTokenSuccess( 67 virtual void OnGetTokenSuccess(
66 const OAuth2TokenService::Request* request, 68 const OAuth2TokenService::Request* request,
67 const std::string& access_token, 69 const std::string& access_token,
68 const base::Time& expiration_time) OVERRIDE; 70 const base::Time& expiration_time) OVERRIDE;
69 virtual void OnGetTokenFailure( 71 virtual void OnGetTokenFailure(
70 const OAuth2TokenService::Request* request, 72 const OAuth2TokenService::Request* request,
71 const GoogleServiceAuthError& error) OVERRIDE; 73 const GoogleServiceAuthError& error) OVERRIDE;
72 74
73 // OAuth2TokenService::Observer implementation 75 // OAuth2TokenService::Observer implementation
74 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE; 76 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE;
75 virtual void OnRefreshTokenRevoked(const std::string& account_id) OVERRIDE; 77 virtual void OnRefreshTokenRevoked(const std::string& account_id) OVERRIDE;
76 78
77 // SigninManagerBase::Observer implementation. 79 // InvalidationAuthProvider::Observer implementation.
78 virtual void GoogleSignedOut(const std::string& username) OVERRIDE; 80 virtual void OnInvalidationAuthLogout() OVERRIDE;
79 81
80 // syncer::InvalidationHandler implementation. 82 // syncer::InvalidationHandler implementation.
81 virtual void OnInvalidatorStateChange( 83 virtual void OnInvalidatorStateChange(
82 syncer::InvalidatorState state) OVERRIDE; 84 syncer::InvalidatorState state) OVERRIDE;
83 virtual void OnIncomingInvalidation( 85 virtual void OnIncomingInvalidation(
84 const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE; 86 const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE;
85 virtual std::string GetOwnerName() const OVERRIDE; 87 virtual std::string GetOwnerName() const OVERRIDE;
86 88
87 // Overrides KeyedService method. 89 // Overrides KeyedService method.
88 virtual void Shutdown() OVERRIDE; 90 virtual void Shutdown() OVERRIDE;
89 91
90 protected: 92 protected:
91 // Initializes with an injected invalidator. 93 // Initializes with an injected invalidator.
92 void InitForTest(syncer::Invalidator* invalidator); 94 void InitForTest(syncer::Invalidator* invalidator);
93 95
94 friend class TiclInvalidationServiceTestDelegate; 96 friend class TiclInvalidationServiceTestDelegate;
95 97
96 private: 98 private:
97 enum InvalidationNetworkChannel { 99 enum InvalidationNetworkChannel {
98 PUSH_CLIENT_CHANNEL = 0, 100 PUSH_CLIENT_CHANNEL = 0,
99 GCM_NETWORK_CHANNEL = 1 101 GCM_NETWORK_CHANNEL = 1
100 }; 102 };
101 103
102 bool IsReadyToStart(); 104 bool IsReadyToStart();
103 bool IsStarted(); 105 bool IsStarted();
104 106
105 void StartInvalidator(InvalidationNetworkChannel network_channel); 107 void StartInvalidator(InvalidationNetworkChannel network_channel);
106 void UpdateInvalidatorCredentials(); 108 void UpdateInvalidatorCredentials();
107 void StopInvalidator(); 109 void StopInvalidator();
108 void Logout();
109 110
110 Profile *const profile_; 111 Profile *const profile_;
111 SigninManagerBase *const signin_manager_; 112 scoped_ptr<InvalidationAuthProvider> auth_provider_;
112 ProfileOAuth2TokenService *const oauth2_token_service_;
113 113
114 scoped_ptr<syncer::InvalidatorRegistrar> invalidator_registrar_; 114 scoped_ptr<syncer::InvalidatorRegistrar> invalidator_registrar_;
115 scoped_ptr<InvalidatorStorage> invalidator_storage_; 115 scoped_ptr<InvalidatorStorage> invalidator_storage_;
116 scoped_ptr<syncer::Invalidator> invalidator_; 116 scoped_ptr<syncer::Invalidator> invalidator_;
117 117
118 // TiclInvalidationService needs to remember access token in order to 118 // TiclInvalidationService needs to remember access token in order to
119 // invalidate it with OAuth2TokenService. 119 // invalidate it with OAuth2TokenService.
120 std::string access_token_; 120 std::string access_token_;
121 121
122 // TiclInvalidationService needs to hold reference to access_token_request_ 122 // TiclInvalidationService needs to hold reference to access_token_request_
(...skipping 11 matching lines...) Expand all
134 // Keep a copy of the important parameters used in network channel creation 134 // Keep a copy of the important parameters used in network channel creation
135 // for debugging. 135 // for debugging.
136 base::DictionaryValue network_channel_options_; 136 base::DictionaryValue network_channel_options_;
137 137
138 DISALLOW_COPY_AND_ASSIGN(TiclInvalidationService); 138 DISALLOW_COPY_AND_ASSIGN(TiclInvalidationService);
139 }; 139 };
140 140
141 } // namespace invalidation 141 } // namespace invalidation
142 142
143 #endif // CHROME_BROWSER_INVALIDATION_TICL_INVALIDATION_SERVICE_H_ 143 #endif // CHROME_BROWSER_INVALIDATION_TICL_INVALIDATION_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698