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

Unified Diff: chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc

Issue 5147004: Added [Close] button on completed activation overlay div.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/mobile_setup.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc
===================================================================
--- chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc (revision 66346)
+++ chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc (working copy)
@@ -69,6 +69,11 @@
const char kVersionField[] = "version";
const char kErrorsField[] = "errors";
+// Number of times we will retry to reconnect if connection fails.
+const int kMaxConnectionRetry = 10;
+// Connection timeout in seconds.
+const int kConnectionTimeoutSeconds = 30;
+
chromeos::CellularNetwork* GetCellularNetwork() {
chromeos::NetworkLibrary* lib = chromeos::CrosLibrary::Get()->
GetNetworkLibrary();
@@ -190,6 +195,10 @@
// Sends message to host registration page with system/user info data.
void SendDeviceInfo();
+ // Connects to cellular network, resets connection timer.
+ void ConnectToNetwork(chromeos::CellularNetwork* network);
+ // Reports connection timeout.
+ bool ConnectionTimeout();
// Verify the state of cellular network and modify internal state.
void EvaluateCellularNetwork(chromeos::CellularNetwork* network);
// Check the current cellular network for error conditions.
@@ -243,6 +252,10 @@
bool transaction_complete_signalled_;
bool activation_status_test_;
bool evaluating_;
+ // Connection retry counter.
+ int connection_retry_count_;
+ // Connection start time.
+ base::Time connection_start_time_;
DISALLOW_COPY_AND_ASSIGN(MobileSetupHandler);
};
@@ -328,6 +341,8 @@
l10n_util::GetStringUTF16(IDS_MOBILE_COMPLETED_HEADER));
strings.SetString("completed_text",
l10n_util::GetStringUTF16(IDS_MOBILE_COMPLETED_TEXT));
+ strings.SetString("close_button",
+ l10n_util::GetStringUTF16(IDS_CLOSE));
SetFontAndTextDirection(&strings);
static const base::StringPiece html(
@@ -357,7 +372,8 @@
reenable_cert_check_(false),
transaction_complete_signalled_(false),
activation_status_test_(false),
- evaluating_(false) {
+ evaluating_(false),
+ connection_retry_count_(0) {
}
MobileSetupHandler::~MobileSetupHandler() {
@@ -470,6 +486,19 @@
}
}
+
+void MobileSetupHandler::ConnectToNetwork(chromeos::CellularNetwork* network) {
+ connection_retry_count_++;
+ connection_start_time_ = base::Time::Now();
+ chromeos::CrosLibrary::Get()->GetNetworkLibrary()->
+ ConnectToCellularNetwork(network);
+}
+
+bool MobileSetupHandler::ConnectionTimeout() {
+ return (base::Time::Now() -
+ connection_start_time_).InSeconds() > kConnectionTimeoutSeconds;
+}
+
void MobileSetupHandler::EvaluateCellularNetwork(
chromeos::CellularNetwork* network) {
if (!dom_ui_)
@@ -587,30 +616,35 @@
break;
}
case PLAN_ACTIVATION_RECONNECTING: {
- // Wait until the service shows up and gets activated.
- switch (network->activation_state()) {
- case chromeos::ACTIVATION_STATE_ACTIVATED:
- if (network->connected()) {
- if (network->restricted_pool()) {
+ if (network->connected()) {
+ // Wait until the service shows up and gets activated.
+ switch (network->activation_state()) {
+ case chromeos::ACTIVATION_STATE_ACTIVATED:
+ if (network->restricted_pool())
new_state = PLAN_ACTIVATION_SHOWING_PAYMENT;
- } else {
+ else
new_state = PLAN_ACTIVATION_DONE;
- }
- } else if (network->failed()) {
- chromeos::CrosLibrary::Get()->GetNetworkLibrary()->
- ConnectToCellularNetwork(network);
- evaluating_ = false;
- return;
- }
- break;
- case chromeos::ACTIVATION_STATE_PARTIALLY_ACTIVATED:
- if (network->connected()) {
+ break;
+ case chromeos::ACTIVATION_STATE_PARTIALLY_ACTIVATED:
if (network->restricted_pool())
new_state = PLAN_ACTIVATION_SHOWING_PAYMENT;
- }
- break;
- default:
- break;
+ break;
+ default:
+ break;
+ }
+ } else if (network->failed() || ConnectionTimeout()) {
+ // Try to reconnect again if reconnect failed, or if for some
+ // reasons we are still not connected after 30 seconds.
+ if (connection_retry_count_ < kMaxConnectionRetry) {
+ UMA_HISTOGRAM_COUNTS("Cellular.ConnectionRetry", 1);
+ ConnectToNetwork(network);
+ evaluating_ = false;
+ return;
+ } else {
+ // We simply can't connect anymore after all these tries.
+ UMA_HISTOGRAM_COUNTS("Cellular.ConnectionFailed", 1);
+ new_state = PLAN_ACTIVATION_ERROR;
+ }
}
break;
}
@@ -625,7 +659,8 @@
}
std::string error_description;
- if (GotActivationError(network, &error_description)) {
+ if (new_state != PLAN_ACTIVATION_ERROR &&
+ GotActivationError(network, &error_description)) {
// Check for this special case when we try to do activate partially
// activated device. If that attempt failed, try to disconnect to clear the
// state and reconnect again.
@@ -728,11 +763,10 @@
}
break;
case PLAN_ACTIVATION_RECONNECTING: {
- DCHECK(network);
- if (network) {
- chromeos::CrosLibrary::Get()->GetNetworkLibrary()->
- ConnectToCellularNetwork(network);
- }
+ // Reset connection metrics and try to connect.
+ connection_retry_count_ = 0;
+ connection_start_time_ = base::Time::Now();
+ ConnectToNetwork(network);
break;
}
case PLAN_ACTIVATION_PAGE_LOADING:
« no previous file with comments | « no previous file | chrome/browser/resources/mobile_setup.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698