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

Side by Side Diff: chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc

Issue 8113025: base::Bind: More converts, mostly in WebUI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes. Created 9 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 void MobileSetupHandler::HandleSetTransactionStatus(const ListValue* args) { 519 void MobileSetupHandler::HandleSetTransactionStatus(const ListValue* args) {
520 const size_t kSetTransactionStatusParamCount = 1; 520 const size_t kSetTransactionStatusParamCount = 1;
521 if (args->GetSize() != kSetTransactionStatusParamCount) 521 if (args->GetSize() != kSetTransactionStatusParamCount)
522 return; 522 return;
523 // Get change callback function name. 523 // Get change callback function name.
524 std::string status; 524 std::string status;
525 if (!args->GetString(0, &status)) 525 if (!args->GetString(0, &status))
526 return; 526 return;
527 scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr(), status); 527 scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr(), status);
528 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 528 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
529 NewRunnableMethod(task.get(), &TaskProxy::HandleSetTransactionStatus)); 529 base::Bind(&TaskProxy::HandleSetTransactionStatus, task.get()));
530 } 530 }
531 531
532 void MobileSetupHandler::InitiateActivation() { 532 void MobileSetupHandler::InitiateActivation() {
533 scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr(), 0); 533 scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr(), 0);
534 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 534 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
535 NewRunnableMethod(task.get(), &TaskProxy::HandleStartActivation)); 535 base::Bind(&TaskProxy::HandleStartActivation, task.get()));
536 } 536 }
537 537
538 void MobileSetupHandler::StartActivation() { 538 void MobileSetupHandler::StartActivation() {
539 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 539 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
540 chromeos::NetworkLibrary* lib = 540 chromeos::NetworkLibrary* lib =
541 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); 541 chromeos::CrosLibrary::Get()->GetNetworkLibrary();
542 chromeos::CellularNetwork* network = GetCellularNetwork(service_path_); 542 chromeos::CellularNetwork* network = GetCellularNetwork(service_path_);
543 // Check if we can start activation process. 543 // Check if we can start activation process.
544 if (!network || already_running_) { 544 if (!network || already_running_) {
545 std::string error; 545 std::string error;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 connection_retry_count_++; 676 connection_retry_count_++;
677 connection_start_time_ = base::Time::Now(); 677 connection_start_time_ = base::Time::Now();
678 if (!network) { 678 if (!network) {
679 LOG(WARNING) << "Connect failed." 679 LOG(WARNING) << "Connect failed."
680 << (network ? network->service_path().c_str() : "no service"); 680 << (network ? network->service_path().c_str() : "no service");
681 // If we coudn't connect during reconnection phase, try to reconnect 681 // If we coudn't connect during reconnection phase, try to reconnect
682 // with a delay (and try to reconnect if needed). 682 // with a delay (and try to reconnect if needed).
683 scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr(), 683 scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr(),
684 delay); 684 delay);
685 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, 685 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE,
686 NewRunnableMethod(task.get(), &TaskProxy::ContinueConnecting), 686 base::Bind(&TaskProxy::ContinueConnecting, task.get()), delay);
687 delay);
688 return false; 687 return false;
689 } 688 }
690 chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> 689 chromeos::CrosLibrary::Get()->GetNetworkLibrary()->
691 ConnectToCellularNetwork(network); 690 ConnectToCellularNetwork(network);
692 return true; 691 return true;
693 } 692 }
694 693
695 void MobileSetupHandler::ForceReconnect( 694 void MobileSetupHandler::ForceReconnect(
696 chromeos::CellularNetwork* network, 695 chromeos::CellularNetwork* network,
697 int delay) { 696 int delay) {
698 DCHECK(network); 697 DCHECK(network);
699 UMA_HISTOGRAM_COUNTS("Cellular.ActivationRetry", 1); 698 UMA_HISTOGRAM_COUNTS("Cellular.ActivationRetry", 1);
700 // Reset reconnect metrics. 699 // Reset reconnect metrics.
701 connection_retry_count_ = 0; 700 connection_retry_count_ = 0;
702 connection_start_time_ = base::Time(); 701 connection_start_time_ = base::Time();
703 // First, disconnect... 702 // First, disconnect...
704 LOG(INFO) << "Disconnecting from " << network->service_path(); 703 LOG(INFO) << "Disconnecting from " << network->service_path();
705 chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> 704 chromeos::CrosLibrary::Get()->GetNetworkLibrary()->
706 DisconnectFromNetwork(network); 705 DisconnectFromNetwork(network);
707 // Check the network state 3s after we disconnect to make sure. 706 // Check the network state 3s after we disconnect to make sure.
708 scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr(), 707 scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr(),
709 delay); 708 delay);
710 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, 709 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE,
711 NewRunnableMethod(task.get(), &TaskProxy::ContinueConnecting), 710 base::Bind(&TaskProxy::ContinueConnecting, task.get()), delay);
712 delay);
713 } 711 }
714 712
715 bool MobileSetupHandler::ConnectionTimeout() { 713 bool MobileSetupHandler::ConnectionTimeout() {
716 return (base::Time::Now() - 714 return (base::Time::Now() -
717 connection_start_time_).InSeconds() > kConnectionTimeoutSeconds; 715 connection_start_time_).InSeconds() > kConnectionTimeoutSeconds;
718 } 716 }
719 717
720 void MobileSetupHandler::EvaluateCellularNetwork( 718 void MobileSetupHandler::EvaluateCellularNetwork(
721 chromeos::CellularNetwork* network) { 719 chromeos::CellularNetwork* network) {
722 if (!web_ui_) 720 if (!web_ui_)
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 UpdatePage(network, error_description); 1094 UpdatePage(network, error_description);
1097 1095
1098 // Pick action that should happen on entering the new state. 1096 // Pick action that should happen on entering the new state.
1099 switch (new_state) { 1097 switch (new_state) {
1100 case PLAN_ACTIVATION_START: 1098 case PLAN_ACTIVATION_START:
1101 break; 1099 break;
1102 case PLAN_ACTIVATION_DELAY_OTASP: { 1100 case PLAN_ACTIVATION_DELAY_OTASP: {
1103 UMA_HISTOGRAM_COUNTS("Cellular.RetryOTASP", 1); 1101 UMA_HISTOGRAM_COUNTS("Cellular.RetryOTASP", 1);
1104 scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr(), 0); 1102 scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr(), 0);
1105 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, 1103 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE,
1106 NewRunnableMethod(task.get(), &TaskProxy::RetryOTASP), 1104 base::Bind(&TaskProxy::RetryOTASP, task.get()), kOTASPRetryDelay);
1107 kOTASPRetryDelay);
1108 break; 1105 break;
1109 } 1106 }
1110 case PLAN_ACTIVATION_INITIATING_ACTIVATION: 1107 case PLAN_ACTIVATION_INITIATING_ACTIVATION:
1111 case PLAN_ACTIVATION_TRYING_OTASP: 1108 case PLAN_ACTIVATION_TRYING_OTASP:
1112 case PLAN_ACTIVATION_OTASP: 1109 case PLAN_ACTIVATION_OTASP:
1113 DCHECK(network); 1110 DCHECK(network);
1114 LOG(WARNING) << "Activating service " << network->service_path().c_str(); 1111 LOG(WARNING) << "Activating service " << network->service_path().c_str();
1115 UMA_HISTOGRAM_COUNTS("Cellular.ActivationTry", 1); 1112 UMA_HISTOGRAM_COUNTS("Cellular.ActivationTry", 1);
1116 if (!network->StartActivation()) { 1113 if (!network->StartActivation()) {
1117 UMA_HISTOGRAM_COUNTS("Cellular.ActivationFailure", 1); 1114 UMA_HISTOGRAM_COUNTS("Cellular.ActivationFailure", 1);
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 MobileSetupHandler* handler = new MobileSetupHandler(service_path); 1326 MobileSetupHandler* handler = new MobileSetupHandler(service_path);
1330 AddMessageHandler((handler)->Attach(this)); 1327 AddMessageHandler((handler)->Attach(this));
1331 handler->Init(contents); 1328 handler->Init(contents);
1332 MobileSetupUIHTMLSource* html_source = 1329 MobileSetupUIHTMLSource* html_source =
1333 new MobileSetupUIHTMLSource(service_path); 1330 new MobileSetupUIHTMLSource(service_path);
1334 1331
1335 // Set up the chrome://mobilesetup/ source. 1332 // Set up the chrome://mobilesetup/ source.
1336 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); 1333 Profile* profile = Profile::FromBrowserContext(contents->browser_context());
1337 profile->GetChromeURLDataManager()->AddDataSource(html_source); 1334 profile->GetChromeURLDataManager()->AddDataSource(html_source);
1338 } 1335 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc ('k') | chrome/browser/ui/webui/chromeos/register_page_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698