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

Unified Diff: chrome/browser/ui/webui/sync_setup_handler.cc

Issue 10539128: Set timeout in sync setup (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed some descriptions. Created 8 years, 6 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
Index: chrome/browser/ui/webui/sync_setup_handler.cc
diff --git a/chrome/browser/ui/webui/sync_setup_handler.cc b/chrome/browser/ui/webui/sync_setup_handler.cc
index dfc6dfe0c6e8d2861626ddb94dea95b1c7959791..b2fa04eae0f960d22a38776e4eea4c943644c0f4 100644
--- a/chrome/browser/ui/webui/sync_setup_handler.cc
+++ b/chrome/browser/ui/webui/sync_setup_handler.cc
@@ -284,6 +284,8 @@ void SyncSetupHandler::GetStaticLocalizedValues(
static OptionsStringResource resources[] = {
{ "syncSetupConfigureTitle", IDS_SYNC_SETUP_CONFIGURE_TITLE },
+ { "syncSetupTimeoutTitle", IDS_SYNC_SETUP_TIME_OUT_TITLE },
+ { "syncSetupTimeoutContent", IDS_SYNC_SETUP_TIME_OUT_CONTENT },
{ "cannotBeBlank", IDS_SYNC_CANNOT_BE_BLANK },
{ "emailLabel", IDS_SYNC_LOGIN_EMAIL_NEW_LINE },
{ "passwordLabel", IDS_SYNC_LOGIN_PASSWORD_NEW_LINE },
@@ -536,6 +538,23 @@ void SyncSetupHandler::DisplaySpinner() {
configuring_sync_ = true;
StringValue page("spinner");
DictionaryValue args;
+
+ const int kTimeoutSec = 30;
+ backend_start_timer_.reset(new base::OneShotTimer<SyncSetupHandler>());
Andrew T Wilson (Slow) 2012/06/20 00:12:02 Seems like we should never get called with a non-e
peria 2012/06/20 04:06:03 I think it is not necessary to put DCHECK() here,
Andrew T Wilson (Slow) 2012/06/20 05:23:41 Sorry, I meant to say "DCHECK(!backend_start_timer
peria 2012/06/20 09:20:17 I got it. Thank you for your explanation. But it c
Andrew T Wilson (Slow) 2012/06/20 16:40:27 Isn't that a bug, then? Shouldn't the timeout time
peria 2012/06/21 06:45:32 Yes, it is, even though it works without erros. A
+ backend_start_timer_->Start(FROM_HERE,
+ base::TimeDelta::FromSeconds(kTimeoutSec),
+ this, &SyncSetupHandler::DisplayTimeout);
+ web_ui()->CallJavascriptFunction(
+ "SyncSetupOverlay.showSyncSetupPage", page, args);
+}
+
+// TODO(kochi): Handle error conditions other than timeout.
+// http://crbug.com/128692
+void SyncSetupHandler::DisplayTimeout() {
+ configuring_sync_ = false;
Andrew T Wilson (Slow) 2012/06/20 00:12:02 I'm slightly nervous about leaving sync setup runn
peria 2012/06/20 04:06:03 SGTM. Done.
+ StringValue page("timeout");
+ DictionaryValue args;
+
web_ui()->CallJavascriptFunction(
"SyncSetupOverlay.showSyncSetupPage", page, args);
}
@@ -662,6 +681,10 @@ void SyncSetupHandler::GaiaCredentialsValid() {
}
void SyncSetupHandler::SigninFailed(const GoogleServiceAuthError& error) {
+ // Stop a timer to handle timeout in waiting for checking network connection.
+ if (backend_start_timer_.get())
Andrew T Wilson (Slow) 2012/06/20 00:12:02 No need to do a .get() first - just call reset().
peria 2012/06/20 04:06:03 Done.
+ backend_start_timer_.reset();
+
last_signin_error_ = error;
// Got a failed signin - this is either just a typical auth error, or a
// sync error (treat sync errors as "fatal errors" - i.e. non-auth errors).
@@ -684,6 +707,10 @@ ProfileSyncService* SyncSetupHandler::GetSyncService() const {
void SyncSetupHandler::SigninSuccess() {
DCHECK(GetSyncService()->sync_initialized());
+ // Stop a timer to handle timeout in waiting for checking network connection.
+ if (backend_start_timer_.get())
Andrew T Wilson (Slow) 2012/06/20 00:12:02 Just call reset(), don't bother checking get() fir
peria 2012/06/20 04:06:03 Done.
+ backend_start_timer_.reset();
+
// If we have signed in while sync is already setup, it must be due to some
// kind of re-authentication flow. In that case, just close the signin dialog
// rather than forcing the user to go through sync configuration.
« chrome/app/generated_resources.grd ('K') | « chrome/browser/ui/webui/sync_setup_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698