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

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: added missing files Created 7 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
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() {}
Roger Tawa OOO till Jul 10th 2013/11/27 18:45:43 Should DCHECK that |accounts_| is empty.
acleung1 2013/11/28 00:52:44 Done.
16 16
17 void GoogleAutoLoginHelper::LogIn() { 17 void GoogleAutoLoginHelper::LogIn() {
18 uber_token_fetcher_.reset(new UbertokenFetcher(profile_, this)); 18 uber_token_fetcher_.reset(CreateNewUbertokenFetcher());
Roger Tawa OOO till Jul 10th 2013/11/27 18:45:43 Add a DCHECK that |accounts_| is empty.
acleung1 2013/11/28 00:52:44 Done.
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 if (uber_token_fetcher_.get()) {
24 uber_token_fetcher_->StartFetchingToken(account_id); 24 accounts_.push_back(account_id);
25 } else {
26 uber_token_fetcher_.reset(CreateNewUbertokenFetcher());
27 uber_token_fetcher_->StartFetchingToken(account_id);
28 }
25 } 29 }
26 30
27 void GoogleAutoLoginHelper::OnUbertokenSuccess(const std::string& uber_token) { 31 void GoogleAutoLoginHelper::OnUbertokenSuccess(const std::string& uber_token) {
28 gaia_auth_fetcher_.reset(new GaiaAuthFetcher( 32 VLOG(1) << "GoogleAutoLoginHelper::OnUbertokenSuccess" << uber_token;
Roger Tawa OOO till Jul 10th 2013/11/27 18:45:43 Nit: put a space after "Success" in string?
acleung1 2013/11/28 00:52:44 Good point. Actually, the uber token's too noisy.
29 this, GaiaConstants::kChromeSource, profile_->GetRequestContext())); 33 gaia_auth_fetcher_.reset(CreateNewGaiaAuthFetcher());
30 gaia_auth_fetcher_->StartMergeSession(uber_token); 34 gaia_auth_fetcher_->StartMergeSession(uber_token);
31 } 35 }
32 36
33 void GoogleAutoLoginHelper::OnUbertokenFailure( 37 void GoogleAutoLoginHelper::OnUbertokenFailure(
34 const GoogleServiceAuthError& error) { 38 const GoogleServiceAuthError& error) {
35 VLOG(1) << "Failed to retrieve ubertoken, error: " << error.ToString(); 39 VLOG(1) << "Failed to retrieve ubertoken, error: " << error.ToString();
36 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 40 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
37 } 41 }
38 42
39 void GoogleAutoLoginHelper::OnMergeSessionSuccess(const std::string& data) { 43 void GoogleAutoLoginHelper::OnMergeSessionSuccess(const std::string& data) {
40 DVLOG(1) << "MergeSession successful." << data; 44 DVLOG(1) << "MergeSession successful." << data;
41 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 45 if (accounts_.empty()) {
46 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
47 } else {
48 uber_token_fetcher_.reset(CreateNewUbertokenFetcher());
49 uber_token_fetcher_->StartFetchingToken(accounts_.front());
50 accounts_.pop_front();
51 }
42 } 52 }
43 53
44 void GoogleAutoLoginHelper::OnMergeSessionFailure( 54 void GoogleAutoLoginHelper::OnMergeSessionFailure(
45 const GoogleServiceAuthError& error) { 55 const GoogleServiceAuthError& error) {
46 VLOG(1) << "Failed MergeSession request, error: " << error.ToString(); 56 VLOG(1) << "Failed MergeSession request, error: " << error.ToString();
47 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 57 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
58 // TODO(acleung): Depending on the return error we should probably
59 // take different actions instead of just throw our hands up.
Roger Tawa OOO till Jul 10th 2013/11/27 18:45:43 sgtm, but for now please clear out the |accounts_|
acleung1 2013/11/28 00:52:44 Done.
48 } 60 }
61
62 UbertokenFetcher* GoogleAutoLoginHelper::CreateNewUbertokenFetcher() {
63 return new UbertokenFetcher(profile_, this);
64 }
65
66 GaiaAuthFetcher* GoogleAutoLoginHelper::CreateNewGaiaAuthFetcher() {
67 return new GaiaAuthFetcher(
68 this, GaiaConstants::kChromeSource, profile_->GetRequestContext());
69 }
70
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698