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

Unified Diff: chrome/browser/chromeos/login/oauth2_login_verifier.cc

Issue 148463004: Perform /ListAccounts check before session merge to see if there is a need for session merge at all. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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/chromeos/login/oauth2_login_verifier.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/login/oauth2_login_verifier.cc
diff --git a/chrome/browser/chromeos/login/oauth2_login_verifier.cc b/chrome/browser/chromeos/login/oauth2_login_verifier.cc
index 86e6aab824b3f430fd8f785c8b99ff4ec586b789..9976734d26957e681db150a3ca0921d7dacd9294 100644
--- a/chrome/browser/chromeos/login/oauth2_login_verifier.cc
+++ b/chrome/browser/chromeos/login/oauth2_login_verifier.cc
@@ -68,26 +68,24 @@ OAuth2LoginVerifier::OAuth2LoginVerifier(
OAuth2LoginVerifier::~OAuth2LoginVerifier() {
}
+void OAuth2LoginVerifier::VerifyUserCookies(Profile* profile) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ if (DelayNetworkCall(base::Bind(&OAuth2LoginVerifier::VerifyUserCookies,
+ AsWeakPtr(),
+ profile))) {
+ return;
+ }
+
+ StartAuthCookiesVerification();
+}
+
void OAuth2LoginVerifier::VerifyProfileTokens(Profile* profile) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- // Delay the verification if the network is not connected or on a captive
- // portal.
- const NetworkState* default_network =
- NetworkHandler::Get()->network_state_handler()->DefaultNetwork();
- NetworkPortalDetector* detector = NetworkPortalDetector::Get();
- if (!default_network ||
- default_network->connection_state() == shill::kStatePortal ||
- (detector && detector->GetCaptivePortalState(default_network).status !=
- NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE)) {
- // If network is offline, defer the token fetching until online.
- LOG(WARNING) << "Network is offline. Deferring OAuth2 access token fetch.";
- BrowserThread::PostDelayedTask(
- BrowserThread::UI,
- FROM_HERE,
- base::Bind(
- &OAuth2LoginVerifier::VerifyProfileTokens, AsWeakPtr(), profile),
- base::TimeDelta::FromMilliseconds(kRequestRestartDelay));
+ if (DelayNetworkCall(base::Bind(&OAuth2LoginVerifier::VerifyProfileTokens,
+ AsWeakPtr(),
+ profile))) {
return;
}
@@ -169,11 +167,11 @@ void OAuth2LoginVerifier::SchedulePostMergeVerification() {
BrowserThread::UI,
FROM_HERE,
base::Bind(
- &OAuth2LoginVerifier::StartPostRestoreVerification, AsWeakPtr()),
+ &OAuth2LoginVerifier::StartAuthCookiesVerification, AsWeakPtr()),
base::TimeDelta::FromMilliseconds(kPostResoreVerificationDelay));
}
-void OAuth2LoginVerifier::StartPostRestoreVerification() {
+void OAuth2LoginVerifier::StartAuthCookiesVerification() {
gaia_fetcher_.reset(
new GaiaAuthFetcher(this,
std::string(GaiaConstants::kChromeOSSource),
@@ -239,7 +237,7 @@ void OAuth2LoginVerifier::OnListAccountsFailure(
RetryOnError(
"ListAccounts",
error,
- base::Bind(&OAuth2LoginVerifier::StartPostRestoreVerification,
+ base::Bind(&OAuth2LoginVerifier::StartAuthCookiesVerification,
AsWeakPtr()),
base::Bind(&Delegate::OnListAccountsFailure,
base::Unretained(delegate_)));
@@ -272,4 +270,27 @@ void OAuth2LoginVerifier::RetryOnError(const char* operation_id,
error_handler.Run(IsConnectionOrServiceError(error));
}
+bool OAuth2LoginVerifier::DelayNetworkCall(const base::Closure& callback) {
+ // Delay the verification if the network is not connected or on a captive
+ // portal.
+ const NetworkState* default_network =
+ NetworkHandler::Get()->network_state_handler()->DefaultNetwork();
+ NetworkPortalDetector* detector = NetworkPortalDetector::Get();
+ if (!default_network ||
+ default_network->connection_state() == shill::kStatePortal ||
+ (detector && detector->GetCaptivePortalState(default_network).status !=
+ NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE)) {
+ // If network is offline, defer the token fetching until online.
+ LOG(WARNING) << "Network is offline. Deferring call.";
+ BrowserThread::PostDelayedTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ callback,
+ base::TimeDelta::FromMilliseconds(kRequestRestartDelay));
+ return true;
+ }
+
+ return false;
+}
+
} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/login/oauth2_login_verifier.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698