diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-16 01:58:28 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-16 01:58:28 +0000 |
commit | 4969b012f10da24416e15e8812281519caf528ec (patch) | |
tree | a431b70300694107dab580fa64d333d1ef62fad6 /sync | |
parent | e67eb42a67faaa070b80a391cb1b11e39d8e6368 (diff) | |
download | chromium_src-4969b012f10da24416e15e8812281519caf528ec.zip chromium_src-4969b012f10da24416e15e8812281519caf528ec.tar.gz chromium_src-4969b012f10da24416e15e8812281519caf528ec.tar.bz2 |
Replace GetIOMessageLoopProxy() with GetNetworkTaskRunner() in UrlRequestContextGetter.
Also updated all code that depends on that methods.
TBR=mnissler@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10539148
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142560 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-rw-r--r-- | sync/notifier/non_blocking_invalidation_notifier.cc | 68 | ||||
-rw-r--r-- | sync/notifier/non_blocking_invalidation_notifier.h | 8 |
2 files changed, 39 insertions, 37 deletions
diff --git a/sync/notifier/non_blocking_invalidation_notifier.cc b/sync/notifier/non_blocking_invalidation_notifier.cc index 531286f..f9a7bd1 100644 --- a/sync/notifier/non_blocking_invalidation_notifier.cc +++ b/sync/notifier/non_blocking_invalidation_notifier.cc @@ -4,9 +4,11 @@ #include "sync/notifier/non_blocking_invalidation_notifier.h" +#include "base/location.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop.h" +#include "base/single_thread_task_runner.h" +#include "base/thread_task_runner_handle.h" #include "base/threading/thread.h" #include "jingle/notifier/listener/push_client.h" #include "sync/notifier/invalidation_notifier.h" @@ -54,7 +56,7 @@ class NonBlockingInvalidationNotifier::Core // The variables below should be used only on the I/O thread. const browser_sync::WeakHandle<SyncNotifierObserver> delegate_observer_; scoped_ptr<InvalidationNotifier> invalidation_notifier_; - scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; + scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; DISALLOW_COPY_AND_ASSIGN(Core); }; @@ -79,9 +81,9 @@ void NonBlockingInvalidationNotifier::Core::Initialize( DCHECK(notifier_options.request_context_getter); DCHECK_EQ(notifier::NOTIFICATION_SERVER, notifier_options.notification_method); - io_message_loop_proxy_ = notifier_options.request_context_getter-> - GetIOMessageLoopProxy(); - DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); + network_task_runner_ = notifier_options.request_context_getter-> + GetNetworkTaskRunner(); + DCHECK(network_task_runner_->BelongsToCurrentThread()); invalidation_notifier_.reset( new InvalidationNotifier( notifier::PushClient::CreateDefaultOnIOThread(notifier_options), @@ -94,40 +96,40 @@ void NonBlockingInvalidationNotifier::Core::Initialize( void NonBlockingInvalidationNotifier::Core::Teardown() { - DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(network_task_runner_->BelongsToCurrentThread()); invalidation_notifier_->RemoveObserver(this); invalidation_notifier_.reset(); - io_message_loop_proxy_ = NULL; + network_task_runner_ = NULL; } void NonBlockingInvalidationNotifier::Core::SetUniqueId( const std::string& unique_id) { - DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(network_task_runner_->BelongsToCurrentThread()); invalidation_notifier_->SetUniqueId(unique_id); } void NonBlockingInvalidationNotifier::Core::SetStateDeprecated( const std::string& state) { - DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(network_task_runner_->BelongsToCurrentThread()); invalidation_notifier_->SetStateDeprecated(state); } void NonBlockingInvalidationNotifier::Core::UpdateCredentials( const std::string& email, const std::string& token) { - DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(network_task_runner_->BelongsToCurrentThread()); invalidation_notifier_->UpdateCredentials(email, token); } void NonBlockingInvalidationNotifier::Core::UpdateEnabledTypes( syncable::ModelTypeSet enabled_types) { - DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(network_task_runner_->BelongsToCurrentThread()); invalidation_notifier_->UpdateEnabledTypes(enabled_types); } void NonBlockingInvalidationNotifier::Core::OnIncomingNotification( const syncable::ModelTypePayloadMap& type_payloads, IncomingNotificationSource source) { - DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(network_task_runner_->BelongsToCurrentThread()); delegate_observer_.Call(FROM_HERE, &SyncNotifierObserver::OnIncomingNotification, type_payloads, @@ -136,7 +138,7 @@ void NonBlockingInvalidationNotifier::Core::OnIncomingNotification( void NonBlockingInvalidationNotifier::Core::OnNotificationStateChange( bool notifications_enabled) { - DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(network_task_runner_->BelongsToCurrentThread()); delegate_observer_.Call(FROM_HERE, &SyncNotifierObserver::OnNotificationStateChange, notifications_enabled); @@ -153,11 +155,11 @@ NonBlockingInvalidationNotifier::NonBlockingInvalidationNotifier( core_( new Core(browser_sync::MakeWeakHandle( weak_ptr_factory_.GetWeakPtr()))), - parent_message_loop_proxy_( - base::MessageLoopProxy::current()), - io_message_loop_proxy_(notifier_options.request_context_getter-> - GetIOMessageLoopProxy()) { - if (!io_message_loop_proxy_->PostTask( + parent_task_runner_( + base::ThreadTaskRunnerHandle::Get()), + network_task_runner_(notifier_options.request_context_getter-> + GetNetworkTaskRunner()) { + if (!network_task_runner_->PostTask( FROM_HERE, base::Bind( &NonBlockingInvalidationNotifier::Core::Initialize, @@ -172,8 +174,8 @@ NonBlockingInvalidationNotifier::NonBlockingInvalidationNotifier( } NonBlockingInvalidationNotifier::~NonBlockingInvalidationNotifier() { - DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread()); - if (!io_message_loop_proxy_->PostTask( + DCHECK(parent_task_runner_->BelongsToCurrentThread()); + if (!network_task_runner_->PostTask( FROM_HERE, base::Bind(&NonBlockingInvalidationNotifier::Core::Teardown, core_.get()))) { @@ -183,20 +185,20 @@ NonBlockingInvalidationNotifier::~NonBlockingInvalidationNotifier() { void NonBlockingInvalidationNotifier::AddObserver( SyncNotifierObserver* observer) { - DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(parent_task_runner_->BelongsToCurrentThread()); observers_.AddObserver(observer); } void NonBlockingInvalidationNotifier::RemoveObserver( SyncNotifierObserver* observer) { - DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(parent_task_runner_->BelongsToCurrentThread()); observers_.RemoveObserver(observer); } void NonBlockingInvalidationNotifier::SetUniqueId( const std::string& unique_id) { - DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread()); - if (!io_message_loop_proxy_->PostTask( + DCHECK(parent_task_runner_->BelongsToCurrentThread()); + if (!network_task_runner_->PostTask( FROM_HERE, base::Bind(&NonBlockingInvalidationNotifier::Core::SetUniqueId, core_.get(), unique_id))) { @@ -206,8 +208,8 @@ void NonBlockingInvalidationNotifier::SetUniqueId( void NonBlockingInvalidationNotifier::SetStateDeprecated( const std::string& state) { - DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread()); - if (!io_message_loop_proxy_->PostTask( + DCHECK(parent_task_runner_->BelongsToCurrentThread()); + if (!network_task_runner_->PostTask( FROM_HERE, base::Bind( &NonBlockingInvalidationNotifier::Core::SetStateDeprecated, @@ -218,8 +220,8 @@ void NonBlockingInvalidationNotifier::SetStateDeprecated( void NonBlockingInvalidationNotifier::UpdateCredentials( const std::string& email, const std::string& token) { - DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread()); - if (!io_message_loop_proxy_->PostTask( + DCHECK(parent_task_runner_->BelongsToCurrentThread()); + if (!network_task_runner_->PostTask( FROM_HERE, base::Bind(&NonBlockingInvalidationNotifier::Core::UpdateCredentials, core_.get(), email, token))) { @@ -229,8 +231,8 @@ void NonBlockingInvalidationNotifier::UpdateCredentials( void NonBlockingInvalidationNotifier::UpdateEnabledTypes( syncable::ModelTypeSet enabled_types) { - DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread()); - if (!io_message_loop_proxy_->PostTask( + DCHECK(parent_task_runner_->BelongsToCurrentThread()); + if (!network_task_runner_->PostTask( FROM_HERE, base::Bind(&NonBlockingInvalidationNotifier::Core::UpdateEnabledTypes, core_.get(), enabled_types))) { @@ -240,7 +242,7 @@ void NonBlockingInvalidationNotifier::UpdateEnabledTypes( void NonBlockingInvalidationNotifier::SendNotification( syncable::ModelTypeSet changed_types) { - DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(parent_task_runner_->BelongsToCurrentThread()); // InvalidationClient doesn't implement SendNotification(), so no // need to forward on the call. } @@ -248,14 +250,14 @@ void NonBlockingInvalidationNotifier::SendNotification( void NonBlockingInvalidationNotifier::OnIncomingNotification( const syncable::ModelTypePayloadMap& type_payloads, IncomingNotificationSource source) { - DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(parent_task_runner_->BelongsToCurrentThread()); FOR_EACH_OBSERVER(SyncNotifierObserver, observers_, OnIncomingNotification(type_payloads, source)); } void NonBlockingInvalidationNotifier::OnNotificationStateChange( bool notifications_enabled) { - DCHECK(parent_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(parent_task_runner_->BelongsToCurrentThread()); FOR_EACH_OBSERVER(SyncNotifierObserver, observers_, OnNotificationStateChange(notifications_enabled)); } diff --git a/sync/notifier/non_blocking_invalidation_notifier.h b/sync/notifier/non_blocking_invalidation_notifier.h index c4f28807..31efc74 100644 --- a/sync/notifier/non_blocking_invalidation_notifier.h +++ b/sync/notifier/non_blocking_invalidation_notifier.h @@ -23,8 +23,8 @@ #include "sync/util/weak_handle.h" namespace base { -class MessageLoopProxy; -} +class SingleThreadTaskRunner; +} // namespace base namespace sync_notifier { @@ -73,8 +73,8 @@ class NonBlockingInvalidationNotifier // The real guts of NonBlockingInvalidationNotifier, which allows // this class to live completely on the parent thread. scoped_refptr<Core> core_; - scoped_refptr<base::MessageLoopProxy> parent_message_loop_proxy_; - scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; + scoped_refptr<base::SingleThreadTaskRunner> parent_task_runner_; + scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; DISALLOW_COPY_AND_ASSIGN(NonBlockingInvalidationNotifier); }; |