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

Unified Diff: chrome/browser/signin/token_service.cc

Issue 10213013: Now CHECKs to make sure we log out before clearing the token db (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review feedback. Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/signin/signin_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/signin/token_service.cc
diff --git a/chrome/browser/signin/token_service.cc b/chrome/browser/signin/token_service.cc
index da66af2c8dc4e1cbecb8600749a11b7cfdd373c8..c229b79d33792d6426c4b8e3d5be598f0a906a8d 100644
--- a/chrome/browser/signin/token_service.cc
+++ b/chrome/browser/signin/token_service.cc
@@ -7,11 +7,13 @@
#include "base/basictypes.h"
#include "base/command_line.h"
#include "base/string_util.h"
+#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/net/gaia/gaia_auth_fetcher.h"
#include "chrome/common/net/gaia/gaia_constants.h"
+#include "chrome/common/pref_names.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
@@ -66,7 +68,10 @@ void TokenService::Initialize(const char* const source,
source_ = std::string(source);
CommandLine* cmd_line = CommandLine::ForCurrentProcess();
- // Allow the token service to be cleared from the command line.
+ // Allow the token service to be cleared from the command line. We rely on
+ // SigninManager::Initialize() being called to clear out the
+ // kGoogleServicesUsername pref before we call EraseTokensFromDB() as
+ // otherwise the system would be in an invalid state.
if (cmd_line->HasSwitch(switches::kClearTokenService))
EraseTokensFromDB();
@@ -133,6 +138,13 @@ void TokenService::SaveAuthTokenToDB(const std::string& service,
void TokenService::EraseTokensFromDB() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ // Try to track down http://crbug.com/121755 - we should never clear the
+ // token DB while we're still logged in.
+ if (profile_) {
+ std::string user = profile_->GetPrefs()->GetString(
+ prefs::kGoogleServicesUsername);
+ CHECK(user.empty());
+ }
if (web_data_service_.get())
web_data_service_->RemoveAllTokens();
}
« no previous file with comments | « chrome/browser/signin/signin_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698