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

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

Issue 12380006: Build a new TokenCacheService so I can stop using TokenService for something it wasn't designed for. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Token Cache Service - more CR fixes per DCheng Created 7 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
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 #include "chrome/browser/signin/token_service.h" 5 #include "chrome/browser/signin/token_service.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 if (cmd_line->HasSwitch(switches::kSetToken)) { 93 if (cmd_line->HasSwitch(switches::kSetToken)) {
94 std::string value = cmd_line->GetSwitchValueASCII(switches::kSetToken); 94 std::string value = cmd_line->GetSwitchValueASCII(switches::kSetToken);
95 int separator = value.find(':'); 95 int separator = value.find(':');
96 std::string service = value.substr(0, separator); 96 std::string service = value.substr(0, separator);
97 std::string token = value.substr(separator + 1); 97 std::string token = value.substr(separator + 1);
98 token_map_[service] = token; 98 token_map_[service] = token;
99 SaveAuthTokenToDB(service, token); 99 SaveAuthTokenToDB(service, token);
100 } 100 }
101 } 101 }
102 102
103 // TODO(petewil) We should refactor the token_service so it does not both
104 // store tokens and fetch them. Move the key-value storage out of
105 // token_service, and leave the token fetching in token_service.
106
107 void TokenService::AddAuthTokenManually(const std::string& service, 103 void TokenService::AddAuthTokenManually(const std::string& service,
108 const std::string& auth_token) { 104 const std::string& auth_token) {
109 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 105 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
110 VLOG(1) << "Got an authorization token for " << service; 106 VLOG(1) << "Got an authorization token for " << service;
111 token_map_[service] = auth_token; 107 token_map_[service] = auth_token;
112 FireTokenAvailableNotification(service, auth_token); 108 FireTokenAvailableNotification(service, auth_token);
113 SaveAuthTokenToDB(service, auth_token); 109 SaveAuthTokenToDB(service, auth_token);
114 110
115 // We don't ever want to fetch OAuth2 tokens from LSO service token in case 111 // We don't ever want to fetch OAuth2 tokens from LSO service token in case
116 // when ChromeOS is in forced OAuth2 use mode. OAuth2 token should only 112 // when ChromeOS is in forced OAuth2 use mode. OAuth2 token should only
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 DCHECK(NULL == fetchers_[i].get()); 409 DCHECK(NULL == fetchers_[i].get());
414 } 410 }
415 411
416 for (size_t i = 0; i < arraysize(kServices); i++) { 412 for (size_t i = 0; i < arraysize(kServices); i++) {
417 LoadSingleTokenIntoMemory(db_tokens, in_memory_tokens, kServices[i]); 413 LoadSingleTokenIntoMemory(db_tokens, in_memory_tokens, kServices[i]);
418 } 414 }
419 LoadSingleTokenIntoMemory(db_tokens, in_memory_tokens, 415 LoadSingleTokenIntoMemory(db_tokens, in_memory_tokens,
420 GaiaConstants::kGaiaOAuth2LoginRefreshToken); 416 GaiaConstants::kGaiaOAuth2LoginRefreshToken);
421 LoadSingleTokenIntoMemory(db_tokens, in_memory_tokens, 417 LoadSingleTokenIntoMemory(db_tokens, in_memory_tokens,
422 GaiaConstants::kGaiaOAuth2LoginAccessToken); 418 GaiaConstants::kGaiaOAuth2LoginAccessToken);
423 // TODO(petewil): Remove next line when we refactor key-value
424 // storage out of token_service.
425 LoadSingleTokenIntoMemory(db_tokens, in_memory_tokens,
426 GaiaConstants::kObfuscatedGaiaId);
427 419
428 if (credentials_.lsid.empty() && credentials_.sid.empty()) { 420 if (credentials_.lsid.empty() && credentials_.sid.empty()) {
429 // Look for GAIA SID and LSID tokens. If we have both, and the current 421 // Look for GAIA SID and LSID tokens. If we have both, and the current
430 // crendentials are empty, update the credentials. 422 // crendentials are empty, update the credentials.
431 std::string lsid; 423 std::string lsid;
432 std::string sid; 424 std::string sid;
433 425
434 if (db_tokens.count(GaiaConstants::kGaiaLsid) > 0) 426 if (db_tokens.count(GaiaConstants::kGaiaLsid) > 0)
435 lsid = db_tokens.find(GaiaConstants::kGaiaLsid)->second; 427 lsid = db_tokens.find(GaiaConstants::kGaiaLsid)->second;
436 428
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 472
481 void TokenService::AddSigninDiagnosticsObserver( 473 void TokenService::AddSigninDiagnosticsObserver(
482 SigninDiagnosticsObserver* observer) { 474 SigninDiagnosticsObserver* observer) {
483 signin_diagnostics_observers_.AddObserver(observer); 475 signin_diagnostics_observers_.AddObserver(observer);
484 } 476 }
485 477
486 void TokenService::RemoveSigninDiagnosticsObserver( 478 void TokenService::RemoveSigninDiagnosticsObserver(
487 SigninDiagnosticsObserver* observer) { 479 SigninDiagnosticsObserver* observer) {
488 signin_diagnostics_observers_.RemoveObserver(observer); 480 signin_diagnostics_observers_.RemoveObserver(observer);
489 } 481 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698