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

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

Issue 63253003: Fix issues with token refresh in AccountReconcilor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wip Created 7 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 #include "chrome/browser/signin/google_auto_login_helper.h" 5 #include "chrome/browser/signin/google_auto_login_helper.h"
6 6
7 #include "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/profiles/profile_manager.h" 8 #include "chrome/browser/profiles/profile_manager.h"
9 #include "google_apis/gaia/gaia_auth_fetcher.h" 9 #include "google_apis/gaia/gaia_auth_fetcher.h"
10 #include "google_apis/gaia/gaia_constants.h" 10 #include "google_apis/gaia/gaia_constants.h"
11 11
12 GoogleAutoLoginHelper::GoogleAutoLoginHelper(Profile* profile) 12 GoogleAutoLoginHelper::GoogleAutoLoginHelper(Profile* profile)
13 : profile_(profile) {} 13 : profile_(profile) {}
14 14
15 GoogleAutoLoginHelper::~GoogleAutoLoginHelper() {} 15 GoogleAutoLoginHelper::~GoogleAutoLoginHelper() {}
16 16
17 void GoogleAutoLoginHelper::LogIn() { 17 void GoogleAutoLoginHelper::LogIn() {
18 uber_token_fetcher_.reset(new UbertokenFetcher(profile_, this)); 18 uber_token_fetcher_.reset(new UbertokenFetcher(profile_, this));
19 uber_token_fetcher_->StartFetchingToken(); 19 uber_token_fetcher_->StartFetchingToken();
20 } 20 }
21 21
22 void GoogleAutoLoginHelper::LogIn(const std::string& account_id) { 22 void GoogleAutoLoginHelper::LogIn(const std::string& account_id) {
23 uber_token_fetcher_.reset(new UbertokenFetcher(profile_, this)); 23 uber_token_fetcher_.reset(new UbertokenFetcher(profile_, this));
24 uber_token_fetcher_->StartFetchingToken(account_id); 24 uber_token_fetcher_->StartFetchingToken(account_id);
25 } 25 }
26 26
27 void GoogleAutoLoginHelper::LogIn(const std::deque<std::string>& account_ids) {
28 accounts_ = account_ids;
29 uber_token_fetcher_.reset(new UbertokenFetcher(profile_, this));
30 uber_token_fetcher_->StartFetchingToken(accounts_.front());
31 accounts_.pop_front();
32 }
33
27 void GoogleAutoLoginHelper::OnUbertokenSuccess(const std::string& uber_token) { 34 void GoogleAutoLoginHelper::OnUbertokenSuccess(const std::string& uber_token) {
28 gaia_auth_fetcher_.reset(new GaiaAuthFetcher( 35 gaia_auth_fetcher_.reset(new GaiaAuthFetcher(
29 this, GaiaConstants::kChromeSource, profile_->GetRequestContext())); 36 this, GaiaConstants::kChromeSource, profile_->GetRequestContext()));
30 gaia_auth_fetcher_->StartMergeSession(uber_token); 37 gaia_auth_fetcher_->StartMergeSession(uber_token);
31 } 38 }
32 39
33 void GoogleAutoLoginHelper::OnUbertokenFailure( 40 void GoogleAutoLoginHelper::OnUbertokenFailure(
34 const GoogleServiceAuthError& error) { 41 const GoogleServiceAuthError& error) {
35 VLOG(1) << "Failed to retrieve ubertoken, error: " << error.ToString(); 42 VLOG(1) << "Failed to retrieve ubertoken, error: " << error.ToString();
36 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 43 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
37 } 44 }
38 45
39 void GoogleAutoLoginHelper::OnMergeSessionSuccess(const std::string& data) { 46 void GoogleAutoLoginHelper::OnMergeSessionSuccess(const std::string& data) {
40 DVLOG(1) << "MergeSession successful." << data; 47 DVLOG(1) << "MergeSession successful." << data;
41 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 48 if (accounts_.empty()) {
49 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
50 } else {
51 LogIn(accounts_.front());
52 accounts_.pop_front();
53 }
42 } 54 }
43 55
44 void GoogleAutoLoginHelper::OnMergeSessionFailure( 56 void GoogleAutoLoginHelper::OnMergeSessionFailure(
45 const GoogleServiceAuthError& error) { 57 const GoogleServiceAuthError& error) {
46 VLOG(1) << "Failed MergeSession request, error: " << error.ToString(); 58 VLOG(1) << "Failed MergeSession request, error: " << error.ToString();
47 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 59 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
48 } 60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698