diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-04 20:28:56 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-04 20:28:56 +0000 |
commit | cf7c614663817b1532652e5687028a9069469886 (patch) | |
tree | 0f68396c9e7bffaaaf3ee73c5e7747addb2cf6a9 | |
parent | df5536d0084ac6d27d9219202cb07b9248760330 (diff) | |
download | chromium_src-cf7c614663817b1532652e5687028a9069469886.zip chromium_src-cf7c614663817b1532652e5687028a9069469886.tar.gz chromium_src-cf7c614663817b1532652e5687028a9069469886.tar.bz2 |
base::Bind: More converts, mostly in WebUI.
BUG=none
TEST=none
R=csilv@chromium.org,ajwong@chromium.org
Review URL: http://codereview.chromium.org/8113025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103978 0039d316-1c4b-4281-b951-d872f2087c98
22 files changed, 106 insertions, 103 deletions
diff --git a/base/callback.h b/base/callback.h index 03abb4b..7579cef 100644 --- a/base/callback.h +++ b/base/callback.h @@ -25,7 +25,7 @@ // with the Bind() function in bind.h, they provide a type-safe method for // performing currying of arguments, and creating a "closure." // -// In programing languages, a closure is a first-class function where all its +// In programming languages, a closure is a first-class function where all its // parameters have been bound (usually via currying). Closures are well // suited for representing, and passing around a unit of delayed execution. // They are used in Chromium code to schedule tasks on different MessageLoops. diff --git a/base/callback.h.pump b/base/callback.h.pump index 82b643e..8aecdc8 100644 --- a/base/callback.h.pump +++ b/base/callback.h.pump @@ -28,7 +28,7 @@ $var MAX_ARITY = 6 // with the Bind() function in bind.h, they provide a type-safe method for // performing currying of arguments, and creating a "closure." // -// In programing languages, a closure is a first-class function where all its +// In programming languages, a closure is a first-class function where all its // parameters have been bound (usually via currying). Closures are well // suited for representing, and passing around a unit of delayed execution. // They are used in Chromium code to schedule tasks on different MessageLoops. diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc index d4a0763..33fb627 100644 --- a/chrome/browser/browser_about_handler.cc +++ b/chrome/browser/browser_about_handler.cc @@ -8,7 +8,8 @@ #include <string> #include <vector> -#include "base/callback.h" +#include "base/bind.h" +#include "base/bind_helpers.h" #include "base/command_line.h" #include "base/file_util.h" #include "base/i18n/number_formatting.h" @@ -1365,7 +1366,8 @@ ChromeOSAboutVersionHandler::ChromeOSAboutVersionHandler( : source_(source), request_id_(request_id) { loader_.GetVersion(&consumer_, - NewCallback(this, &ChromeOSAboutVersionHandler::OnVersion), + base::Bind(&ChromeOSAboutVersionHandler::OnVersion, + base::Unretained(this)), chromeos::VersionLoader::VERSION_FULL); } diff --git a/chrome/browser/chromeos/login/version_info_updater.cc b/chrome/browser/chromeos/login/version_info_updater.cc index a33259e..375c909 100644 --- a/chrome/browser/chromeos/login/version_info_updater.cc +++ b/chrome/browser/chromeos/login/version_info_updater.cc @@ -7,6 +7,8 @@ #include <string> #include <vector> +#include "base/bind.h" +#include "base/bind_helpers.h" #include "base/string16.h" #include "base/string_util.h" #include "base/stringprintf.h" @@ -41,7 +43,7 @@ void VersionInfoUpdater::StartUpdate(bool is_official_build) { if (CrosLibrary::Get()->EnsureLoaded()) { version_loader_.GetVersion( &version_consumer_, - NewCallback(this, &VersionInfoUpdater::OnVersion), + base::Bind(&VersionInfoUpdater::OnVersion, base::Unretained(this)), is_official_build ? VersionLoader::VERSION_SHORT_WITH_DATE : VersionLoader::VERSION_FULL); diff --git a/chrome/browser/chromeos/system/syslogs_provider.cc b/chrome/browser/chromeos/system/syslogs_provider.cc index 271f42a..48352b0 100644 --- a/chrome/browser/chromeos/system/syslogs_provider.cc +++ b/chrome/browser/chromeos/system/syslogs_provider.cc @@ -175,7 +175,7 @@ class SyslogsProviderImpl : public SyslogsProvider { bool compress_logs, SyslogsContext context, CancelableRequestConsumerBase* consumer, - ReadCompleteCallback* callback); + const ReadCompleteCallback& callback); // Reads system logs, compresses content if requested. // Called from FILE thread. @@ -208,7 +208,7 @@ CancelableRequestProvider::Handle SyslogsProviderImpl::RequestSyslogs( bool compress_logs, SyslogsContext context, CancelableRequestConsumerBase* consumer, - ReadCompleteCallback* callback) { + const ReadCompleteCallback& callback) { // Register the callback request. scoped_refptr<CancelableRequest<ReadCompleteCallback> > request( new CancelableRequest<ReadCompleteCallback>(callback)); @@ -285,8 +285,7 @@ class SyslogsMemoryHandler : public MemoryDetails { } (*logs_)["mem_usage"] = mem_string; // This will call the callback on the calling thread. - request_->ForwardResult( - Tuple2<LogDictionaryType*, std::string*>(logs_, zip_content_)); + request_->ForwardResult(logs_, zip_content_); } private: diff --git a/chrome/browser/chromeos/system/syslogs_provider.h b/chrome/browser/chromeos/system/syslogs_provider.h index ecb92b6..9279654 100644 --- a/chrome/browser/chromeos/system/syslogs_provider.h +++ b/chrome/browser/chromeos/system/syslogs_provider.h @@ -8,7 +8,7 @@ #include <string> -#include "base/callback_old.h" +#include "base/callback.h" #include "content/browser/cancelable_request.h" class CancelableRequestConsumerBase; @@ -24,8 +24,8 @@ class SyslogsProvider : public CancelableRequestProvider { static SyslogsProvider* GetInstance(); // The callback type used with RequestSyslogs(). - typedef Callback2<LogDictionaryType*, - std::string*>::Type ReadCompleteCallback; + typedef base::Callback<void(LogDictionaryType*, + std::string*)> ReadCompleteCallback; // Used to specify the syslogs context with RequestSyslogs(). enum SyslogsContext { @@ -44,7 +44,7 @@ class SyslogsProvider : public CancelableRequestProvider { bool compress_logs, SyslogsContext context, CancelableRequestConsumerBase* consumer, - ReadCompleteCallback* callback) = 0; + const ReadCompleteCallback& callback) = 0; protected: virtual ~SyslogsProvider() {} diff --git a/chrome/browser/chromeos/version_loader.cc b/chrome/browser/chromeos/version_loader.cc index 80237397..cebed17 100644 --- a/chrome/browser/chromeos/version_loader.cc +++ b/chrome/browser/chromeos/version_loader.cc @@ -44,7 +44,7 @@ const char VersionLoader::kFirmwarePrefix[] = "version"; VersionLoader::Handle VersionLoader::GetVersion( CancelableRequestConsumerBase* consumer, - VersionLoader::GetVersionCallback* callback, + const VersionLoader::GetVersionCallback& callback, VersionFormat format) { if (!g_browser_process->file_thread()) { // This should only happen if Chrome is shutting down, so we don't do @@ -63,7 +63,7 @@ VersionLoader::Handle VersionLoader::GetVersion( VersionLoader::Handle VersionLoader::GetFirmware( CancelableRequestConsumerBase* consumer, - VersionLoader::GetFirmwareCallback* callback) { + const VersionLoader::GetFirmwareCallback& callback) { if (!g_browser_process->file_thread()) { // This should only happen if Chrome is shutting down, so we don't do // anything. @@ -154,8 +154,7 @@ void VersionLoader::Backend::GetVersion( } } - request->ForwardResult(GetVersionCallback::TupleType(request->handle(), - version)); + request->ForwardResult(request->handle(), version); } void VersionLoader::Backend::GetFirmware( @@ -171,8 +170,7 @@ void VersionLoader::Backend::GetFirmware( firmware = ParseFirmware(contents); } - request->ForwardResult(GetFirmwareCallback::TupleType(request->handle(), - firmware)); + request->ForwardResult(request->handle(), firmware); } } // namespace chromeos diff --git a/chrome/browser/chromeos/version_loader.h b/chrome/browser/chromeos/version_loader.h index 1560b18..e035275 100644 --- a/chrome/browser/chromeos/version_loader.h +++ b/chrome/browser/chromeos/version_loader.h @@ -8,7 +8,7 @@ #include <string> -#include "base/callback_old.h" +#include "base/callback.h" #include "base/gtest_prod_util.h" #include "content/browser/cancelable_request.h" @@ -43,21 +43,21 @@ class VersionLoader : public CancelableRequestProvider { }; // Signature - typedef Callback2<Handle, std::string>::Type GetVersionCallback; + typedef base::Callback<void(Handle, std::string)> GetVersionCallback; typedef CancelableRequest<GetVersionCallback> GetVersionRequest; - typedef Callback2<Handle, std::string>::Type GetFirmwareCallback; + typedef base::Callback<void(Handle, std::string)> GetFirmwareCallback; typedef CancelableRequest<GetFirmwareCallback> GetFirmwareRequest; // Asynchronously requests the version. // If |full_version| is true version string with extra info is extracted, // otherwise it's in short format x.x.xx.x. Handle GetVersion(CancelableRequestConsumerBase* consumer, - GetVersionCallback* callback, + const GetVersionCallback& callback, VersionFormat format); Handle GetFirmware(CancelableRequestConsumerBase* consumer, - GetFirmwareCallback* callback); + const GetFirmwareCallback& callback); // Parse the version information as a Chrome platfrom, not Chrome OS // TODO(rkc): Change this and everywhere it is used once we switch Chrome OS diff --git a/chrome/browser/ui/webui/bug_report_ui.cc b/chrome/browser/ui/webui/bug_report_ui.cc index 57b4917..1218089 100644 --- a/chrome/browser/ui/webui/bug_report_ui.cc +++ b/chrome/browser/ui/webui/bug_report_ui.cc @@ -8,7 +8,6 @@ #include "base/bind.h" #include "base/bind_helpers.h" -#include "base/callback_old.h" #include "base/logging.h" #include "base/memory/weak_ptr.h" #include "base/message_loop.h" @@ -434,7 +433,8 @@ void BugReportHandler::HandleGetDialogDefaults(const ListValue*) { true, // don't compress. chromeos::system::SyslogsProvider::SYSLOGS_FEEDBACK, &syslogs_consumer_, - NewCallback(bug_report_data_, &BugReportData::SyslogsComplete)); + base::Bind(&BugReportData::SyslogsComplete, + base::Unretained(bug_report_data_))); } // 2: user e-mail dialog_defaults.Append(new StringValue(GetUserEmail())); diff --git a/chrome/browser/ui/webui/chrome_url_data_manager.cc b/chrome/browser/ui/webui/chrome_url_data_manager.cc index 967f1a5..ef83c23 100644 --- a/chrome/browser/ui/webui/chrome_url_data_manager.cc +++ b/chrome/browser/ui/webui/chrome_url_data_manager.cc @@ -6,6 +6,7 @@ #include <vector> +#include "base/bind.h" #include "base/i18n/rtl.h" #include "base/memory/ref_counted_memory.h" #include "base/memory/scoped_ptr.h" @@ -50,9 +51,8 @@ void ChromeURLDataManager::AddDataSource(DataSource* source) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - NewRunnableFunction(AddDataSourceOnIOThread, - backend_, - make_scoped_refptr(source))); + base::Bind(&AddDataSourceOnIOThread, + backend_, make_scoped_refptr(source))); } // static diff --git a/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc b/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc index f205f31..3f018ec 100644 --- a/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc +++ b/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc @@ -5,10 +5,12 @@ #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h" #include "base/basictypes.h" +#include "base/bind.h" #include "base/command_line.h" #include "base/compiler_specific.h" #include "base/file_util.h" #include "base/memory/ref_counted_memory.h" +#include "base/memory/weak_ptr.h" #include "base/message_loop.h" #include "base/path_service.h" #include "base/string_util.h" @@ -114,7 +116,7 @@ class URLRequestChromeJob : public net::URLRequestJob { // The backend is owned by ChromeURLRequestContext and always outlives us. ChromeURLDataManagerBackend* backend_; - ScopedRunnableMethodFactory<URLRequestChromeJob> method_factory_; + base::WeakPtrFactory<URLRequestChromeJob> weak_factory_; DISALLOW_COPY_AND_ASSIGN(URLRequestChromeJob); }; @@ -125,7 +127,7 @@ URLRequestChromeJob::URLRequestChromeJob(net::URLRequest* request, data_offset_(0), pending_buf_size_(0), backend_(backend), - ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { + ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { DCHECK(backend); } @@ -136,8 +138,10 @@ URLRequestChromeJob::~URLRequestChromeJob() { void URLRequestChromeJob::Start() { // Start reading asynchronously so that all error reporting and data // callbacks happen as they would for network requests. - MessageLoop::current()->PostTask(FROM_HERE, method_factory_.NewRunnableMethod( - &URLRequestChromeJob::StartAsync)); + MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&URLRequestChromeJob::StartAsync, + weak_factory_.GetWeakPtr())); } void URLRequestChromeJob::Kill() { @@ -367,9 +371,8 @@ bool ChromeURLDataManagerBackend::StartRequest(const GURL& url, // usually the UI thread, for this path. target_message_loop->PostTask( FROM_HERE, - NewRunnableMethod(source, - &ChromeURLDataManager::DataSource::StartDataRequest, - path, context->is_incognito(), request_id)); + base::Bind(&ChromeURLDataManager::DataSource::StartDataRequest, source, + path, context->is_incognito(), request_id)); } return true; } diff --git a/chrome/browser/ui/webui/chromeos/choose_mobile_network_ui.cc b/chrome/browser/ui/webui/chromeos/choose_mobile_network_ui.cc index 325ef6b..bf3a9bf 100644 --- a/chrome/browser/ui/webui/chromeos/choose_mobile_network_ui.cc +++ b/chrome/browser/ui/webui/chromeos/choose_mobile_network_ui.cc @@ -7,6 +7,8 @@ #include <set> #include <string> +#include "base/bind.h" +#include "base/bind_helpers.h" #include "base/logging.h" #include "base/string_number_conversions.h" #include "base/string_piece.h" @@ -153,13 +155,16 @@ ChooseMobileNetworkHandler::~ChooseMobileNetworkHandler() { void ChooseMobileNetworkHandler::RegisterMessages() { web_ui_->RegisterMessageCallback( kJsApiCancel, - NewCallback(this, &ChooseMobileNetworkHandler::HandleCancel)); + base::Bind(&ChooseMobileNetworkHandler::HandleCancel, + base::Unretained(this))); web_ui_->RegisterMessageCallback( kJsApiConnect, - NewCallback(this, &ChooseMobileNetworkHandler::HandleConnect)); + base::Bind(&ChooseMobileNetworkHandler::HandleConnect, + base::Unretained(this))); web_ui_->RegisterMessageCallback( kJsApiPageReady, - NewCallback(this, &ChooseMobileNetworkHandler::HandlePageReady)); + base::Bind(&ChooseMobileNetworkHandler::HandlePageReady, + base::Unretained(this))); } void ChooseMobileNetworkHandler::OnNetworkDeviceFoundNetworks( diff --git a/chrome/browser/ui/webui/chromeos/imageburner/imageburner_utils.cc b/chrome/browser/ui/webui/chromeos/imageburner/imageburner_utils.cc index b02ce87..b604707 100644 --- a/chrome/browser/ui/webui/chromeos/imageburner/imageburner_utils.cc +++ b/chrome/browser/ui/webui/chromeos/imageburner/imageburner_utils.cc @@ -4,6 +4,7 @@ #include "chrome/browser/ui/webui/chromeos/imageburner/imageburner_utils.h" +#include "base/bind.h" #include "base/path_service.h" #include "base/string_util.h" #include "base/task.h" @@ -236,8 +237,7 @@ void BurnManager::OnDownloadUpdated(DownloadItem* download) { new BurnManagerTaskProxy(); BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - NewRunnableMethod(task.get(), - &BurnManagerTaskProxy::OnConfigFileDownloaded)); + base::Bind(&BurnManagerTaskProxy::OnConfigFileDownloaded, task.get())); } } diff --git a/chrome/browser/ui/webui/chromeos/imageburner/webui_handler.h b/chrome/browser/ui/webui/chromeos/imageburner/webui_handler.h index 3e2c3ec..ee03ab5 100644 --- a/chrome/browser/ui/webui/chromeos/imageburner/webui_handler.h +++ b/chrome/browser/ui/webui/chromeos/imageburner/webui_handler.h @@ -8,6 +8,7 @@ #include <string> +#include "base/bind.h" #include "base/file_path.h" #include "base/string16.h" #include "base/values.h" @@ -56,7 +57,7 @@ class WebUIHandlerTaskProxy void DeleteOnUIThread() { BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - NewRunnableMethod(this, &WebUIHandlerTaskProxy::DoNothing)); + base::Bind(&WebUIHandlerTaskProxy::DoNothing, this)); } void DoNothing() {} diff --git a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc index 6e9d929..d23bb98 100644 --- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc +++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc @@ -66,11 +66,21 @@ std::string SanitizeEmail(const std::string& email) { return sanitized; } +// The Task posted to PostTaskAndReply in StartClearingDnsCache on the IO +// thread. +void ClearDnsCache(IOThread* io_thread) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + if (browser_shutdown::IsTryingToQuit()) + return; + + io_thread->globals()->dnsrr_resolver.get()->OnIPAddressChanged(); +} + } // namespace namespace chromeos { -// Class which observes network state changes and calls registerd callbacks. +// Class which observes network state changes and calls registered callbacks. // State is considered changed if connection or the active network has been // changed. Also, it answers to the requests about current network state. class NetworkStateInformer @@ -103,30 +113,6 @@ class NetworkStateInformer WebUI* web_ui_; }; -// Clears DNS cache on IO thread. -class ClearDnsCacheTaskOnIOThread : public Task { - public: - ClearDnsCacheTaskOnIOThread(Task* callback, IOThread* io_thread) - : callback_(callback), io_thread_(io_thread) { - } - virtual ~ClearDnsCacheTaskOnIOThread() {} - - // Task overrides. - virtual void Run() OVERRIDE { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - if (browser_shutdown::IsTryingToQuit()) - return; - - io_thread_->globals()->dnsrr_resolver.get()->OnIPAddressChanged(); - BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback_); - } - - private: - Task* callback_; - IOThread* io_thread_; - DISALLOW_COPY_AND_ASSIGN(ClearDnsCacheTaskOnIOThread); -}; - // NetworkStateInformer implementation ----------------------------------------- NetworkStateInformer::NetworkStateInformer(WebUI* web_ui) : web_ui_(web_ui) { @@ -199,12 +185,12 @@ SigninScreenHandler::SigninScreenHandler() CommandLine::ForCurrentProcess()->HasSwitch( switches::kWebUILogin)), cookie_remover_(NULL), - ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { + ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { delegate_->SetWebUIHandler(this); } SigninScreenHandler::~SigninScreenHandler() { - method_factory_.RevokeAll(); + weak_factory_.InvalidateWeakPtrs(); if (cookie_remover_) cookie_remover_->RemoveObserver(this); } @@ -616,10 +602,11 @@ void SigninScreenHandler::StartClearingDnsCache() { return; dns_cleared_ = false; - ClearDnsCacheTaskOnIOThread* clear_dns_task = new ClearDnsCacheTaskOnIOThread( - method_factory_.NewRunnableMethod(&SigninScreenHandler::OnDnsCleared), - g_browser_process->io_thread()); - BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, clear_dns_task); + BrowserThread::PostTaskAndReply( + BrowserThread::IO, FROM_HERE, + base::Bind(&ClearDnsCache, g_browser_process->io_thread()), + base::Bind(&SigninScreenHandler::OnDnsCleared, + weak_factory_.GetWeakPtr())); dns_clear_task_running_ = true; } diff --git a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h index 3539b14..be1dd56 100644 --- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h +++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h @@ -9,6 +9,7 @@ #include <string> #include "base/memory/ref_counted.h" +#include "base/memory/weak_ptr.h" #include "base/task.h" #include "chrome/browser/browsing_data_remover.h" #include "chrome/browser/chromeos/login/help_app_launcher.h" @@ -200,7 +201,7 @@ class SigninScreenHandler : public BaseScreenHandler, // Help application used for help dialogs. scoped_refptr<HelpAppLauncher> help_app_; - // Network state infromer used to keep offline message screen up. + // Network state informer used to keep offline message screen up. scoped_ptr<NetworkStateInformer> network_state_informer_; // Email to pre-populate with. @@ -212,7 +213,7 @@ class SigninScreenHandler : public BaseScreenHandler, BrowsingDataRemover* cookie_remover_; - ScopedRunnableMethodFactory<SigninScreenHandler> method_factory_; + base::WeakPtrFactory<SigninScreenHandler> weak_factory_; DISALLOW_COPY_AND_ASSIGN(SigninScreenHandler); }; diff --git a/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc b/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc index d16f28d..1c3e5f4 100644 --- a/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc +++ b/chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc @@ -527,13 +527,13 @@ void MobileSetupHandler::HandleSetTransactionStatus(const ListValue* args) { return; scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr(), status); BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - NewRunnableMethod(task.get(), &TaskProxy::HandleSetTransactionStatus)); + base::Bind(&TaskProxy::HandleSetTransactionStatus, task.get())); } void MobileSetupHandler::InitiateActivation() { scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr(), 0); BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - NewRunnableMethod(task.get(), &TaskProxy::HandleStartActivation)); + base::Bind(&TaskProxy::HandleStartActivation, task.get())); } void MobileSetupHandler::StartActivation() { @@ -684,8 +684,7 @@ bool MobileSetupHandler::ConnectToNetwork( scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr(), delay); BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, - NewRunnableMethod(task.get(), &TaskProxy::ContinueConnecting), - delay); + base::Bind(&TaskProxy::ContinueConnecting, task.get()), delay); return false; } chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> @@ -709,8 +708,7 @@ void MobileSetupHandler::ForceReconnect( scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr(), delay); BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, - NewRunnableMethod(task.get(), &TaskProxy::ContinueConnecting), - delay); + base::Bind(&TaskProxy::ContinueConnecting, task.get()), delay); } bool MobileSetupHandler::ConnectionTimeout() { @@ -1104,8 +1102,7 @@ void MobileSetupHandler::ChangeState(chromeos::CellularNetwork* network, UMA_HISTOGRAM_COUNTS("Cellular.RetryOTASP", 1); scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr(), 0); BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, - NewRunnableMethod(task.get(), &TaskProxy::RetryOTASP), - kOTASPRetryDelay); + base::Bind(&TaskProxy::RetryOTASP, task.get()), kOTASPRetryDelay); break; } case PLAN_ACTIVATION_INITIATING_ACTIVATION: diff --git a/chrome/browser/ui/webui/chromeos/register_page_ui.cc b/chrome/browser/ui/webui/chromeos/register_page_ui.cc index 2fb243e..5cebaa2 100644 --- a/chrome/browser/ui/webui/chromeos/register_page_ui.cc +++ b/chrome/browser/ui/webui/chromeos/register_page_ui.cc @@ -8,7 +8,6 @@ #include "base/bind.h" #include "base/bind_helpers.h" -#include "base/callback.h" #include "base/logging.h" #include "base/memory/weak_ptr.h" #include "base/string_piece.h" @@ -241,8 +240,7 @@ void RegisterPageHandler::HandleGetUserInfo(const ListValue* args) { if (chromeos::CrosLibrary::Get()->EnsureLoaded()) { version_loader_.GetVersion( &version_consumer_, - NewCallback(this, - &RegisterPageHandler::OnVersion), + base::Bind(&RegisterPageHandler::OnVersion, base::Unretained(this)), chromeos::VersionLoader::VERSION_FULL); } else { SkipRegistration("CrosLibrary is not loaded."); diff --git a/chrome/browser/ui/webui/chromeos/sim_unlock_ui.cc b/chrome/browser/ui/webui/chromeos/sim_unlock_ui.cc index bbaa405..08de306 100644 --- a/chrome/browser/ui/webui/chromeos/sim_unlock_ui.cc +++ b/chrome/browser/ui/webui/chromeos/sim_unlock_ui.cc @@ -482,7 +482,7 @@ void SimUnlockHandler::HandleCancel(const ListValue* args) { } scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr()); BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - NewRunnableMethod(task.get(), &TaskProxy::HandleCancel)); + base::Bind(&TaskProxy::HandleCancel, task.get())); } void SimUnlockHandler::HandleChangePinCode(const ListValue* args) { @@ -503,7 +503,7 @@ void SimUnlockHandler::HandleEnterCode(SimUnlockCode code_type, const std::string& code) { scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr(), code, code_type); BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - NewRunnableMethod(task.get(), &TaskProxy::HandleEnterCode)); + base::Bind(&TaskProxy::HandleEnterCode, task.get())); } void SimUnlockHandler::HandleEnterPinCode(const ListValue* args) { @@ -538,7 +538,7 @@ void SimUnlockHandler::HandleProceedToPukInput(const ListValue* args) { } scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr()); BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - NewRunnableMethod(task.get(), &TaskProxy::HandleProceedToPukInput)); + base::Bind(&TaskProxy::HandleProceedToPukInput, task.get())); } void SimUnlockHandler::HandleSimStatusInitialize(const ListValue* args) { @@ -553,7 +553,7 @@ void SimUnlockHandler::HandleSimStatusInitialize(const ListValue* args) { VLOG(1) << "Initializing SIM dialog in mode: " << dialog_mode_; scoped_refptr<TaskProxy> task = new TaskProxy(AsWeakPtr()); BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - NewRunnableMethod(task.get(), &TaskProxy::HandleInitialize)); + base::Bind(&TaskProxy::HandleInitialize, task.get())); } void SimUnlockHandler::InitializeSimStatus() { diff --git a/chrome/browser/ui/webui/chromeos/system_info_ui.cc b/chrome/browser/ui/webui/chromeos/system_info_ui.cc index baa5fcf..25d11db 100644 --- a/chrome/browser/ui/webui/chromeos/system_info_ui.cc +++ b/chrome/browser/ui/webui/chromeos/system_info_ui.cc @@ -4,7 +4,8 @@ #include "chrome/browser/ui/webui/chromeos/system_info_ui.h" -#include "base/callback.h" +#include "base/bind.h" +#include "base/bind_helpers.h" #include "base/memory/weak_ptr.h" #include "base/message_loop.h" #include "base/path_service.h" @@ -99,7 +100,8 @@ void SystemInfoUIHTMLSource::StartDataRequest(const std::string& path, false, // don't compress. chromeos::system::SyslogsProvider::SYSLOGS_SYSINFO, &consumer_, - NewCallback(this, &SystemInfoUIHTMLSource::SyslogsComplete)); + base::Bind(&SystemInfoUIHTMLSource::SyslogsComplete, + base::Unretained(this))); } } diff --git a/chrome/browser/ui/webui/net_internals_ui.cc b/chrome/browser/ui/webui/net_internals_ui.cc index a227ec9..d7e53b4 100644 --- a/chrome/browser/ui/webui/net_internals_ui.cc +++ b/chrome/browser/ui/webui/net_internals_ui.cc @@ -11,6 +11,8 @@ #include <vector> #include "base/base64.h" +#include "base/bind.h" +#include "base/bind_helpers.h" #include "base/command_line.h" #include "base/memory/singleton.h" #include "base/message_loop.h" @@ -495,7 +497,8 @@ void NetInternalsMessageHandler::RegisterMessages() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); web_ui_->RegisterMessageCallback( "notifyReady", - NewCallback(this, &NetInternalsMessageHandler::OnRendererReady)); + base::Bind(&NetInternalsMessageHandler::OnRendererReady, + base::Unretained(this))); web_ui_->RegisterMessageCallback( "getProxySettings", proxy_->CreateCallback(&IOThreadImpl::OnGetProxySettings)); @@ -559,20 +562,24 @@ void NetInternalsMessageHandler::RegisterMessages() { #ifdef OS_CHROMEOS web_ui_->RegisterMessageCallback( "refreshSystemLogs", - NewCallback(this, &NetInternalsMessageHandler::OnRefreshSystemLogs)); + base::Bind(&NetInternalsMessageHandler::OnRefreshSystemLogs, + base::Unretained(this))); web_ui_->RegisterMessageCallback( "getSystemLog", - NewCallback(this, &NetInternalsMessageHandler::OnGetSystemLog)); + base::Bind(&NetInternalsMessageHandler::OnGetSystemLog, + base::Unretained(this))); #endif web_ui_->RegisterMessageCallback( "setLogLevel", proxy_->CreateCallback(&IOThreadImpl::OnSetLogLevel)); web_ui_->RegisterMessageCallback( "enableHttpThrottling", - NewCallback(this, &NetInternalsMessageHandler::OnEnableHttpThrottling)); + base::Bind(&NetInternalsMessageHandler::OnEnableHttpThrottling, + base::Unretained(this))); web_ui_->RegisterMessageCallback( "getPrerenderInfo", - NewCallback(this, &NetInternalsMessageHandler::OnGetPrerenderInfo)); + base::Bind(&NetInternalsMessageHandler::OnGetPrerenderInfo, + base::Unretained(this))); } void NetInternalsMessageHandler::SendJavascriptCommand( @@ -708,9 +715,9 @@ void NetInternalsMessageHandler::SystemLogsGetter::LoadSystemLogs() { false, // compress logs. chromeos::system::SyslogsProvider::SYSLOGS_NETWORK, &consumer_, - NewCallback( - this, - &NetInternalsMessageHandler::SystemLogsGetter::OnSystemLogsLoaded)); + base::Bind( + &NetInternalsMessageHandler::SystemLogsGetter::OnSystemLogsLoaded, + base::Unretained(this))); } void NetInternalsMessageHandler::SystemLogsGetter::OnSystemLogsLoaded( diff --git a/chrome/browser/ui/webui/options/chromeos/about_page_handler.cc b/chrome/browser/ui/webui/options/chromeos/about_page_handler.cc index cfe9738..f4ae091 100644 --- a/chrome/browser/ui/webui/options/chromeos/about_page_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/about_page_handler.cc @@ -9,7 +9,6 @@ #include "base/basictypes.h" #include "base/bind.h" #include "base/bind_helpers.h" -#include "base/callback_old.h" #include "base/command_line.h" #include "base/i18n/time_formatting.h" #include "base/string16.h" @@ -249,10 +248,12 @@ void AboutPageHandler::RegisterMessages() { void AboutPageHandler::PageReady(const ListValue* args) { // Version information is loaded from a callback loader_.GetVersion(&consumer_, - NewCallback(this, &AboutPageHandler::OnOSVersion), + base::Bind(&AboutPageHandler::OnOSVersion, + base::Unretained(this)), VersionLoader::VERSION_FULL); loader_.GetFirmware(&consumer_, - NewCallback(this, &AboutPageHandler::OnOSFirmware)); + base::Bind(&AboutPageHandler::OnOSFirmware, + base::Unretained(this))); UpdateLibrary* update_library = CrosLibrary::Get()->GetUpdateLibrary(); |