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 @@
#include "chrome/browser/profiles/off_the_record_profile_impl.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/file_path.h"
......@@ -112,8 +113,7 @@ void OffTheRecordProfileImpl::Init() {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
NewRunnableFunction(
&NotifyOTRProfileCreatedOnIOThread, profile_, this));
base::Bind(&NotifyOTRProfileCreatedOnIOThread, profile_, this));
}
OffTheRecordProfileImpl::~OffTheRecordProfileImpl() {
......@@ -128,15 +128,14 @@ OffTheRecordProfileImpl::~OffTheRecordProfileImpl() {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
NewRunnableFunction(&NotifyOTRProfileDestroyedOnIOThread, profile_,
this));
base::Bind(&NotifyOTRProfileDestroyedOnIOThread, profile_, this));
// Clean up all DB files/directories
if (db_tracker_) {
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
NewRunnableMethod(db_tracker_.get(),
&webkit_database::DatabaseTracker::Shutdown));
base::Bind(&webkit_database::DatabaseTracker::Shutdown,
db_tracker_.get()));
}
BrowserList::RemoveObserver(this);
......@@ -517,9 +516,8 @@ ChromeBlobStorageContext* OffTheRecordProfileImpl::GetBlobStorageContext() {
blob_storage_context_ = new ChromeBlobStorageContext();
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
NewRunnableMethod(
blob_storage_context_.get(),
&ChromeBlobStorageContext::InitializeOnIOThread));
base::Bind(&ChromeBlobStorageContext::InitializeOnIOThread,
blob_storage_context_.get()));
}
return blob_storage_context_;
}
......@@ -617,13 +615,12 @@ void OffTheRecordProfileImpl::CreateQuotaManagerAndClients() {
appcache_service_ = new ChromeAppCacheService(quota_manager_->proxy());
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
NewRunnableMethod(
appcache_service_.get(),
&ChromeAppCacheService::InitializeOnIOThread,
IsOffTheRecord()
? FilePath() : GetPath().Append(chrome::kAppCacheDirname),
&GetResourceContext(),
make_scoped_refptr(GetExtensionSpecialStoragePolicy())));
base::Bind(&ChromeAppCacheService::InitializeOnIOThread,
appcache_service_.get(),
IsOffTheRecord()
? FilePath() : GetPath().Append(chrome::kAppCacheDirname),
&GetResourceContext(),
make_scoped_refptr(GetExtensionSpecialStoragePolicy())));
}
#if defined(OS_CHROMEOS)
......
......@@ -4,6 +4,7 @@
#include "chrome/browser/profiles/profile_impl.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/environment.h"
......@@ -159,6 +160,13 @@ enum ContextType {
typedef std::list<std::pair<FilePath::StringType, int> >
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)
void AddFileManagerExtension(ComponentExtensionList* component_extensions) {
#ifndef NDEBUG
......@@ -240,10 +248,9 @@ Profile* Profile::CreateProfileAsync(const FilePath& path,
Profile::Delegate* delegate) {
DCHECK(delegate);
// This is safe while all file operations are done on the FILE thread.
BrowserThread::PostTask(BrowserThread::FILE,
FROM_HERE,
NewRunnableFunction(&file_util::CreateDirectory,
path));
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
base::Bind(&CreateDirectoryNoResult, path));
// Async version.
return new ProfileImpl(path, delegate);
}
......@@ -339,10 +346,9 @@ void ProfileImpl::DoFinalInit() {
} else {
// 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.
BrowserThread::PostTask(BrowserThread::FILE,
FROM_HERE,
NewRunnableFunction(&file_util::CreateDirectory,
base_cache_path_));
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
base::Bind(&CreateDirectoryNoResult, base_cache_path_));
}
#if !defined(OS_CHROMEOS)
......@@ -642,10 +648,8 @@ ProfileImpl::~ProfileImpl() {
if (appcache_service_ && clear_local_state_on_exit_) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
NewRunnableMethod(
appcache_service_.get(),
&appcache::AppCacheService::set_clear_local_state_on_exit,
true));
base::Bind(&appcache::AppCacheService::set_clear_local_state_on_exit,
appcache_service_.get(), true));
}
if (webkit_context_.get())
......@@ -669,9 +673,8 @@ ProfileImpl::~ProfileImpl() {
if (db_tracker_) {
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
NewRunnableMethod(
db_tracker_.get(),
&webkit_database::DatabaseTracker::Shutdown));
base::Bind(&webkit_database::DatabaseTracker::Shutdown,
db_tracker_.get()));
}
// Password store uses WebDB, shut it down before the WebDB has been shutdown.
......@@ -971,10 +974,9 @@ void ProfileImpl::RegisterExtensionWithRequestContexts(
GetExtensionService()->IsIncognitoEnabled(extension->id());
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
NewRunnableMethod(extension_info_map_.get(),
&ExtensionInfoMap::AddExtension,
make_scoped_refptr(extension),
install_time, incognito_enabled));
base::Bind(&ExtensionInfoMap::AddExtension, extension_info_map_.get(),
make_scoped_refptr(extension), install_time,
incognito_enabled));
}
void ProfileImpl::UnregisterExtensionWithRequestContexts(
......@@ -982,10 +984,8 @@ void ProfileImpl::UnregisterExtensionWithRequestContexts(
const extension_misc::UnloadedExtensionReason reason) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
NewRunnableMethod(extension_info_map_.get(),
&ExtensionInfoMap::RemoveExtension,
extension_id,
reason));
base::Bind(&ExtensionInfoMap::RemoveExtension, extension_info_map_.get(),
extension_id, reason));
}
net::SSLConfigService* ProfileImpl::GetSSLConfigService() {
......@@ -1369,13 +1369,12 @@ void ProfileImpl::CreateQuotaManagerAndClients() {
appcache_service_ = new ChromeAppCacheService(quota_manager_->proxy());
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
NewRunnableMethod(
appcache_service_.get(),
&ChromeAppCacheService::InitializeOnIOThread,
IsOffTheRecord()
? FilePath() : GetPath().Append(chrome::kAppCacheDirname),
&GetResourceContext(),
make_scoped_refptr(GetExtensionSpecialStoragePolicy())));
base::Bind(&ChromeAppCacheService::InitializeOnIOThread,
appcache_service_.get(),
IsOffTheRecord()
? FilePath() : GetPath().Append(chrome::kAppCacheDirname),
&GetResourceContext(),
make_scoped_refptr(GetExtensionSpecialStoragePolicy())));
}
WebKitContext* ProfileImpl::GetWebKitContext() {
......@@ -1531,8 +1530,8 @@ ChromeBlobStorageContext* ProfileImpl::GetBlobStorageContext() {
blob_storage_context_ = new ChromeBlobStorageContext();
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
NewRunnableMethod(blob_storage_context_.get(),
&ChromeBlobStorageContext::InitializeOnIOThread));
base::Bind(&ChromeBlobStorageContext::InitializeOnIOThread,
blob_storage_context_.get()));
}
return blob_storage_context_;
}
......
......@@ -8,6 +8,7 @@
#include "base/basictypes.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/logging.h"
......@@ -90,11 +91,8 @@ class ChromeCookieMonsterDelegate : public net::CookieMonster::Delegate {
net::CookieMonster::Delegate::ChangeCause cause) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
NewRunnableMethod(this,
&ChromeCookieMonsterDelegate::OnCookieChangedAsyncHelper,
cookie,
removed,
cause));
base::Bind(&ChromeCookieMonsterDelegate::OnCookieChangedAsyncHelper,
this, cookie, removed, cause));
}
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