OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/webui/chromeos/mobile_setup_ui.h" | 5 #include "chrome/browser/ui/webui/chromeos/mobile_setup_ui.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
737 | 737 |
738 bool MobileSetupHandler::ConnectToNetwork( | 738 bool MobileSetupHandler::ConnectToNetwork( |
739 chromeos::CellularNetwork* network, | 739 chromeos::CellularNetwork* network, |
740 int delay) { | 740 int delay) { |
741 if (network && network->connecting_or_connected()) | 741 if (network && network->connecting_or_connected()) |
742 return true; | 742 return true; |
743 // Permit network connection changes only in reconnecting states. | 743 // Permit network connection changes only in reconnecting states. |
744 if (state_ != PLAN_ACTIVATION_RECONNECTING_OTASP_TRY && | 744 if (state_ != PLAN_ACTIVATION_RECONNECTING_OTASP_TRY && |
745 state_ != PLAN_ACTIVATION_RECONNECTING && | 745 state_ != PLAN_ACTIVATION_RECONNECTING && |
746 state_ != PLAN_ACTIVATION_RECONNECTING_PAYMENT && | 746 state_ != PLAN_ACTIVATION_RECONNECTING_PAYMENT && |
747 state_ != PLAN_ACTIVATION_RECONNECTING_OTASP) | 747 state_ != PLAN_ACTIVATION_RECONNECTING_OTASP) return false; |
Mark Mentovai
2012/04/09 22:55:58
This too.
| |
748 return false; | |
749 if (network) | 748 if (network) |
750 LOG(INFO) << "Connecting to: " << network->service_path(); | 749 LOG(INFO) << "Connecting to: " << network->service_path(); |
751 connection_retry_count_++; | 750 connection_retry_count_++; |
752 connection_start_time_ = base::Time::Now(); | 751 connection_start_time_ = base::Time::Now(); |
753 if (!network) { | 752 if (!network) { |
754 LOG(WARNING) << "Connect failed." | 753 LOG(WARNING) << "Connect failed." |
755 << (network ? network->service_path().c_str() : "no service"); | 754 << (network ? network->service_path().c_str() : "no service"); |
756 // If we coudn't connect during reconnection phase, try to reconnect | 755 // If we coudn't connect during reconnection phase, try to reconnect |
757 // with a delay (and try to reconnect if needed). | 756 // with a delay (and try to reconnect if needed). |
758 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, | 757 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, |
759 base::Bind(&MobileSetupHandler::ContinueConnecting, AsWeakPtr(), delay), | 758 base::Bind(&MobileSetupHandler::ContinueConnecting, AsWeakPtr(), delay), |
760 delay); | 759 base::TimeDelta::FromMilliseconds(delay)); |
761 return false; | 760 return false; |
762 } | 761 } |
763 chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> | 762 chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> |
764 ConnectToCellularNetwork(network); | 763 ConnectToCellularNetwork(network); |
765 return true; | 764 return true; |
766 } | 765 } |
767 | 766 |
768 void MobileSetupHandler::ForceReconnect( | 767 void MobileSetupHandler::ForceReconnect( |
769 chromeos::CellularNetwork* network, | 768 chromeos::CellularNetwork* network, |
770 int delay) { | 769 int delay) { |
771 DCHECK(network); | 770 DCHECK(network); |
772 UMA_HISTOGRAM_COUNTS("Cellular.ActivationRetry", 1); | 771 UMA_HISTOGRAM_COUNTS("Cellular.ActivationRetry", 1); |
773 // Reset reconnect metrics. | 772 // Reset reconnect metrics. |
774 connection_retry_count_ = 0; | 773 connection_retry_count_ = 0; |
775 connection_start_time_ = base::Time(); | 774 connection_start_time_ = base::Time(); |
776 // First, disconnect... | 775 // First, disconnect... |
777 LOG(INFO) << "Disconnecting from " << network->service_path(); | 776 LOG(INFO) << "Disconnecting from " << network->service_path(); |
778 chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> | 777 chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> |
779 DisconnectFromNetwork(network); | 778 DisconnectFromNetwork(network); |
780 // Check the network state 3s after we disconnect to make sure. | 779 // Check the network state 3s after we disconnect to make sure. |
781 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, | 780 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, |
782 base::Bind(&MobileSetupHandler::ContinueConnecting, AsWeakPtr(), delay), | 781 base::Bind(&MobileSetupHandler::ContinueConnecting, AsWeakPtr(), delay), |
783 delay); | 782 base::TimeDelta::FromMilliseconds(delay)); |
784 } | 783 } |
785 | 784 |
786 bool MobileSetupHandler::ConnectionTimeout() { | 785 bool MobileSetupHandler::ConnectionTimeout() { |
787 return (base::Time::Now() - | 786 return (base::Time::Now() - |
788 connection_start_time_).InSeconds() > kConnectionTimeoutSeconds; | 787 connection_start_time_).InSeconds() > kConnectionTimeoutSeconds; |
789 } | 788 } |
790 | 789 |
791 void MobileSetupHandler::EvaluateCellularNetwork( | 790 void MobileSetupHandler::EvaluateCellularNetwork( |
792 chromeos::CellularNetwork* network) { | 791 chromeos::CellularNetwork* network) { |
793 if (!web_ui()) | 792 if (!web_ui()) |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1178 UpdatePage(network, error_description); | 1177 UpdatePage(network, error_description); |
1179 | 1178 |
1180 // Pick action that should happen on entering the new state. | 1179 // Pick action that should happen on entering the new state. |
1181 switch (new_state) { | 1180 switch (new_state) { |
1182 case PLAN_ACTIVATION_START: | 1181 case PLAN_ACTIVATION_START: |
1183 break; | 1182 break; |
1184 case PLAN_ACTIVATION_DELAY_OTASP: { | 1183 case PLAN_ACTIVATION_DELAY_OTASP: { |
1185 UMA_HISTOGRAM_COUNTS("Cellular.RetryOTASP", 1); | 1184 UMA_HISTOGRAM_COUNTS("Cellular.RetryOTASP", 1); |
1186 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, | 1185 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, |
1187 base::Bind(&MobileSetupHandler::RetryOTASP, AsWeakPtr()), | 1186 base::Bind(&MobileSetupHandler::RetryOTASP, AsWeakPtr()), |
1188 kOTASPRetryDelay); | 1187 base::TimeDelta::FromMilliseconds(kOTASPRetryDelay)); |
1189 break; | 1188 break; |
1190 } | 1189 } |
1191 case PLAN_ACTIVATION_INITIATING_ACTIVATION: | 1190 case PLAN_ACTIVATION_INITIATING_ACTIVATION: |
1192 case PLAN_ACTIVATION_TRYING_OTASP: | 1191 case PLAN_ACTIVATION_TRYING_OTASP: |
1193 case PLAN_ACTIVATION_OTASP: | 1192 case PLAN_ACTIVATION_OTASP: |
1194 DCHECK(network); | 1193 DCHECK(network); |
1195 LOG(WARNING) << "Activating service " << network->service_path().c_str(); | 1194 LOG(WARNING) << "Activating service " << network->service_path().c_str(); |
1196 UMA_HISTOGRAM_COUNTS("Cellular.ActivationTry", 1); | 1195 UMA_HISTOGRAM_COUNTS("Cellular.ActivationTry", 1); |
1197 if (!network->StartActivation()) { | 1196 if (!network->StartActivation()) { |
1198 UMA_HISTOGRAM_COUNTS("Cellular.ActivationFailure", 1); | 1197 UMA_HISTOGRAM_COUNTS("Cellular.ActivationFailure", 1); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1402 | 1401 |
1403 // Set up the chrome://mobilesetup/ source. | 1402 // Set up the chrome://mobilesetup/ source. |
1404 Profile* profile = Profile::FromWebUI(web_ui); | 1403 Profile* profile = Profile::FromWebUI(web_ui); |
1405 profile->GetChromeURLDataManager()->AddDataSource(html_source); | 1404 profile->GetChromeURLDataManager()->AddDataSource(html_source); |
1406 } | 1405 } |
1407 | 1406 |
1408 void MobileSetupUI::RenderViewCreated(RenderViewHost* host) { | 1407 void MobileSetupUI::RenderViewCreated(RenderViewHost* host) { |
1409 // Destroyed by the corresponding RenderViewHost | 1408 // Destroyed by the corresponding RenderViewHost |
1410 new PortalFrameLoadObserver(AsWeakPtr(), host); | 1409 new PortalFrameLoadObserver(AsWeakPtr(), host); |
1411 } | 1410 } |
OLD | NEW |