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

Side by Side Diff: chrome/browser/signin/token_service.h

Issue 11348220: sync: centralize sync startup decisions in TryStart. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ui review Created 8 years 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
« no previous file with comments | « no previous file | chrome/browser/sync/profile_sync_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // The TokenService will supply authentication tokens for any service that 5 // The TokenService will supply authentication tokens for any service that
6 // needs it, such as sync. Whenever the user logs in, a controller watching 6 // needs it, such as sync. Whenever the user logs in, a controller watching
7 // the token service is expected either to call ClientLogin to derive a new 7 // the token service is expected either to call ClientLogin to derive a new
8 // SID and LSID, or to use GAIA OAuth requests to derive an OAuth1 access 8 // SID and LSID, or to use GAIA OAuth requests to derive an OAuth1 access
9 // token for the OAuthLogin scope. Whenever such credentials are available, 9 // token for the OAuthLogin scope. Whenever such credentials are available,
10 // the TokenService should be updated with new credentials. The controller 10 // the TokenService should be updated with new credentials. The controller
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // Terminate any running requests and reset the TokenService to a clean 137 // Terminate any running requests and reset the TokenService to a clean
138 // slate. Resets in memory structures. Does not modify the DB. 138 // slate. Resets in memory structures. Does not modify the DB.
139 // When this is done, no tokens will be left in memory and no 139 // When this is done, no tokens will be left in memory and no
140 // user credentials will be left. Useful if a user is logging out. 140 // user credentials will be left. Useful if a user is logging out.
141 // Initialize doesn't need to be called again but UpdateCredentials does. 141 // Initialize doesn't need to be called again but UpdateCredentials does.
142 void ResetCredentialsInMemory(); 142 void ResetCredentialsInMemory();
143 143
144 // Async load all tokens for services we know of from the DB. 144 // Async load all tokens for services we know of from the DB.
145 // You should do this at startup. Optionally you can do it again 145 // You should do this at startup. Optionally you can do it again
146 // after you reset in memory credentials. 146 // after you reset in memory credentials.
147 void LoadTokensFromDB(); 147 virtual void LoadTokensFromDB();
148 148
149 // Clear all DB stored tokens for the current profile. Tokens may still be 149 // Clear all DB stored tokens for the current profile. Tokens may still be
150 // available in memory. If a DB load is pending it may still be serviced. 150 // available in memory. If a DB load is pending it may still be serviced.
151 void EraseTokensFromDB(); 151 void EraseTokensFromDB();
152 152
153 // Returns true if tokens have been loaded from the DB. Set when 153 // Returns true if tokens have been loaded from the DB. Set when
154 // LoadTokensFromDB() completes, unset when ResetCredentialsInMemory() is 154 // LoadTokensFromDB() completes, unset when ResetCredentialsInMemory() is
155 // called. 155 // called.
156 bool TokensLoadedFromDB() const; 156 bool TokensLoadedFromDB() const;
157 157
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 const GoogleServiceAuthError& error) OVERRIDE; 190 const GoogleServiceAuthError& error) OVERRIDE;
191 virtual void OnClientOAuthSuccess(const ClientOAuthResult& result) OVERRIDE; 191 virtual void OnClientOAuthSuccess(const ClientOAuthResult& result) OVERRIDE;
192 virtual void OnClientOAuthFailure( 192 virtual void OnClientOAuthFailure(
193 const GoogleServiceAuthError& error) OVERRIDE; 193 const GoogleServiceAuthError& error) OVERRIDE;
194 194
195 // WebDataServiceConsumer implementation. 195 // WebDataServiceConsumer implementation.
196 virtual void OnWebDataServiceRequestDone( 196 virtual void OnWebDataServiceRequestDone(
197 WebDataService::Handle h, 197 WebDataService::Handle h,
198 const WDTypedResult* result) OVERRIDE; 198 const WDTypedResult* result) OVERRIDE;
199 199
200 protected:
201 void set_tokens_loaded(bool loaded) {
202 tokens_loaded_ = loaded;
203 }
204
200 private: 205 private:
201 206
202 // Gets the list of all service names for which tokens will be retrieved. 207 // Gets the list of all service names for which tokens will be retrieved.
203 // This method is meant only for tests. 208 // This method is meant only for tests.
204 static void GetServiceNamesForTesting(std::vector<std::string>* names); 209 static void GetServiceNamesForTesting(std::vector<std::string>* names);
205 210
206 void FireCredentialsUpdatedNotification(const std::string& lsid, 211 void FireCredentialsUpdatedNotification(const std::string& lsid,
207 const std::string& sid); 212 const std::string& sid);
208 213
209 void FireTokenAvailableNotification(const std::string& service, 214 void FireTokenAvailableNotification(const std::string& service,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 260
256 friend class TokenServiceTest; 261 friend class TokenServiceTest;
257 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, LoadTokensIntoMemoryBasic); 262 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, LoadTokensIntoMemoryBasic);
258 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, LoadTokensIntoMemoryAdvanced); 263 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, LoadTokensIntoMemoryAdvanced);
259 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, FullIntegrationNewServicesAdded); 264 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, FullIntegrationNewServicesAdded);
260 265
261 DISALLOW_COPY_AND_ASSIGN(TokenService); 266 DISALLOW_COPY_AND_ASSIGN(TokenService);
262 }; 267 };
263 268
264 #endif // CHROME_BROWSER_SIGNIN_TOKEN_SERVICE_H_ 269 #endif // CHROME_BROWSER_SIGNIN_TOKEN_SERVICE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/profile_sync_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698