diff options
author | adamk@chromium.org <adamk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-17 18:05:29 +0000 |
---|---|---|
committer | adamk@chromium.org <adamk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-17 18:05:29 +0000 |
commit | 704d77e9e5bfee8ddba225174adc4c52185ad93b (patch) | |
tree | 051432fa58f3d07c5d806d88895fa4d14618056a | |
parent | 3a1a40516b43d170e0651b0e3636072b0fdcf1fd (diff) | |
download | chromium_src-704d77e9e5bfee8ddba225174adc4c52185ad93b.zip chromium_src-704d77e9e5bfee8ddba225174adc4c52185ad93b.tar.gz chromium_src-704d77e9e5bfee8ddba225174adc4c52185ad93b.tar.bz2 |
Revert 105832 - NewRunnable* -> base::Bind for most of chrome/browser/extensions/.
R=aa@chromium.org
Review URL: http://codereview.chromium.org/8292005
TBR=adamk@chromium.org
Review URL: http://codereview.chromium.org/8320008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105848 0039d316-1c4b-4281-b951-d872f2087c98
22 files changed, 146 insertions, 164 deletions
diff --git a/chrome/browser/extensions/autoupdate_interceptor.cc b/chrome/browser/extensions/autoupdate_interceptor.cc index 265959a..40b40c4 100644 --- a/chrome/browser/extensions/autoupdate_interceptor.cc +++ b/chrome/browser/extensions/autoupdate_interceptor.cc @@ -4,7 +4,6 @@ #include "chrome/browser/extensions/autoupdate_interceptor.h" -#include "base/bind.h" #include "base/file_util.h" #include "base/threading/thread_restrictions.h" #include "content/browser/browser_thread.h" @@ -87,5 +86,5 @@ void AutoUpdateInterceptor::SetResponseOnIOThread(const std::string url, const FilePath& path) { BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - base::Bind(&AutoUpdateInterceptor::SetResponse, this, url, path)); + NewRunnableMethod(this, &AutoUpdateInterceptor::SetResponse, url, path)); } diff --git a/chrome/browser/extensions/crx_installer.cc b/chrome/browser/extensions/crx_installer.cc index 18a1a87..e73f4f1 100644 --- a/chrome/browser/extensions/crx_installer.cc +++ b/chrome/browser/extensions/crx_installer.cc @@ -7,7 +7,6 @@ #include <map> #include <set> -#include "base/bind.h" #include "base/file_util.h" #include "base/lazy_instance.h" #include "base/metrics/field_trial.h" @@ -16,6 +15,7 @@ #include "base/scoped_temp_dir.h" #include "base/stl_util.h" #include "base/stringprintf.h" +#include "base/task.h" #include "base/threading/thread_restrictions.h" #include "base/time.h" #include "base/utf_string_conversions.h" @@ -139,7 +139,7 @@ CrxInstaller::~CrxInstaller() { if (!temp_dir_.value().empty()) { if (!BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind( + NewRunnableFunction( &extension_file_util::DeleteFile, temp_dir_, true))) NOTREACHED(); } @@ -147,7 +147,7 @@ CrxInstaller::~CrxInstaller() { if (delete_source_) { if (!BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind( + NewRunnableFunction( &extension_file_util::DeleteFile, source_file_, false))) NOTREACHED(); } @@ -168,8 +168,8 @@ void CrxInstaller::InstallCrx(const FilePath& source_file) { if (!BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind( - &SandboxedExtensionUnpacker::Start, unpacker.get()))) + NewRunnableMethod( + unpacker.get(), &SandboxedExtensionUnpacker::Start))) NOTREACHED(); } @@ -182,7 +182,8 @@ void CrxInstaller::InstallUserScript(const FilePath& source_file, if (!BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind(&CrxInstaller::ConvertUserScriptOnFileThread, this))) + NewRunnableMethod(this, + &CrxInstaller::ConvertUserScriptOnFileThread))) NOTREACHED(); } @@ -201,7 +202,8 @@ void CrxInstaller::ConvertUserScriptOnFileThread() { void CrxInstaller::InstallWebApp(const WebApplicationInfo& web_app) { if (!BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind(&CrxInstaller::ConvertWebAppOnFileThread, this, web_app))) + NewRunnableMethod(this, &CrxInstaller::ConvertWebAppOnFileThread, + web_app))) NOTREACHED(); } @@ -357,7 +359,7 @@ void CrxInstaller::OnUnpackSuccess(const FilePath& temp_dir, if (!BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind(&CrxInstaller::ConfirmInstall, this))) + NewRunnableMethod(this, &CrxInstaller::ConfirmInstall))) NOTREACHED(); } @@ -421,7 +423,7 @@ void CrxInstaller::ConfirmInstall() { } else { if (!BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind(&CrxInstaller::CompleteInstall, this))) + NewRunnableMethod(this, &CrxInstaller::CompleteInstall))) NOTREACHED(); } return; @@ -430,7 +432,7 @@ void CrxInstaller::ConfirmInstall() { void CrxInstaller::InstallUIProceed() { if (!BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind(&CrxInstaller::CompleteInstall, this))) + NewRunnableMethod(this, &CrxInstaller::CompleteInstall))) NOTREACHED(); Release(); // balanced in ConfirmInstall(). @@ -511,7 +513,9 @@ void CrxInstaller::ReportFailureFromFileThread(const std::string& error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); if (!BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind(&CrxInstaller::ReportFailureFromUIThread, this, error))) + NewRunnableMethod(this, + &CrxInstaller::ReportFailureFromUIThread, + error))) NOTREACHED(); } @@ -555,7 +559,8 @@ void CrxInstaller::ReportSuccessFromFileThread() { if (!BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind(&CrxInstaller::ReportSuccessFromUIThread, this))) + NewRunnableMethod(this, + &CrxInstaller::ReportSuccessFromUIThread))) NOTREACHED(); } diff --git a/chrome/browser/extensions/extension_bookmarks_module.cc b/chrome/browser/extensions/extension_bookmarks_module.cc index 3e1d22c..dce4b6f 100644 --- a/chrome/browser/extensions/extension_bookmarks_module.cc +++ b/chrome/browser/extensions/extension_bookmarks_module.cc @@ -4,7 +4,6 @@ #include "chrome/browser/extensions/extension_bookmarks_module.h" -#include "base/bind.h" #include "base/file_path.h" #include "base/i18n/file_util_icu.h" #include "base/i18n/time_formatting.h" @@ -852,7 +851,7 @@ void BookmarksIOFunction::SelectFile(SelectFileDialog::Type type) { // (stat or access, for example), so this requires a thread with IO allowed. if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) { BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, - base::Bind(&BookmarksIOFunction::SelectFile, this, type)); + NewRunnableMethod(this, &BookmarksIOFunction::SelectFile, type)); return; } @@ -866,8 +865,8 @@ void BookmarksIOFunction::SelectFile(SelectFileDialog::Type type) { // After getting the |default_path|, ask the UI to display the file dialog. BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - base::Bind(&BookmarksIOFunction::ShowSelectFileDialog, this, - type, default_path)); + NewRunnableMethod(this, &BookmarksIOFunction::ShowSelectFileDialog, + type, default_path)); } void BookmarksIOFunction::ShowSelectFileDialog(SelectFileDialog::Type type, diff --git a/chrome/browser/extensions/extension_cookies_api.cc b/chrome/browser/extensions/extension_cookies_api.cc index e2af159..f9f7e51 100644 --- a/chrome/browser/extensions/extension_cookies_api.cc +++ b/chrome/browser/extensions/extension_cookies_api.cc @@ -203,7 +203,7 @@ bool GetCookieFunction::RunImpl() { bool rv = BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - base::Bind(&GetCookieFunction::GetCookieOnIOThread, this)); + NewRunnableMethod(this, &GetCookieFunction::GetCookieOnIOThread)); DCHECK(rv); // Will finish asynchronously. @@ -238,7 +238,7 @@ void GetCookieFunction::GetCookieCallback(const net::CookieList& cookie_list) { bool rv = BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind(&GetCookieFunction::RespondOnUIThread, this)); + NewRunnableMethod(this, &GetCookieFunction::RespondOnUIThread)); DCHECK(rv); } @@ -268,7 +268,7 @@ bool GetAllCookiesFunction::RunImpl() { bool rv = BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - base::Bind(&GetAllCookiesFunction::GetAllCookiesOnIOThread, this)); + NewRunnableMethod(this, &GetAllCookiesFunction::GetAllCookiesOnIOThread)); DCHECK(rv); // Will finish asynchronously. @@ -296,7 +296,7 @@ void GetAllCookiesFunction::GetAllCookiesCallback( } bool rv = BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind(&GetAllCookiesFunction::RespondOnUIThread, this)); + NewRunnableMethod(this, &GetAllCookiesFunction::RespondOnUIThread)); DCHECK(rv); } @@ -369,7 +369,7 @@ bool SetCookieFunction::RunImpl() { bool rv = BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - base::Bind(&SetCookieFunction::SetCookieOnIOThread, this)); + NewRunnableMethod(this, &SetCookieFunction::SetCookieOnIOThread)); DCHECK(rv); // Will finish asynchronously. @@ -412,7 +412,7 @@ void SetCookieFunction::PullCookieCallback(const net::CookieList& cookie_list) { bool rv = BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind(&SetCookieFunction::RespondOnUIThread, this)); + NewRunnableMethod(this, &SetCookieFunction::RespondOnUIThread)); DCHECK(rv); } @@ -453,7 +453,7 @@ bool RemoveCookieFunction::RunImpl() { // Pass the work off to the IO thread. bool rv = BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - base::Bind(&RemoveCookieFunction::RemoveCookieOnIOThread, this)); + NewRunnableMethod(this, &RemoveCookieFunction::RemoveCookieOnIOThread)); DCHECK(rv); // Will return asynchronously. @@ -482,7 +482,7 @@ void RemoveCookieFunction::RemoveCookieCallback() { // Return to UI thread bool rv = BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind(&RemoveCookieFunction::RespondOnUIThread, this)); + NewRunnableMethod(this, &RemoveCookieFunction::RespondOnUIThread)); DCHECK(rv); } diff --git a/chrome/browser/extensions/extension_downloads_api.cc b/chrome/browser/extensions/extension_downloads_api.cc index fc98dbd..0e1470e 100644 --- a/chrome/browser/extensions/extension_downloads_api.cc +++ b/chrome/browser/extensions/extension_downloads_api.cc @@ -163,8 +163,8 @@ bool DownloadsDownloadFunction::ParseArgs() { void DownloadsDownloadFunction::RunInternal() { VLOG(1) << __FUNCTION__ << " " << iodata_->url.spec(); - if (!BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, base::Bind( - &DownloadsDownloadFunction::BeginDownloadOnIOThread, this))) { + if (!BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, NewRunnableMethod( + this, &DownloadsDownloadFunction::BeginDownloadOnIOThread))) { error_ = constants::kGenericError; SendResponse(error_.empty()); } @@ -207,8 +207,8 @@ void DownloadsDownloadFunction::BeginDownloadOnIOThread() { void DownloadsDownloadFunction::OnStarted(DownloadId dl_id, net::Error error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); VLOG(1) << __FUNCTION__ << " " << dl_id << " " << error; - BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( - &DownloadsDownloadFunction::RespondOnUIThread, this, + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableMethod( + this, &DownloadsDownloadFunction::RespondOnUIThread, dl_id.local(), error)); } diff --git a/chrome/browser/extensions/extension_error_reporter.cc b/chrome/browser/extensions/extension_error_reporter.cc index 0cfb883..a33ce99 100644 --- a/chrome/browser/extensions/extension_error_reporter.cc +++ b/chrome/browser/extensions/extension_error_reporter.cc @@ -6,13 +6,16 @@ #include "build/build_config.h" -#include "base/bind.h" -#include "base/bind_helpers.h" #include "base/logging.h" #include "base/message_loop.h" #include "base/utf_string_conversions.h" #include "chrome/browser/simple_message_box.h" +// No AddRef required when using ExtensionErrorReporter with RunnableMethod. +// This is okay since the ExtensionErrorReporter is a singleton that lives until +// the end of the process. +DISABLE_RUNNABLE_METHOD_REFCOUNT(ExtensionErrorReporter); + ExtensionErrorReporter* ExtensionErrorReporter::instance_ = NULL; // static @@ -39,13 +42,9 @@ void ExtensionErrorReporter::ReportError(const std::string& message, bool be_noisy) { // NOTE: There won't be a ui_loop_ in the unit test environment. if (ui_loop_ && MessageLoop::current() != ui_loop_) { - // base::Unretained is okay since the ExtensionErrorReporter is a singleton - // that lives until the end of the process. ui_loop_->PostTask(FROM_HERE, - base::Bind(&ExtensionErrorReporter::ReportError, - base::Unretained(this), - message, - be_noisy)); + NewRunnableMethod(this, &ExtensionErrorReporter::ReportError, message, + be_noisy)); return; } diff --git a/chrome/browser/extensions/extension_event_router.cc b/chrome/browser/extensions/extension_event_router.cc index 7f662ea..3b88961 100644 --- a/chrome/browser/extensions/extension_event_router.cc +++ b/chrome/browser/extensions/extension_event_router.cc @@ -4,7 +4,6 @@ #include "chrome/browser/extensions/extension_event_router.h" -#include "base/bind.h" #include "base/command_line.h" #include "base/values.h" #include "chrome/browser/extensions/extension_devtools_manager.h" @@ -141,7 +140,7 @@ void ExtensionEventRouter::RemoveEventListener( BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - base::Bind( + NewRunnableFunction( &NotifyEventListenerRemovedOnIOThread, profile_, listener.extension_id, event_name)); } diff --git a/chrome/browser/extensions/extension_event_router_forwarder_unittest.cc b/chrome/browser/extensions/extension_event_router_forwarder_unittest.cc index a128cd6..4a785d6 100644 --- a/chrome/browser/extensions/extension_event_router_forwarder_unittest.cc +++ b/chrome/browser/extensions/extension_event_router_forwarder_unittest.cc @@ -4,7 +4,6 @@ #include "chrome/browser/extensions/extension_event_router_forwarder.h" -#include "base/bind.h" #include "base/message_loop.h" #include "base/system_monitor/system_monitor.h" #include "base/test/thread_test_helper.h" @@ -118,9 +117,9 @@ TEST_F(ExtensionEventRouterForwarderTest, BroadcastRendererIO) { CallExtensionEventRouter( profile2_, "", kEventName, kEventArgs, profile2_, url)); BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, - base::Bind( - &MockExtensionEventRouterForwarder::BroadcastEventToRenderers, + NewRunnableMethod( event_router.get(), + &MockExtensionEventRouterForwarder::BroadcastEventToRenderers, std::string(kEventName), std::string(kEventArgs), url)); // Wait for IO thread's message loop to be processed diff --git a/chrome/browser/extensions/extension_file_browser_private_api.cc b/chrome/browser/extensions/extension_file_browser_private_api.cc index a89d38b..cd1d740 100644 --- a/chrome/browser/extensions/extension_file_browser_private_api.cc +++ b/chrome/browser/extensions/extension_file_browser_private_api.cc @@ -5,13 +5,13 @@ #include "chrome/browser/extensions/extension_file_browser_private_api.h" #include "base/base64.h" -#include "base/bind.h" #include "base/command_line.h" #include "base/json/json_writer.h" #include "base/logging.h" #include "base/memory/singleton.h" #include "base/stringprintf.h" #include "base/string_util.h" +#include "base/task.h" #include "base/time.h" #include "base/values.h" #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" @@ -347,9 +347,8 @@ class LocalFileSystemCallbackDispatcher BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind( + NewRunnableMethod(function_, &RequestLocalFileSystemFunction::RespondSuccessOnUIThread, - function_, name, root_path)); } @@ -357,9 +356,8 @@ class LocalFileSystemCallbackDispatcher virtual void DidFail(base::PlatformFileError error_code) OVERRIDE { BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind( + NewRunnableMethod(function_, &RequestLocalFileSystemFunction::RespondFailedOnUIThread, - function_, error_code)); } @@ -437,9 +435,8 @@ bool RequestLocalFileSystemFunction::RunImpl() { BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind( + NewRunnableMethod(this, &RequestLocalFileSystemFunction::RequestOnFileThread, - this, source_url_, render_view_host()->process()->id())); // Will finish asynchronously. @@ -507,9 +504,8 @@ bool FileWatchBrowserFunctionBase::RunImpl() { GURL file_watch_url(url); BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind( + NewRunnableMethod(this, &FileWatchBrowserFunctionBase::RunFileWatchOperationOnFileThread, - this, file_watch_url, extension_id())); @@ -524,24 +520,21 @@ void FileWatchBrowserFunctionBase::RunFileWatchOperationOnFileThread( local_path == FilePath()) { BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind( + NewRunnableMethod(this, &FileWatchBrowserFunctionBase::RespondOnUIThread, - this, false)); } if (!PerformFileWatchOperation(local_path, virtual_path, extension_id)) { BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind( + NewRunnableMethod(this, &FileWatchBrowserFunctionBase::RespondOnUIThread, - this, false)); } BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind( + NewRunnableMethod(this, &FileWatchBrowserFunctionBase::RespondOnUIThread, - this, true)); } @@ -678,17 +671,15 @@ class ExecuteTasksFileSystemCallbackDispatcher if (file_list.empty()) { BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind( - &ExecuteTasksFileBrowserFunction::ExecuteFailedOnUIThread, - function_)); + NewRunnableMethod(function_, + &ExecuteTasksFileBrowserFunction::ExecuteFailedOnUIThread)); return; } BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind( + NewRunnableMethod(function_, &ExecuteTasksFileBrowserFunction::ExecuteFileActionsOnUIThread, - function_, task_id_, file_system_name, file_system_root, @@ -698,9 +689,8 @@ class ExecuteTasksFileSystemCallbackDispatcher virtual void DidFail(base::PlatformFileError error_code) OVERRIDE { BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind( - &ExecuteTasksFileBrowserFunction::ExecuteFailedOnUIThread, - function_)); + NewRunnableMethod(function_, + &ExecuteTasksFileBrowserFunction::ExecuteFailedOnUIThread)); } private: @@ -849,9 +839,8 @@ bool ExecuteTasksFileBrowserFunction::InitiateFileTaskExecution( // Get local file system instance on file thread. BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind( + NewRunnableMethod(this, &ExecuteTasksFileBrowserFunction::RequestFileEntryOnFileThread, - this, source_url_, task_id, file_urls)); @@ -1025,9 +1014,8 @@ void FileBrowserFunction::GetLocalPathsOnFileThread(const UrlList& file_urls, BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind( + NewRunnableMethod(this, &FileBrowserFunction::GetLocalPathsResponseOnUIThread, - this, selected_files, context)); } @@ -1042,9 +1030,8 @@ bool SelectFileFunction::RunImpl() { BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind( + NewRunnableMethod(this, &SelectFileFunction::GetLocalPathsOnFileThread, - this, file_paths, reinterpret_cast<void*>(NULL))); return true; @@ -1095,9 +1082,8 @@ bool ViewFilesFunction::RunImpl() { BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind( + NewRunnableMethod(this, &ViewFilesFunction::GetLocalPathsOnFileThread, - this, file_urls, reinterpret_cast<void*>(new std::string(internal_task_id)))); @@ -1147,9 +1133,8 @@ bool SelectFilesFunction::RunImpl() { BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind( + NewRunnableMethod(this, &SelectFilesFunction::GetLocalPathsOnFileThread, - this, file_urls, reinterpret_cast<void*>(NULL))); return true; @@ -1220,9 +1205,8 @@ bool AddMountFunction::RunImpl() { MountParamaters* params = new MountParamaters(mount_type_str, options); BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind( + NewRunnableMethod(this, &AddMountFunction::GetLocalPathsOnFileThread, - this, file_paths, reinterpret_cast<void*>(params))); #endif // OS_CHROMEOS @@ -1283,9 +1267,8 @@ bool RemoveMountFunction::RunImpl() { file_paths.push_back(GURL(mount_path)); BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind( + NewRunnableMethod(this, &RemoveMountFunction::GetLocalPathsOnFileThread, - this, file_paths, reinterpret_cast<void*>(NULL))); return true; } @@ -1358,9 +1341,8 @@ bool GetSizeStatsFunction::RunImpl() { BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind( + NewRunnableMethod(this, &GetSizeStatsFunction::GetLocalPathsOnFileThread, - this, mount_paths, reinterpret_cast<void*>(NULL))); return true; } @@ -1376,9 +1358,8 @@ void GetSizeStatsFunction::GetLocalPathsResponseOnUIThread( BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind( + NewRunnableMethod(this, &GetSizeStatsFunction::CallGetSizeStatsOnFileThread, - this, files[0].value().c_str())); } @@ -1395,9 +1376,8 @@ void GetSizeStatsFunction::CallGetSizeStatsOnFileThread( BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - bsae::Bind( + NewRunnableMethod(this, &GetSizeStatsFunction::GetSizeStatsCallbackOnUIThread, - this, mount_path, total_size_kb, remaining_size_kb)); } @@ -1436,9 +1416,8 @@ bool FormatDeviceFunction::RunImpl() { BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind( + NewRunnableMethod(this, &FormatDeviceFunction::GetLocalPathsOnFileThread, - this, file_paths, reinterpret_cast<void*>(NULL))); return true; } diff --git a/chrome/browser/extensions/extension_gallery_install_apitest.cc b/chrome/browser/extensions/extension_gallery_install_apitest.cc index 16daa73..bf3a580 100644 --- a/chrome/browser/extensions/extension_gallery_install_apitest.cc +++ b/chrome/browser/extensions/extension_gallery_install_apitest.cc @@ -7,7 +7,6 @@ #include "base/win/windows_version.h" #endif // defined (OS_WIN) -#include "base/bind.h" #include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/extensions/extension_webstore_private_api.h" #include "chrome/common/chrome_notification_types.h" @@ -40,9 +39,9 @@ class GalleryInstallApiTestObserver : ExtensionInstallUI* prompt = Source<ExtensionInstallUI>(source).ptr(); CHECK(prompt->delegate_); MessageLoop::current()->PostTask( - FROM_HERE, base::Bind( - &GalleryInstallApiTestObserver::InstallUIProceed, + FROM_HERE, NewRunnableMethod( this, + &GalleryInstallApiTestObserver::InstallUIProceed, prompt->delegate_)); } diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index bbaf432..2a03197 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -6,9 +6,7 @@ #include <list> -#include "base/bind.h" #include "base/memory/singleton.h" -#include "base/memory/weak_ptr.h" #include "base/message_loop.h" #include "base/metrics/histogram.h" #include "base/string_util.h" @@ -95,14 +93,14 @@ class ExtensionHost::ProcessCreationQueue { friend struct DefaultSingletonTraits<ProcessCreationQueue>; ProcessCreationQueue() : pending_create_(false), - ALLOW_THIS_IN_INITIALIZER_LIST(ptr_factory_(this)) { } + ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { } // Queue up a delayed task to process the next ExtensionHost in the queue. void PostTask() { if (!pending_create_) { MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(&ProcessCreationQueue::ProcessOneHost, - ptr_factory_.GetWeakPtr())); + method_factory_.NewRunnableMethod( + &ProcessCreationQueue::ProcessOneHost)); pending_create_ = true; } } @@ -123,7 +121,7 @@ class ExtensionHost::ProcessCreationQueue { typedef std::list<ExtensionHost*> Queue; Queue queue_; bool pending_create_; - base::WeakPtrFactory<ProcessCreationQueue> ptr_factory_; + ScopedRunnableMethodFactory<ProcessCreationQueue> method_factory_; }; //////////////// diff --git a/chrome/browser/extensions/extension_management_api.cc b/chrome/browser/extensions/extension_management_api.cc index e638801..7db4f60 100644 --- a/chrome/browser/extensions/extension_management_api.cc +++ b/chrome/browser/extensions/extension_management_api.cc @@ -7,7 +7,6 @@ #include <map> #include <string> -#include "base/bind.h" #include "base/basictypes.h" #include "base/json/json_writer.h" #include "base/metrics/histogram.h" @@ -212,7 +211,7 @@ class SafeManifestJSONParser : public UtilityProcessHost::Client { BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - base::Bind(&SafeManifestJSONParser::StartWorkOnIOThread, this)); + NewRunnableMethod(this, &SafeManifestJSONParser::StartWorkOnIOThread)); } void StartWorkOnIOThread() { @@ -246,7 +245,8 @@ class SafeManifestJSONParser : public UtilityProcessHost::Client { BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind(&SafeManifestJSONParser::ReportResultFromUIThread, this)); + NewRunnableMethod(this, + &SafeManifestJSONParser::ReportResultFromUIThread)); } void OnJSONParseFailed(const std::string& error) { @@ -256,7 +256,8 @@ class SafeManifestJSONParser : public UtilityProcessHost::Client { BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind(&SafeManifestJSONParser::ReportResultFromUIThread, this)); + NewRunnableMethod(this, + &SafeManifestJSONParser::ReportResultFromUIThread)); } void ReportResultFromUIThread() { diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc index ab689c5..835064d 100644 --- a/chrome/browser/extensions/extension_service.cc +++ b/chrome/browser/extensions/extension_service.cc @@ -7,7 +7,6 @@ #include <algorithm> #include <set> -#include "base/bind.h" #include "base/basictypes.h" #include "base/callback.h" #include "base/command_line.h" @@ -317,8 +316,9 @@ void ExtensionServiceBackend::LoadSingleExtension(const FilePath& path_in, file_util::AbsolutePath(&extension_path); BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - base::Bind(&ExtensionServiceBackend::CheckExtensionFileAccess, - this, extension_path, prompt_for_plugins)); + NewRunnableMethod(this, + &ExtensionServiceBackend::CheckExtensionFileAccess, + extension_path, prompt_for_plugins)); } void ExtensionServiceBackend::CheckExtensionFileAccess( @@ -333,9 +333,10 @@ void ExtensionServiceBackend::CheckExtensionFileAccess( allow_file_access = frontend_->extension_prefs()->AllowFileAccess(id); BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, - base::Bind( + NewRunnableMethod( + this, &ExtensionServiceBackend::LoadSingleExtensionWithFileAccess, - this, extension_path, allow_file_access, prompt_for_plugins)); + extension_path, allow_file_access, prompt_for_plugins)); } void ExtensionServiceBackend::LoadSingleExtensionWithFileAccess( @@ -356,9 +357,9 @@ void ExtensionServiceBackend::LoadSingleExtensionWithFileAccess( if (!extension) { BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - base::Bind( - &ExtensionServiceBackend::ReportExtensionLoadError, + NewRunnableMethod( this, + &ExtensionServiceBackend::ReportExtensionLoadError, extension_path, error)); return; } @@ -366,9 +367,10 @@ void ExtensionServiceBackend::LoadSingleExtensionWithFileAccess( // Report this as an installed extension so that it gets remembered in the // prefs. BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, - base::Bind( + NewRunnableMethod( + this, &ExtensionServiceBackend::OnLoadSingleExtension, - this, extension, prompt_for_plugins)); + extension, prompt_for_plugins)); } void ExtensionServiceBackend::ReportExtensionLoadError( @@ -589,6 +591,7 @@ ExtensionService::ExtensionService(Profile* profile, bool autoupdate_enabled, bool extensions_enabled) : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), + method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), profile_(profile), extension_prefs_(extension_prefs), extension_settings_frontend_( @@ -793,7 +796,7 @@ bool ExtensionService::UpdateExtension( // that would do it for us. if (!BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind( + NewRunnableFunction( extension_file_util::DeleteFile, extension_path, false))) NOTREACHED(); @@ -934,7 +937,7 @@ bool ExtensionService::UninstallExtension( if (Extension::LOAD != extension->location()) { if (!BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind( + NewRunnableFunction( &extension_file_util::UninstallExtension, install_directory_, extension_id))) @@ -1124,8 +1127,9 @@ void ExtensionService::LoadExtension(const FilePath& extension_path) { void ExtensionService::LoadExtension(const FilePath& extension_path, bool prompt_for_plugins) { BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, - base::Bind(&ExtensionServiceBackend::LoadSingleExtension, backend_.get(), - extension_path, prompt_for_plugins)); + NewRunnableMethod(backend_.get(), + &ExtensionServiceBackend::LoadSingleExtension, + extension_path, prompt_for_plugins)); } void ExtensionService::LoadExtensionFromCommandLine( @@ -1624,7 +1628,8 @@ void ExtensionService::NotifyExtensionUnloaded( for (size_t i = 0; i < extension->plugins().size(); ++i) { const Extension::PluginInfo& plugin = extension->plugins()[i]; if (!BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, - base::Bind(&ForceShutdownPlugin, plugin.path))) + NewRunnableFunction(&ForceShutdownPlugin, + plugin.path))) NOTREACHED(); webkit::npapi::PluginList::Singleton()->RefreshPlugins(); webkit::npapi::PluginList::Singleton()->RemoveExtraPluginPath( @@ -2328,7 +2333,7 @@ void ExtensionService::GarbageCollectExtensions() { if (!BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind( + NewRunnableFunction( &extension_file_util::GarbageCollectExtensions, install_directory_, extension_paths))) @@ -2565,8 +2570,8 @@ void ExtensionService::OnExtensionInstalled( // load it. if (!BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind(&extension_file_util::DeleteFile, - extension->path(), true))) + NewRunnableFunction(&extension_file_util::DeleteFile, + extension->path(), true))) NOTREACHED(); return; } @@ -2822,9 +2827,8 @@ void ExtensionService::Observe(int type, // access to the Extension and ExtensionHost. MessageLoop::current()->PostTask( FROM_HERE, - base::Bind( + method_factory_.NewRunnableMethod( &ExtensionService::TrackTerminatedExtension, - weak_ptr_factory_.GetWeakPtr(), host->extension())); break; } diff --git a/chrome/browser/extensions/extension_service.h b/chrome/browser/extensions/extension_service.h index b99831c..85b6ae2 100644 --- a/chrome/browser/extensions/extension_service.h +++ b/chrome/browser/extensions/extension_service.h @@ -18,6 +18,7 @@ #include "base/memory/linked_ptr.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" +#include "base/task.h" #include "base/time.h" #include "base/tuple.h" #include "chrome/browser/extensions/apps_promo.h" @@ -687,6 +688,8 @@ class ExtensionService base::WeakPtrFactory<ExtensionService> weak_ptr_factory_; + ScopedRunnableMethodFactory<ExtensionService> method_factory_; + // The profile this ExtensionService is part of. Profile* profile_; diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc index ff89e5e2..4c42e24 100644 --- a/chrome/browser/extensions/extension_service_unittest.cc +++ b/chrome/browser/extensions/extension_service_unittest.cc @@ -22,6 +22,7 @@ #include "base/string16.h" #include "base/string_number_conversions.h" #include "base/string_util.h" +#include "base/task.h" #include "base/utf_string_conversions.h" #include "base/version.h" #include "chrome/browser/browser_process.h" @@ -334,9 +335,9 @@ class ExtensionTestingProfile : public TestingProfile { appcache_service_ = new ChromeAppCacheService(NULL); if (!BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - base::Bind( - &ChromeAppCacheService::InitializeOnIOThread, + NewRunnableMethod( appcache_service_.get(), + &ChromeAppCacheService::InitializeOnIOThread, IsOffTheRecord() ? FilePath() : GetPath().Append(chrome::kAppCacheDirname), &GetResourceContext(), diff --git a/chrome/browser/extensions/extension_special_storage_policy.cc b/chrome/browser/extensions/extension_special_storage_policy.cc index 05e0805..de58fb9 100644 --- a/chrome/browser/extensions/extension_special_storage_policy.cc +++ b/chrome/browser/extensions/extension_special_storage_policy.cc @@ -4,7 +4,6 @@ #include "chrome/browser/extensions/extension_special_storage_policy.h" -#include "base/bind.h" #include "base/logging.h" #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/common/content_settings.h" @@ -122,7 +121,8 @@ void ExtensionSpecialStoragePolicy::RevokeRightsForAllExtensions() { void ExtensionSpecialStoragePolicy::NotifyChanged() { if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, - base::Bind(&ExtensionSpecialStoragePolicy::NotifyChanged, this)); + NewRunnableMethod(this, + &ExtensionSpecialStoragePolicy::NotifyChanged)); return; } SpecialStoragePolicy::NotifyObservers(); diff --git a/chrome/browser/extensions/extension_tab_id_map.cc b/chrome/browser/extensions/extension_tab_id_map.cc index fd45169..1c92c03 100644 --- a/chrome/browser/extensions/extension_tab_id_map.cc +++ b/chrome/browser/extensions/extension_tab_id_map.cc @@ -4,8 +4,6 @@ #include "chrome/browser/extensions/extension_tab_id_map.h" -#include "base/bind.h" -#include "base/bind_helpers.h" #include "chrome/browser/sessions/restore_tab_helper.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "content/browser/browser_thread.h" @@ -16,6 +14,9 @@ #include "content/common/notification_observer.h" #include "content/common/notification_service.h" +// ExtensionTabIdMap is a Singleton, so it doesn't need refcounting. +DISABLE_RUNNABLE_METHOD_REFCOUNT(ExtensionTabIdMap); + // // ExtensionTabIdMap::TabObserver // @@ -66,9 +67,9 @@ void ExtensionTabIdMap::TabObserver::Observe( // have been set yet. BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - base::Bind( + NewRunnableMethod( + ExtensionTabIdMap::GetInstance(), &ExtensionTabIdMap::SetTabAndWindowId, - base::Unretained(ExtensionTabIdMap::GetInstance()), host->process()->id(), host->routing_id(), tab->restore_tab_helper()->session_id().id(), tab->restore_tab_helper()->window_id().id())); @@ -79,9 +80,9 @@ void ExtensionTabIdMap::TabObserver::Observe( RenderViewHost* host = tab->render_view_host(); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - base::Bind( + NewRunnableMethod( + ExtensionTabIdMap::GetInstance(), &ExtensionTabIdMap::SetTabAndWindowId, - base::Unretained(ExtensionTabIdMap::GetInstance()), host->process()->id(), host->routing_id(), tab->restore_tab_helper()->session_id().id(), tab->restore_tab_helper()->window_id().id())); @@ -91,9 +92,9 @@ void ExtensionTabIdMap::TabObserver::Observe( RenderViewHost* host = Source<RenderViewHost>(source).ptr(); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - base::Bind( + NewRunnableMethod( + ExtensionTabIdMap::GetInstance(), &ExtensionTabIdMap::ClearTabAndWindowId, - base::Unretained(ExtensionTabIdMap::GetInstance()), host->process()->id(), host->routing_id())); break; } diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc index f5a07bf..c460cc9 100644 --- a/chrome/browser/extensions/extension_tabs_module.cc +++ b/chrome/browser/extensions/extension_tabs_module.cc @@ -8,7 +8,6 @@ #include <vector> #include "base/base64.h" -#include "base/bind.h" #include "base/memory/ref_counted_memory.h" #include "base/stl_util.h" #include "base/string16.h" @@ -1495,8 +1494,8 @@ bool DetectTabLanguageFunction::RunImpl() { if (!helper->language_state().original_language().empty()) { // Delay the callback invocation until after the current JS call has // returned. - MessageLoop::current()->PostTask(FROM_HERE, base::Bind( - &DetectTabLanguageFunction::GotLanguage, this, + MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( + this, &DetectTabLanguageFunction::GotLanguage, helper->language_state().original_language())); return true; } diff --git a/chrome/browser/extensions/extension_tts_api_chromeos.cc b/chrome/browser/extensions/extension_tts_api_chromeos.cc index cf58b3d..e421897 100644 --- a/chrome/browser/extensions/extension_tts_api_chromeos.cc +++ b/chrome/browser/extensions/extension_tts_api_chromeos.cc @@ -2,11 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/bind.h" #include "base/memory/singleton.h" -#include "base/memory/weak_ptr.h" #include "base/message_loop.h" #include "base/string_number_conversions.h" +#include "base/task.h" #include "chrome/browser/chromeos/cros/cros_library.h" #include "chrome/browser/chromeos/cros/speech_synthesis_library.h" #include "chrome/browser/extensions/extension_tts_api_controller.h" @@ -40,7 +39,7 @@ class ExtensionTtsPlatformImplChromeOs : public ExtensionTtsPlatformImpl { private: ExtensionTtsPlatformImplChromeOs() - : ALLOW_THIS_IN_INITIALIZER_LIST(ptr_factory_(this)) {} + : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {} virtual ~ExtensionTtsPlatformImplChromeOs() {} void PollUntilSpeechFinishes(int utterance_id); @@ -51,7 +50,7 @@ class ExtensionTtsPlatformImplChromeOs : public ExtensionTtsPlatformImpl { int utterance_id_; int utterance_length_; - base::WeakPtrFactory<ExtensionTtsPlatformImplChromeOs> ptr_factory_; + ScopedRunnableMethodFactory<ExtensionTtsPlatformImplChromeOs> method_factory_; friend struct DefaultSingletonTraits<ExtensionTtsPlatformImplChromeOs>; @@ -166,9 +165,8 @@ void ExtensionTtsPlatformImplChromeOs::PollUntilSpeechFinishes( } MessageLoop::current()->PostDelayedTask( - FROM_HERE, base::Bind( + FROM_HERE, method_factory_.NewRunnableMethod( &ExtensionTtsPlatformImplChromeOs::PollUntilSpeechFinishes, - ptr_factory_.GetWeakPtr(), utterance_id), kSpeechCheckDelayIntervalMs); } diff --git a/chrome/browser/extensions/extension_tts_apitest.cc b/chrome/browser/extensions/extension_tts_apitest.cc index 71f2634..a144650 100644 --- a/chrome/browser/extensions/extension_tts_apitest.cc +++ b/chrome/browser/extensions/extension_tts_apitest.cc @@ -2,9 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/bind.h" #include "base/command_line.h" -#include "base/memory/weak_ptr.h" +#include "base/task.h" #include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/extensions/extension_tts_api.h" #include "chrome/browser/extensions/extension_tts_api_controller.h" @@ -33,7 +32,7 @@ using ::testing::_; class MockExtensionTtsPlatformImpl : public ExtensionTtsPlatformImpl { public: MockExtensionTtsPlatformImpl() - : ALLOW_THIS_IN_INITIALIZER_LIST(ptr_factory_(this)) {} + : ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {} virtual bool PlatformImplAvailable() { return true; @@ -61,9 +60,8 @@ class MockExtensionTtsPlatformImpl : public ExtensionTtsPlatformImpl { const std::string& lang, const UtteranceContinuousParameters& params) { MessageLoop::current()->PostDelayedTask( - FROM_HERE, base::Bind( + FROM_HERE, method_factory_.NewRunnableMethod( &MockExtensionTtsPlatformImpl::SendEvent, - ptr_factory_.GetWeakPtr(), false, utterance_id, TTS_EVENT_END, utterance.size(), std::string()), 0); @@ -75,9 +73,8 @@ class MockExtensionTtsPlatformImpl : public ExtensionTtsPlatformImpl { const std::string& lang, const UtteranceContinuousParameters& params) { MessageLoop::current()->PostDelayedTask( - FROM_HERE, base::Bind( + FROM_HERE, method_factory_.NewRunnableMethod( &MockExtensionTtsPlatformImpl::SendEvent, - ptr_factory_.GetWeakPtr(), true, utterance_id, TTS_EVENT_END, utterance.size(), std::string()), 0); } @@ -89,9 +86,8 @@ class MockExtensionTtsPlatformImpl : public ExtensionTtsPlatformImpl { for (int i = 0; i < static_cast<int>(utterance.size()); i++) { if (i == 0 || utterance[i - 1] == ' ') { MessageLoop::current()->PostDelayedTask( - FROM_HERE, base::Bind( + FROM_HERE, method_factory_.NewRunnableMethod( &MockExtensionTtsPlatformImpl::SendEvent, - ptr_factory_.GetWeakPtr(), false, utterance_id, TTS_EVENT_WORD, i, std::string()), 0); @@ -107,9 +103,8 @@ class MockExtensionTtsPlatformImpl : public ExtensionTtsPlatformImpl { ExtensionTtsController* controller = ExtensionTtsController::GetInstance(); if (wait_for_non_empty_queue && controller->QueueSize() == 0) { MessageLoop::current()->PostDelayedTask( - FROM_HERE, base::Bind( + FROM_HERE, method_factory_.NewRunnableMethod( &MockExtensionTtsPlatformImpl::SendEvent, - ptr_factory_.GetWeakPtr(), true, utterance_id, event_type, char_index, message), 100); return; @@ -119,7 +114,7 @@ class MockExtensionTtsPlatformImpl : public ExtensionTtsPlatformImpl { } private: - base::WeakPtrFactory<MockExtensionTtsPlatformImpl> ptr_factory_; + ScopedRunnableMethodFactory<MockExtensionTtsPlatformImpl> method_factory_; }; class TtsApiTest : public ExtensionApiTest { diff --git a/chrome/browser/extensions/extension_updater.cc b/chrome/browser/extensions/extension_updater.cc index 716d6f5..6dc0420 100644 --- a/chrome/browser/extensions/extension_updater.cc +++ b/chrome/browser/extensions/extension_updater.cc @@ -7,7 +7,6 @@ #include <algorithm> #include <set> -#include "base/bind.h" #include "base/compiler_specific.h" #include "base/file_util.h" #include "base/logging.h" @@ -106,7 +105,7 @@ void RecordCRXWriteHistogram(bool success, const FilePath& crx_path) { // can not be read. Try reading. BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, - base::Bind(CheckThatCRXIsReadable, crx_path)); + NewRunnableFunction(CheckThatCRXIsReadable, crx_path)); } } @@ -126,7 +125,7 @@ void CheckThatCRXIsReadable(const FilePath& crx_path) { BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind(RecordFileUpdateHistogram, file_write_result)); + NewRunnableFunction(RecordFileUpdateHistogram, file_write_result)); } void RecordFileUpdateHistogram(FileWriteResult file_write_result) { @@ -478,6 +477,7 @@ ExtensionUpdater::ExtensionUpdater(ExtensionServiceInterface* service, : alive_(false), weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), service_(service), frequency_seconds_(frequency_seconds), + method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), will_check_soon_(false), extension_prefs_(extension_prefs), prefs_(prefs), profile_(profile), blacklist_checks_enabled_(true), crx_install_is_running_(false) { @@ -583,6 +583,7 @@ void ExtensionUpdater::Stop() { profile_ = NULL; timer_.Stop(); will_check_soon_ = false; + method_factory_.RevokeAll(); manifest_fetcher_.reset(); extension_fetcher_.reset(); STLDeleteElements(&manifests_pending_); @@ -630,8 +631,8 @@ class SafeManifestParser : public UtilityProcessHost::Client { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (!BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, - base::Bind( - &SafeManifestParser::ParseInSandbox, this, + NewRunnableMethod( + this, &SafeManifestParser::ParseInSandbox, g_browser_process->resource_dispatcher_host()))) { NOTREACHED(); } @@ -654,16 +655,16 @@ class SafeManifestParser : public UtilityProcessHost::Client { if (manifest.Parse(xml_)) { if (!BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind( - &SafeManifestParser::OnParseUpdateManifestSucceeded, this, + NewRunnableMethod( + this, &SafeManifestParser::OnParseUpdateManifestSucceeded, manifest.results()))) { NOTREACHED(); } } else { if (!BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind( - &SafeManifestParser::OnParseUpdateManifestFailed, this, + NewRunnableMethod( + this, &SafeManifestParser::OnParseUpdateManifestFailed, manifest.errors()))) { NOTREACHED(); } @@ -983,8 +984,8 @@ void ExtensionUpdater::CheckSoon() { } if (BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind(&ExtensionUpdater::DoCheckSoon, - weak_ptr_factory_.GetWeakPtr()))) { + method_factory_.NewRunnableMethod( + &ExtensionUpdater::DoCheckSoon))) { will_check_soon_ = true; } else { NOTREACHED(); diff --git a/chrome/browser/extensions/extension_updater.h b/chrome/browser/extensions/extension_updater.h index e3a390d..bcba5e8 100644 --- a/chrome/browser/extensions/extension_updater.h +++ b/chrome/browser/extensions/extension_updater.h @@ -19,6 +19,7 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/scoped_temp_dir.h" +#include "base/task.h" #include "base/time.h" #include "base/timer.h" #include "chrome/browser/extensions/extension_service.h" @@ -362,6 +363,8 @@ class ExtensionUpdater : public URLFetcher::Delegate, base::OneShotTimer<ExtensionUpdater> timer_; int frequency_seconds_; + ScopedRunnableMethodFactory<ExtensionUpdater> method_factory_; + bool will_check_soon_; ExtensionPrefs* extension_prefs_; |