Commit 791be42c authored by jhawkins@chromium.org's avatar jhawkins@chromium.org

base::Bind: Convert chrome/browser/profiles.

BUG=none
TEST=none

R=csilv@chromium.org

Review URL: http://codereview.chromium.org/8399028

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107881 0039d316-1c4b-4281-b951-d872f2087c98
parent 5376eb75
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "chrome/browser/profiles/off_the_record_profile_impl.h" #include "chrome/browser/profiles/off_the_record_profile_impl.h"
#include "base/bind.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/file_path.h" #include "base/file_path.h"
...@@ -112,8 +113,7 @@ void OffTheRecordProfileImpl::Init() { ...@@ -112,8 +113,7 @@ void OffTheRecordProfileImpl::Init() {
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE, BrowserThread::IO, FROM_HERE,
NewRunnableFunction( base::Bind(&NotifyOTRProfileCreatedOnIOThread, profile_, this));
&NotifyOTRProfileCreatedOnIOThread, profile_, this));
} }
OffTheRecordProfileImpl::~OffTheRecordProfileImpl() { OffTheRecordProfileImpl::~OffTheRecordProfileImpl() {
...@@ -128,15 +128,14 @@ OffTheRecordProfileImpl::~OffTheRecordProfileImpl() { ...@@ -128,15 +128,14 @@ OffTheRecordProfileImpl::~OffTheRecordProfileImpl() {
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE, BrowserThread::IO, FROM_HERE,
NewRunnableFunction(&NotifyOTRProfileDestroyedOnIOThread, profile_, base::Bind(&NotifyOTRProfileDestroyedOnIOThread, profile_, this));
this));
// Clean up all DB files/directories // Clean up all DB files/directories
if (db_tracker_) { if (db_tracker_) {
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE, BrowserThread::FILE, FROM_HERE,
NewRunnableMethod(db_tracker_.get(), base::Bind(&webkit_database::DatabaseTracker::Shutdown,
&webkit_database::DatabaseTracker::Shutdown)); db_tracker_.get()));
} }
BrowserList::RemoveObserver(this); BrowserList::RemoveObserver(this);
...@@ -517,9 +516,8 @@ ChromeBlobStorageContext* OffTheRecordProfileImpl::GetBlobStorageContext() { ...@@ -517,9 +516,8 @@ ChromeBlobStorageContext* OffTheRecordProfileImpl::GetBlobStorageContext() {
blob_storage_context_ = new ChromeBlobStorageContext(); blob_storage_context_ = new ChromeBlobStorageContext();
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE, BrowserThread::IO, FROM_HERE,
NewRunnableMethod( base::Bind(&ChromeBlobStorageContext::InitializeOnIOThread,
blob_storage_context_.get(), blob_storage_context_.get()));
&ChromeBlobStorageContext::InitializeOnIOThread));
} }
return blob_storage_context_; return blob_storage_context_;
} }
...@@ -617,13 +615,12 @@ void OffTheRecordProfileImpl::CreateQuotaManagerAndClients() { ...@@ -617,13 +615,12 @@ void OffTheRecordProfileImpl::CreateQuotaManagerAndClients() {
appcache_service_ = new ChromeAppCacheService(quota_manager_->proxy()); appcache_service_ = new ChromeAppCacheService(quota_manager_->proxy());
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE, BrowserThread::IO, FROM_HERE,
NewRunnableMethod( base::Bind(&ChromeAppCacheService::InitializeOnIOThread,
appcache_service_.get(), appcache_service_.get(),
&ChromeAppCacheService::InitializeOnIOThread, IsOffTheRecord()
IsOffTheRecord() ? FilePath() : GetPath().Append(chrome::kAppCacheDirname),
? FilePath() : GetPath().Append(chrome::kAppCacheDirname), &GetResourceContext(),
&GetResourceContext(), make_scoped_refptr(GetExtensionSpecialStoragePolicy())));
make_scoped_refptr(GetExtensionSpecialStoragePolicy())));
} }
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "chrome/browser/profiles/profile_impl.h" #include "chrome/browser/profiles/profile_impl.h"
#include "base/bind.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/environment.h" #include "base/environment.h"
...@@ -159,6 +160,13 @@ enum ContextType { ...@@ -159,6 +160,13 @@ enum ContextType {
typedef std::list<std::pair<FilePath::StringType, int> > typedef std::list<std::pair<FilePath::StringType, int> >
ComponentExtensionList; ComponentExtensionList;
// Helper method needed because PostTask cannot currently take a Callback
// function with non-void return type.
// TODO(jhawkins): Remove once IgnoreReturn is fixed.
void CreateDirectoryNoResult(const FilePath& path) {
file_util::CreateDirectory(path);
}
#if defined(FILE_MANAGER_EXTENSION) #if defined(FILE_MANAGER_EXTENSION)
void AddFileManagerExtension(ComponentExtensionList* component_extensions) { void AddFileManagerExtension(ComponentExtensionList* component_extensions) {
#ifndef NDEBUG #ifndef NDEBUG
...@@ -240,10 +248,9 @@ Profile* Profile::CreateProfileAsync(const FilePath& path, ...@@ -240,10 +248,9 @@ Profile* Profile::CreateProfileAsync(const FilePath& path,
Profile::Delegate* delegate) { Profile::Delegate* delegate) {
DCHECK(delegate); DCHECK(delegate);
// This is safe while all file operations are done on the FILE thread. // This is safe while all file operations are done on the FILE thread.
BrowserThread::PostTask(BrowserThread::FILE, BrowserThread::PostTask(
FROM_HERE, BrowserThread::FILE, FROM_HERE,
NewRunnableFunction(&file_util::CreateDirectory, base::Bind(&CreateDirectoryNoResult, path));
path));
// Async version. // Async version.
return new ProfileImpl(path, delegate); return new ProfileImpl(path, delegate);
} }
...@@ -339,10 +346,9 @@ void ProfileImpl::DoFinalInit() { ...@@ -339,10 +346,9 @@ void ProfileImpl::DoFinalInit() {
} else { } else {
// Async profile loading is used, so call this on the FILE thread instead. // Async profile loading is used, so call this on the FILE thread instead.
// It is safe since all other file operations should also be done there. // It is safe since all other file operations should also be done there.
BrowserThread::PostTask(BrowserThread::FILE, BrowserThread::PostTask(
FROM_HERE, BrowserThread::FILE, FROM_HERE,
NewRunnableFunction(&file_util::CreateDirectory, base::Bind(&CreateDirectoryNoResult, base_cache_path_));
base_cache_path_));
} }
#if !defined(OS_CHROMEOS) #if !defined(OS_CHROMEOS)
...@@ -642,10 +648,8 @@ ProfileImpl::~ProfileImpl() { ...@@ -642,10 +648,8 @@ ProfileImpl::~ProfileImpl() {
if (appcache_service_ && clear_local_state_on_exit_) { if (appcache_service_ && clear_local_state_on_exit_) {
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE, BrowserThread::IO, FROM_HERE,
NewRunnableMethod( base::Bind(&appcache::AppCacheService::set_clear_local_state_on_exit,
appcache_service_.get(), appcache_service_.get(), true));
&appcache::AppCacheService::set_clear_local_state_on_exit,
true));
} }
if (webkit_context_.get()) if (webkit_context_.get())
...@@ -669,9 +673,8 @@ ProfileImpl::~ProfileImpl() { ...@@ -669,9 +673,8 @@ ProfileImpl::~ProfileImpl() {
if (db_tracker_) { if (db_tracker_) {
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE, BrowserThread::FILE, FROM_HERE,
NewRunnableMethod( base::Bind(&webkit_database::DatabaseTracker::Shutdown,
db_tracker_.get(), db_tracker_.get()));
&webkit_database::DatabaseTracker::Shutdown));
} }
// Password store uses WebDB, shut it down before the WebDB has been shutdown. // Password store uses WebDB, shut it down before the WebDB has been shutdown.
...@@ -971,10 +974,9 @@ void ProfileImpl::RegisterExtensionWithRequestContexts( ...@@ -971,10 +974,9 @@ void ProfileImpl::RegisterExtensionWithRequestContexts(
GetExtensionService()->IsIncognitoEnabled(extension->id()); GetExtensionService()->IsIncognitoEnabled(extension->id());
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE, BrowserThread::IO, FROM_HERE,
NewRunnableMethod(extension_info_map_.get(), base::Bind(&ExtensionInfoMap::AddExtension, extension_info_map_.get(),
&ExtensionInfoMap::AddExtension, make_scoped_refptr(extension), install_time,
make_scoped_refptr(extension), incognito_enabled));
install_time, incognito_enabled));
} }
void ProfileImpl::UnregisterExtensionWithRequestContexts( void ProfileImpl::UnregisterExtensionWithRequestContexts(
...@@ -982,10 +984,8 @@ void ProfileImpl::UnregisterExtensionWithRequestContexts( ...@@ -982,10 +984,8 @@ void ProfileImpl::UnregisterExtensionWithRequestContexts(
const extension_misc::UnloadedExtensionReason reason) { const extension_misc::UnloadedExtensionReason reason) {
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE, BrowserThread::IO, FROM_HERE,
NewRunnableMethod(extension_info_map_.get(), base::Bind(&ExtensionInfoMap::RemoveExtension, extension_info_map_.get(),
&ExtensionInfoMap::RemoveExtension, extension_id, reason));
extension_id,
reason));
} }
net::SSLConfigService* ProfileImpl::GetSSLConfigService() { net::SSLConfigService* ProfileImpl::GetSSLConfigService() {
...@@ -1369,13 +1369,12 @@ void ProfileImpl::CreateQuotaManagerAndClients() { ...@@ -1369,13 +1369,12 @@ void ProfileImpl::CreateQuotaManagerAndClients() {
appcache_service_ = new ChromeAppCacheService(quota_manager_->proxy()); appcache_service_ = new ChromeAppCacheService(quota_manager_->proxy());
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE, BrowserThread::IO, FROM_HERE,
NewRunnableMethod( base::Bind(&ChromeAppCacheService::InitializeOnIOThread,
appcache_service_.get(), appcache_service_.get(),
&ChromeAppCacheService::InitializeOnIOThread, IsOffTheRecord()
IsOffTheRecord() ? FilePath() : GetPath().Append(chrome::kAppCacheDirname),
? FilePath() : GetPath().Append(chrome::kAppCacheDirname), &GetResourceContext(),
&GetResourceContext(), make_scoped_refptr(GetExtensionSpecialStoragePolicy())));
make_scoped_refptr(GetExtensionSpecialStoragePolicy())));
} }
WebKitContext* ProfileImpl::GetWebKitContext() { WebKitContext* ProfileImpl::GetWebKitContext() {
...@@ -1531,8 +1530,8 @@ ChromeBlobStorageContext* ProfileImpl::GetBlobStorageContext() { ...@@ -1531,8 +1530,8 @@ ChromeBlobStorageContext* ProfileImpl::GetBlobStorageContext() {
blob_storage_context_ = new ChromeBlobStorageContext(); blob_storage_context_ = new ChromeBlobStorageContext();
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE, BrowserThread::IO, FROM_HERE,
NewRunnableMethod(blob_storage_context_.get(), base::Bind(&ChromeBlobStorageContext::InitializeOnIOThread,
&ChromeBlobStorageContext::InitializeOnIOThread)); blob_storage_context_.get()));
} }
return blob_storage_context_; return blob_storage_context_;
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/logging.h" #include "base/logging.h"
...@@ -90,11 +91,8 @@ class ChromeCookieMonsterDelegate : public net::CookieMonster::Delegate { ...@@ -90,11 +91,8 @@ class ChromeCookieMonsterDelegate : public net::CookieMonster::Delegate {
net::CookieMonster::Delegate::ChangeCause cause) { net::CookieMonster::Delegate::ChangeCause cause) {
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE, BrowserThread::UI, FROM_HERE,
NewRunnableMethod(this, base::Bind(&ChromeCookieMonsterDelegate::OnCookieChangedAsyncHelper,
&ChromeCookieMonsterDelegate::OnCookieChangedAsyncHelper, this, cookie, removed, cause));
cookie,
removed,
cause));
} }
private: private:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment