summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-10 00:05:16 +0000
committermichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-10 00:05:16 +0000
commit410fbd69f0b0708246fc5266b81436fd620479d9 (patch)
treec3ad4aefead8e0b399d4bfef2e60bdc679999e0b
parent10d861c5af3cb03a4e380c4975df61d1d6ab22a4 (diff)
downloadchromium_src-410fbd69f0b0708246fc5266b81436fd620479d9.zip
chromium_src-410fbd69f0b0708246fc5266b81436fd620479d9.tar.gz
chromium_src-410fbd69f0b0708246fc5266b81436fd620479d9.tar.bz2
base::Bind cleanup in SimpleDatabaseSystem
Review URL: http://codereview.chromium.org/8497053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109337 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/support/simple_database_system.cc91
-rw-r--r--webkit/support/simple_database_system.h3
2 files changed, 54 insertions, 40 deletions
diff --git a/webkit/support/simple_database_system.cc b/webkit/support/simple_database_system.cc
index 73a2452..192ced7 100644
--- a/webkit/support/simple_database_system.cc
+++ b/webkit/support/simple_database_system.cc
@@ -5,6 +5,7 @@
#include "webkit/support/simple_database_system.h"
#include "base/auto_reset.h"
+#include "base/bind_helpers.h"
#include "base/file_util.h"
#include "base/message_loop.h"
#include "base/message_loop_proxy.h"
@@ -45,9 +46,10 @@ SimpleDatabaseSystem::SimpleDatabaseSystem()
SimpleDatabaseSystem::~SimpleDatabaseSystem() {
base::WaitableEvent done_event(false, false);
- db_thread_proxy_->PostTask(FROM_HERE,
- NewRunnableMethod(this, &SimpleDatabaseSystem::ThreadCleanup,
- &done_event));
+ db_thread_proxy_->PostTask(
+ FROM_HERE,
+ base::Bind(&SimpleDatabaseSystem::ThreadCleanup,
+ base::Unretained(this), &done_event));
done_event.Wait();
instance_ = NULL;
}
@@ -56,37 +58,44 @@ void SimpleDatabaseSystem::databaseOpened(const WebKit::WebDatabase& database) {
string16 origin_identifier = database.securityOrigin().databaseIdentifier();
string16 database_name = database.name();
open_connections_->AddOpenConnection(origin_identifier, database_name);
- db_thread_proxy_->PostTask(FROM_HERE,
- NewRunnableMethod(this, &SimpleDatabaseSystem::DatabaseOpened,
- origin_identifier,
- database_name, database.displayName(),
- database.estimatedSize()));
+ db_thread_proxy_->PostTask(
+ FROM_HERE,
+ base::Bind(&SimpleDatabaseSystem::DatabaseOpened,
+ base::Unretained(this),
+ origin_identifier,
+ database_name, database.displayName(),
+ database.estimatedSize()));
}
void SimpleDatabaseSystem::databaseModified(
const WebKit::WebDatabase& database) {
- db_thread_proxy_->PostTask(FROM_HERE,
- NewRunnableMethod(this, &SimpleDatabaseSystem::DatabaseModified,
- database.securityOrigin().databaseIdentifier(),
- database.name()));
+ db_thread_proxy_->PostTask(
+ FROM_HERE,
+ base::Bind(&SimpleDatabaseSystem::DatabaseModified,
+ base::Unretained(this),
+ database.securityOrigin().databaseIdentifier(),
+ database.name()));
}
void SimpleDatabaseSystem::databaseClosed(const WebKit::WebDatabase& database) {
string16 origin_identifier = database.securityOrigin().databaseIdentifier();
string16 database_name = database.name();
- db_thread_proxy_->PostTask(FROM_HERE,
- NewRunnableMethod(this, &SimpleDatabaseSystem::DatabaseClosed,
- origin_identifier, database_name));
+ db_thread_proxy_->PostTask(
+ FROM_HERE,
+ base::Bind(&SimpleDatabaseSystem::DatabaseClosed,
+ base::Unretained(this), origin_identifier, database_name));
}
base::PlatformFile SimpleDatabaseSystem::OpenFile(
const string16& vfs_file_name, int desired_flags) {
base::PlatformFile result = base::kInvalidPlatformFileValue;
base::WaitableEvent done_event(false, false);
- db_thread_proxy_->PostTask(FROM_HERE,
- NewRunnableMethod(this, &SimpleDatabaseSystem::VfsOpenFile,
- vfs_file_name, desired_flags,
- &result, &done_event));
+ db_thread_proxy_->PostTask(
+ FROM_HERE,
+ base::Bind(&SimpleDatabaseSystem::VfsOpenFile,
+ base::Unretained(this),
+ vfs_file_name, desired_flags,
+ &result, &done_event));
done_event.Wait();
return result;
}
@@ -95,10 +104,12 @@ int SimpleDatabaseSystem::DeleteFile(
const string16& vfs_file_name, bool sync_dir) {
int result = SQLITE_OK;
base::WaitableEvent done_event(false, false);
- db_thread_proxy_->PostTask(FROM_HERE,
- NewRunnableMethod(this, &SimpleDatabaseSystem::VfsDeleteFile,
- vfs_file_name, sync_dir,
- &result, &done_event));
+ db_thread_proxy_->PostTask(
+ FROM_HERE,
+ base::Bind(&SimpleDatabaseSystem::VfsDeleteFile,
+ base::Unretained(this),
+ vfs_file_name, sync_dir,
+ &result, &done_event));
done_event.Wait();
return result;
}
@@ -106,9 +117,10 @@ int SimpleDatabaseSystem::DeleteFile(
uint32 SimpleDatabaseSystem::GetFileAttributes(const string16& vfs_file_name) {
uint32 result = 0;
base::WaitableEvent done_event(false, false);
- db_thread_proxy_->PostTask(FROM_HERE,
- NewRunnableMethod(this, &SimpleDatabaseSystem::VfsGetFileAttributes,
- vfs_file_name, &result, &done_event));
+ db_thread_proxy_->PostTask(
+ FROM_HERE,
+ base::Bind(&SimpleDatabaseSystem::VfsGetFileAttributes,
+ base::Unretained(this), vfs_file_name, &result, &done_event));
done_event.Wait();
return result;
}
@@ -116,9 +128,10 @@ uint32 SimpleDatabaseSystem::GetFileAttributes(const string16& vfs_file_name) {
int64 SimpleDatabaseSystem::GetFileSize(const string16& vfs_file_name) {
int64 result = 0;
base::WaitableEvent done_event(false, false);
- db_thread_proxy_->PostTask(FROM_HERE,
- NewRunnableMethod(this, &SimpleDatabaseSystem::VfsGetFileSize,
- vfs_file_name, &result, &done_event));
+ db_thread_proxy_->PostTask(
+ FROM_HERE,
+ base::Bind(&SimpleDatabaseSystem::VfsGetFileSize,
+ base::Unretained(this), vfs_file_name, &result, &done_event));
done_event.Wait();
return result;
}
@@ -127,24 +140,28 @@ int64 SimpleDatabaseSystem::GetSpaceAvailable(
const string16& origin_identifier) {
int64 result = 0;
base::WaitableEvent done_event(false, false);
- db_thread_proxy_->PostTask(FROM_HERE,
- NewRunnableMethod(this, &SimpleDatabaseSystem::VfsGetSpaceAvailable,
- origin_identifier, &result, &done_event));
+ db_thread_proxy_->PostTask(
+ FROM_HERE,
+ base::Bind(&SimpleDatabaseSystem::VfsGetSpaceAvailable,
+ base::Unretained(this), origin_identifier,
+ &result, &done_event));
done_event.Wait();
return result;
}
void SimpleDatabaseSystem::ClearAllDatabases() {
open_connections_->WaitForAllDatabasesToClose();
- db_thread_proxy_->PostTask(FROM_HERE,
- NewRunnableMethod(this, &SimpleDatabaseSystem::ResetTracker));
+ db_thread_proxy_->PostTask(
+ FROM_HERE,
+ base::Bind(&SimpleDatabaseSystem::ResetTracker, base::Unretained(this)));
}
void SimpleDatabaseSystem::SetDatabaseQuota(int64 quota) {
if (!db_thread_proxy_->BelongsToCurrentThread()) {
- db_thread_proxy_->PostTask(FROM_HERE,
- NewRunnableMethod(this, &SimpleDatabaseSystem::SetDatabaseQuota,
- quota));
+ db_thread_proxy_->PostTask(
+ FROM_HERE,
+ base::Bind(&SimpleDatabaseSystem::SetDatabaseQuota,
+ base::Unretained(this), quota));
return;
}
quota_per_origin_ = quota;
diff --git a/webkit/support/simple_database_system.h b/webkit/support/simple_database_system.h
index 14c9014..b15cb48 100644
--- a/webkit/support/simple_database_system.h
+++ b/webkit/support/simple_database_system.h
@@ -12,7 +12,6 @@
#include "base/scoped_temp_dir.h"
#include "base/string16.h"
#include "base/synchronization/lock.h"
-#include "base/task.h"
#include "base/threading/thread.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDatabaseObserver.h"
#include "webkit/database/database_connections.h"
@@ -101,6 +100,4 @@ class SimpleDatabaseSystem : public webkit_database::DatabaseTracker::Observer,
static SimpleDatabaseSystem* instance_;
};
-DISABLE_RUNNABLE_METHOD_REFCOUNT(SimpleDatabaseSystem);
-
#endif // WEBKIT_SUPPORT_SIMPLE_DATABASE_SYSTEM_H_