Commit 09e170f5 authored by rickcam@chromium.org's avatar rickcam@chromium.org

Converted top-level NewRunnableMethod and straggler NewRunnableFunction usage...

Converted top-level NewRunnableMethod and straggler NewRunnableFunction usage to Bind for Sync module

BUG=102167
TEST=unit_tests/regression


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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107822 0039d316-1c4b-4281-b951-d872f2087c98
parent 0bfff1df
...@@ -93,9 +93,7 @@ bool AutofillDataTypeController::StartAssociationAsync() { ...@@ -93,9 +93,7 @@ bool AutofillDataTypeController::StartAssociationAsync() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_EQ(state(), ASSOCIATING); DCHECK_EQ(state(), ASSOCIATING);
return BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, return BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
NewRunnableMethod( base::Bind(&AutofillDataTypeController::StartAssociation, this));
this,
&AutofillDataTypeController::StartAssociation));
} }
void AutofillDataTypeController::CreateSyncComponents() { void AutofillDataTypeController::CreateSyncComponents() {
...@@ -122,9 +120,7 @@ bool AutofillDataTypeController::StopAssociationAsync() { ...@@ -122,9 +120,7 @@ bool AutofillDataTypeController::StopAssociationAsync() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_EQ(state(), STOPPING); DCHECK_EQ(state(), STOPPING);
return BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, return BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
NewRunnableMethod( base::Bind(&AutofillDataTypeController::StopAssociation, this));
this,
&AutofillDataTypeController::StopAssociation));
} }
syncable::ModelType AutofillDataTypeController::type() const { syncable::ModelType AutofillDataTypeController::type() const {
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "chrome/browser/sync/glue/browser_thread_model_worker.h" #include "chrome/browser/sync/glue/browser_thread_model_worker.h"
#include "base/bind.h"
#include "base/synchronization/waitable_event.h" #include "base/synchronization/waitable_event.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
...@@ -28,12 +29,8 @@ UnrecoverableErrorInfo BrowserThreadModelWorker::DoWorkAndWaitUntilDone( ...@@ -28,12 +29,8 @@ UnrecoverableErrorInfo BrowserThreadModelWorker::DoWorkAndWaitUntilDone(
if (!BrowserThread::PostTask( if (!BrowserThread::PostTask(
thread_, thread_,
FROM_HERE, FROM_HERE,
NewRunnableMethod( base::Bind(&BrowserThreadModelWorker::CallDoWorkAndSignalTask, this,
this, work, &done, &error_info))) {
&BrowserThreadModelWorker::CallDoWorkAndSignalTask,
work,
&done,
&error_info))) {
NOTREACHED() << "Failed to post task to thread " << thread_; NOTREACHED() << "Failed to post task to thread " << thread_;
return error_info; return error_info;
} }
......
...@@ -193,7 +193,7 @@ bool HttpBridge::MakeSynchronousPost(int* error_code, int* response_code) { ...@@ -193,7 +193,7 @@ bool HttpBridge::MakeSynchronousPost(int* error_code, int* response_code) {
if (!BrowserThread::PostTask( if (!BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE, BrowserThread::IO, FROM_HERE,
NewRunnableMethod(this, &HttpBridge::CallMakeAsynchronousPost))) { base::Bind(&HttpBridge::CallMakeAsynchronousPost, this))) {
// This usually happens when we're in a unit test. // This usually happens when we're in a unit test.
LOG(WARNING) << "Could not post CallMakeAsynchronousPost task"; LOG(WARNING) << "Could not post CallMakeAsynchronousPost task";
return false; return false;
......
...@@ -46,7 +46,7 @@ bool PasswordDataTypeController::StartAssociationAsync() { ...@@ -46,7 +46,7 @@ bool PasswordDataTypeController::StartAssociationAsync() {
DCHECK_EQ(state(), ASSOCIATING); DCHECK_EQ(state(), ASSOCIATING);
DCHECK(password_store_.get()); DCHECK(password_store_.get());
password_store_->ScheduleTask( password_store_->ScheduleTask(
NewRunnableMethod(this, &PasswordDataTypeController::StartAssociation)); base::Bind(&PasswordDataTypeController::StartAssociation, this));
return true; return true;
} }
...@@ -67,7 +67,7 @@ bool PasswordDataTypeController::StopAssociationAsync() { ...@@ -67,7 +67,7 @@ bool PasswordDataTypeController::StopAssociationAsync() {
DCHECK_EQ(state(), STOPPING); DCHECK_EQ(state(), STOPPING);
DCHECK(password_store_.get()); DCHECK(password_store_.get());
password_store_->ScheduleTask( password_store_->ScheduleTask(
NewRunnableMethod(this, &PasswordDataTypeController::StopAssociation)); base::Bind(&PasswordDataTypeController::StopAssociation, this));
return true; return true;
} }
......
...@@ -26,8 +26,8 @@ UnrecoverableErrorInfo PasswordModelWorker::DoWorkAndWaitUntilDone( ...@@ -26,8 +26,8 @@ UnrecoverableErrorInfo PasswordModelWorker::DoWorkAndWaitUntilDone(
WaitableEvent done(false, false); WaitableEvent done(false, false);
UnrecoverableErrorInfo error_info; UnrecoverableErrorInfo error_info;
password_store_->ScheduleTask( password_store_->ScheduleTask(
NewRunnableMethod(this, &PasswordModelWorker::CallDoWorkAndSignalTask, base::Bind(&PasswordModelWorker::CallDoWorkAndSignalTask,
work, &done, &error_info)); this, work, &done, &error_info));
done.Wait(); done.Wait();
return error_info; return error_info;
} }
......
...@@ -159,9 +159,9 @@ NonBlockingInvalidationNotifier::NonBlockingInvalidationNotifier( ...@@ -159,9 +159,9 @@ NonBlockingInvalidationNotifier::NonBlockingInvalidationNotifier(
GetIOMessageLoopProxy()) { GetIOMessageLoopProxy()) {
if (!io_message_loop_proxy_->PostTask( if (!io_message_loop_proxy_->PostTask(
FROM_HERE, FROM_HERE,
NewRunnableMethod( base::Bind(
core_.get(),
&NonBlockingInvalidationNotifier::Core::Initialize, &NonBlockingInvalidationNotifier::Core::Initialize,
core_.get(),
notifier_options, notifier_options,
initial_max_invalidation_versions, initial_max_invalidation_versions,
invalidation_version_tracker, invalidation_version_tracker,
...@@ -174,9 +174,8 @@ NonBlockingInvalidationNotifier::~NonBlockingInvalidationNotifier() { ...@@ -174,9 +174,8 @@ NonBlockingInvalidationNotifier::~NonBlockingInvalidationNotifier() {
DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread()); DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread());
if (!io_message_loop_proxy_->PostTask( if (!io_message_loop_proxy_->PostTask(
FROM_HERE, FROM_HERE,
NewRunnableMethod( base::Bind(&NonBlockingInvalidationNotifier::Core::Teardown,
core_.get(), core_.get()))) {
&NonBlockingInvalidationNotifier::Core::Teardown))) {
NOTREACHED(); NOTREACHED();
} }
} }
...@@ -198,10 +197,8 @@ void NonBlockingInvalidationNotifier::SetUniqueId( ...@@ -198,10 +197,8 @@ void NonBlockingInvalidationNotifier::SetUniqueId(
DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread()); DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread());
if (!io_message_loop_proxy_->PostTask( if (!io_message_loop_proxy_->PostTask(
FROM_HERE, FROM_HERE,
NewRunnableMethod( base::Bind(&NonBlockingInvalidationNotifier::Core::SetUniqueId,
core_.get(), core_.get(), unique_id))) {
&NonBlockingInvalidationNotifier::Core::SetUniqueId,
unique_id))) {
NOTREACHED(); NOTREACHED();
} }
} }
...@@ -210,10 +207,8 @@ void NonBlockingInvalidationNotifier::SetState(const std::string& state) { ...@@ -210,10 +207,8 @@ void NonBlockingInvalidationNotifier::SetState(const std::string& state) {
DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread()); DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread());
if (!io_message_loop_proxy_->PostTask( if (!io_message_loop_proxy_->PostTask(
FROM_HERE, FROM_HERE,
NewRunnableMethod( base::Bind(&NonBlockingInvalidationNotifier::Core::SetState,
core_.get(), core_.get(), state))) {
&NonBlockingInvalidationNotifier::Core::SetState,
state))) {
NOTREACHED(); NOTREACHED();
} }
} }
...@@ -223,10 +218,8 @@ void NonBlockingInvalidationNotifier::UpdateCredentials( ...@@ -223,10 +218,8 @@ void NonBlockingInvalidationNotifier::UpdateCredentials(
DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread()); DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread());
if (!io_message_loop_proxy_->PostTask( if (!io_message_loop_proxy_->PostTask(
FROM_HERE, FROM_HERE,
NewRunnableMethod( base::Bind(&NonBlockingInvalidationNotifier::Core::UpdateCredentials,
core_.get(), core_.get(), email, token))) {
&NonBlockingInvalidationNotifier::Core::UpdateCredentials,
email, token))) {
NOTREACHED(); NOTREACHED();
} }
} }
...@@ -236,10 +229,8 @@ void NonBlockingInvalidationNotifier::UpdateEnabledTypes( ...@@ -236,10 +229,8 @@ void NonBlockingInvalidationNotifier::UpdateEnabledTypes(
DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread()); DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread());
if (!io_message_loop_proxy_->PostTask( if (!io_message_loop_proxy_->PostTask(
FROM_HERE, FROM_HERE,
NewRunnableMethod( base::Bind(&NonBlockingInvalidationNotifier::Core::UpdateEnabledTypes,
core_.get(), core_.get(), enabled_types))) {
&NonBlockingInvalidationNotifier::Core::UpdateEnabledTypes,
enabled_types))) {
NOTREACHED(); NOTREACHED();
} }
} }
......
...@@ -585,7 +585,7 @@ class WriteTransactionTest: public WriteTransaction { ...@@ -585,7 +585,7 @@ class WriteTransactionTest: public WriteTransaction {
// Our fake server updater. Needs the RefCountedThreadSafe inheritance so we can // Our fake server updater. Needs the RefCountedThreadSafe inheritance so we can
// post tasks with it. // post tasks with it.
class FakeServerUpdater: public base::RefCountedThreadSafe<FakeServerUpdater> { class FakeServerUpdater : public base::RefCountedThreadSafe<FakeServerUpdater> {
public: public:
FakeServerUpdater(TestProfileSyncService* service, FakeServerUpdater(TestProfileSyncService* service,
scoped_ptr<WaitableEvent>* wait_for_start, scoped_ptr<WaitableEvent>* wait_for_start,
...@@ -652,7 +652,7 @@ class FakeServerUpdater: public base::RefCountedThreadSafe<FakeServerUpdater> { ...@@ -652,7 +652,7 @@ class FakeServerUpdater: public base::RefCountedThreadSafe<FakeServerUpdater> {
&FakeServerUpdater::Update)); &FakeServerUpdater::Update));
ASSERT_FALSE(BrowserThread::CurrentlyOn(BrowserThread::DB)); ASSERT_FALSE(BrowserThread::CurrentlyOn(BrowserThread::DB));
if (!BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, if (!BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
NewRunnableMethod(this, &FakeServerUpdater::Update))) { base::Bind(&FakeServerUpdater::Update, this))) {
NOTREACHED() << "Failed to post task to the db thread."; NOTREACHED() << "Failed to post task to the db thread.";
return; return;
} }
...@@ -665,7 +665,7 @@ class FakeServerUpdater: public base::RefCountedThreadSafe<FakeServerUpdater> { ...@@ -665,7 +665,7 @@ class FakeServerUpdater: public base::RefCountedThreadSafe<FakeServerUpdater> {
ASSERT_FALSE(BrowserThread::CurrentlyOn(BrowserThread::DB)); ASSERT_FALSE(BrowserThread::CurrentlyOn(BrowserThread::DB));
is_finished_.Reset(); is_finished_.Reset();
if (!BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, if (!BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
NewRunnableMethod(this, &FakeServerUpdater::Update))) { base::Bind(&FakeServerUpdater::Update, this))) {
NOTREACHED() << "Failed to post task to the db thread."; NOTREACHED() << "Failed to post task to the db thread.";
return; return;
} }
......
...@@ -764,8 +764,8 @@ bool ProfileSyncServiceHarness::AwaitStatusChangeWithTimeout( ...@@ -764,8 +764,8 @@ bool ProfileSyncServiceHarness::AwaitStatusChangeWithTimeout(
loop->SetNestableTasksAllowed(true); loop->SetNestableTasksAllowed(true);
loop->PostDelayedTask( loop->PostDelayedTask(
FROM_HERE, FROM_HERE,
NewRunnableMethod(timeout_signal.get(), base::Bind(&StateChangeTimeoutEvent::Callback,
&StateChangeTimeoutEvent::Callback), timeout_signal.get()),
timeout_milliseconds); timeout_milliseconds);
loop->Run(); loop->Run();
loop->SetNestableTasksAllowed(did_allow_nestable_tasks); loop->SetNestableTasksAllowed(did_allow_nestable_tasks);
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "chrome/browser/sync/profile_sync_test_util.h" #include "chrome/browser/sync/profile_sync_test_util.h"
#include "base/bind.h"
#include "base/task.h" #include "base/task.h"
#include "base/threading/thread.h" #include "base/threading/thread.h"
...@@ -20,7 +21,7 @@ void ThreadNotificationService::Init() { ...@@ -20,7 +21,7 @@ void ThreadNotificationService::Init() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
notification_thread_->message_loop()->PostTask( notification_thread_->message_loop()->PostTask(
FROM_HERE, FROM_HERE,
NewRunnableMethod(this, &ThreadNotificationService::InitTask)); base::Bind(&ThreadNotificationService::InitTask, this));
done_event_.Wait(); done_event_.Wait();
} }
...@@ -28,8 +29,7 @@ void ThreadNotificationService::TearDown() { ...@@ -28,8 +29,7 @@ void ThreadNotificationService::TearDown() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
notification_thread_->message_loop()->PostTask( notification_thread_->message_loop()->PostTask(
FROM_HERE, FROM_HERE,
NewRunnableMethod(this, base::Bind(&ThreadNotificationService::TearDownTask, this));
&ThreadNotificationService::TearDownTask));
done_event_.Wait(); done_event_.Wait();
} }
...@@ -60,11 +60,7 @@ void ThreadNotifier::Notify(int type, ...@@ -60,11 +60,7 @@ void ThreadNotifier::Notify(int type,
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
notify_thread_->message_loop()->PostTask( notify_thread_->message_loop()->PostTask(
FROM_HERE, FROM_HERE,
NewRunnableMethod(this, base::Bind(&ThreadNotifier::NotifyTask, this, type, source, details));
&ThreadNotifier::NotifyTask,
type,
source,
details));
done_event_.Wait(); done_event_.Wait();
} }
......
...@@ -40,7 +40,7 @@ class GetAllAutofillEntries ...@@ -40,7 +40,7 @@ class GetAllAutofillEntries
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::DB, BrowserThread::DB,
FROM_HERE, FROM_HERE,
NewRunnableMethod(this, &GetAllAutofillEntries::Run)); base::Bind(&GetAllAutofillEntries::Run, this));
done_event_.Wait(); done_event_.Wait();
} }
......
...@@ -66,7 +66,7 @@ void AddLogin(PasswordStore* store, const PasswordForm& form) { ...@@ -66,7 +66,7 @@ void AddLogin(PasswordStore* store, const PasswordForm& form) {
ASSERT_TRUE(store); ASSERT_TRUE(store);
base::WaitableEvent wait_event(true, false); base::WaitableEvent wait_event(true, false);
store->AddLogin(form); store->AddLogin(form);
store->ScheduleTask(NewRunnableFunction(&PasswordStoreCallback, &wait_event)); store->ScheduleTask(base::Bind(&PasswordStoreCallback, &wait_event));
wait_event.Wait(); wait_event.Wait();
} }
...@@ -74,7 +74,7 @@ void UpdateLogin(PasswordStore* store, const PasswordForm& form) { ...@@ -74,7 +74,7 @@ void UpdateLogin(PasswordStore* store, const PasswordForm& form) {
ASSERT_TRUE(store); ASSERT_TRUE(store);
base::WaitableEvent wait_event(true, false); base::WaitableEvent wait_event(true, false);
store->UpdateLogin(form); store->UpdateLogin(form);
store->ScheduleTask(NewRunnableFunction(&PasswordStoreCallback, &wait_event)); store->ScheduleTask(base::Bind(&PasswordStoreCallback, &wait_event));
wait_event.Wait(); wait_event.Wait();
} }
...@@ -91,7 +91,7 @@ void RemoveLogin(PasswordStore* store, const PasswordForm& form) { ...@@ -91,7 +91,7 @@ void RemoveLogin(PasswordStore* store, const PasswordForm& form) {
ASSERT_TRUE(store); ASSERT_TRUE(store);
base::WaitableEvent wait_event(true, false); base::WaitableEvent wait_event(true, false);
store->RemoveLogin(form); store->RemoveLogin(form);
store->ScheduleTask(NewRunnableFunction(&PasswordStoreCallback, &wait_event)); store->ScheduleTask(base::Bind(&PasswordStoreCallback, &wait_event));
wait_event.Wait(); wait_event.Wait();
} }
......
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