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 | |
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
25 files changed, 220 insertions, 215 deletions
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc index 952f00b..3b006b3 100644 --- a/chrome/browser/io_thread.cc +++ b/chrome/browser/io_thread.cc @@ -255,15 +255,16 @@ class SystemURLRequestContextGetter : public net::URLRequestContextGetter { explicit SystemURLRequestContextGetter(IOThread* io_thread); // Implementation for net::UrlRequestContextGetter. - virtual net::URLRequestContext* GetURLRequestContext(); - virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const; + virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; + virtual scoped_refptr<base::SingleThreadTaskRunner> + GetNetworkTaskRunner() const OVERRIDE; protected: virtual ~SystemURLRequestContextGetter(); private: IOThread* const io_thread_; // Weak pointer, owned by BrowserProcess. - scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; + scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; base::debug::LeakTracker<SystemURLRequestContextGetter> leak_tracker_; }; @@ -271,7 +272,7 @@ class SystemURLRequestContextGetter : public net::URLRequestContextGetter { SystemURLRequestContextGetter::SystemURLRequestContextGetter( IOThread* io_thread) : io_thread_(io_thread), - io_message_loop_proxy_( + network_task_runner_( BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)) { } @@ -284,9 +285,9 @@ net::URLRequestContext* SystemURLRequestContextGetter::GetURLRequestContext() { return io_thread_->globals()->system_request_context.get(); } -scoped_refptr<base::MessageLoopProxy> -SystemURLRequestContextGetter::GetIOMessageLoopProxy() const { - return io_message_loop_proxy_; +scoped_refptr<base::SingleThreadTaskRunner> +SystemURLRequestContextGetter::GetNetworkTaskRunner() const { + return network_task_runner_; } IOThread::Globals:: diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc index 7f8d2ca..0b3d77d 100644 --- a/chrome/browser/net/chrome_url_request_context.cc +++ b/chrome/browser/net/chrome_url_request_context.cc @@ -146,8 +146,8 @@ net::URLRequestContext* ChromeURLRequestContextGetter::GetURLRequestContext() { return url_request_context_; } -scoped_refptr<base::MessageLoopProxy> -ChromeURLRequestContextGetter::GetIOMessageLoopProxy() const { +scoped_refptr<base::SingleThreadTaskRunner> +ChromeURLRequestContextGetter::GetNetworkTaskRunner() const { return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); } diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h index acf13d2..45472ec 100644 --- a/chrome/browser/net/chrome_url_request_context.h +++ b/chrome/browser/net/chrome_url_request_context.h @@ -103,8 +103,8 @@ class ChromeURLRequestContextGetter : public net::URLRequestContextGetter, // // net::URLRequestContextGetter implementation. virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; - virtual scoped_refptr<base::MessageLoopProxy> - GetIOMessageLoopProxy() const OVERRIDE; + virtual scoped_refptr<base::SingleThreadTaskRunner> + GetNetworkTaskRunner() const OVERRIDE; // Convenience overload of GetURLRequestContext() that returns a // ChromeURLRequestContext* rather than a net::URLRequestContext*. diff --git a/chrome/browser/policy/device_management_service.cc b/chrome/browser/policy/device_management_service.cc index 9657719..53140de 100644 --- a/chrome/browser/policy/device_management_service.cc +++ b/chrome/browser/policy/device_management_service.cc @@ -235,8 +235,8 @@ class DeviceManagementRequestContextGetter // Overridden from net::URLRequestContextGetter: virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; - virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() - const OVERRIDE; + virtual scoped_refptr<base::SingleThreadTaskRunner> + GetNetworkTaskRunner() const OVERRIDE; protected: virtual ~DeviceManagementRequestContextGetter() {} @@ -258,8 +258,8 @@ DeviceManagementRequestContextGetter::GetURLRequestContext() { return context_.get(); } -scoped_refptr<base::MessageLoopProxy> -DeviceManagementRequestContextGetter::GetIOMessageLoopProxy() const { +scoped_refptr<base::SingleThreadTaskRunner> +DeviceManagementRequestContextGetter::GetNetworkTaskRunner() const { return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); } diff --git a/chrome/browser/safe_browsing/safe_browsing_service.cc b/chrome/browser/safe_browsing/safe_browsing_service.cc index 5f5d038..6901697 100644 --- a/chrome/browser/safe_browsing/safe_browsing_service.cc +++ b/chrome/browser/safe_browsing/safe_browsing_service.cc @@ -120,15 +120,15 @@ class SafeBrowsingURLRequestContextGetter // Implementation for net::UrlRequestContextGetter. virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; - virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const - OVERRIDE; + virtual scoped_refptr<base::SingleThreadTaskRunner> + GetNetworkTaskRunner() const OVERRIDE; protected: virtual ~SafeBrowsingURLRequestContextGetter(); private: SafeBrowsingService* const sb_service_; // Owned by BrowserProcess. - scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; + scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; base::debug::LeakTracker<SafeBrowsingURLRequestContextGetter> leak_tracker_; }; @@ -136,7 +136,7 @@ class SafeBrowsingURLRequestContextGetter SafeBrowsingURLRequestContextGetter::SafeBrowsingURLRequestContextGetter( SafeBrowsingService* sb_service) : sb_service_(sb_service), - io_message_loop_proxy_( + network_task_runner_( BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)) { } @@ -150,9 +150,9 @@ SafeBrowsingURLRequestContextGetter::GetURLRequestContext() { return sb_service_->url_request_context_.get(); } -scoped_refptr<base::MessageLoopProxy> -SafeBrowsingURLRequestContextGetter::GetIOMessageLoopProxy() const { - return io_message_loop_proxy_; +scoped_refptr<base::SingleThreadTaskRunner> +SafeBrowsingURLRequestContextGetter::GetNetworkTaskRunner() const { + return network_task_runner_; } // static diff --git a/chrome/browser/sync/glue/http_bridge.cc b/chrome/browser/sync/glue/http_bridge.cc index 98a81d9..78fc872 100644 --- a/chrome/browser/sync/glue/http_bridge.cc +++ b/chrome/browser/sync/glue/http_bridge.cc @@ -49,8 +49,8 @@ HttpBridge::RequestContextGetter::GetURLRequestContext() { return context_.get(); } -scoped_refptr<base::MessageLoopProxy> -HttpBridge::RequestContextGetter::GetIOMessageLoopProxy() const { +scoped_refptr<base::SingleThreadTaskRunner> +HttpBridge::RequestContextGetter::GetNetworkTaskRunner() const { return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); } diff --git a/chrome/browser/sync/glue/http_bridge.h b/chrome/browser/sync/glue/http_bridge.h index c05b113..4e749c1 100644 --- a/chrome/browser/sync/glue/http_bridge.h +++ b/chrome/browser/sync/glue/http_bridge.h @@ -84,8 +84,8 @@ class HttpBridge : public base::RefCountedThreadSafe<HttpBridge>, // net::URLRequestContextGetter implementation. virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; - virtual scoped_refptr<base::MessageLoopProxy> - GetIOMessageLoopProxy() const OVERRIDE; + virtual scoped_refptr<base::SingleThreadTaskRunner> + GetNetworkTaskRunner() const OVERRIDE; protected: virtual ~RequestContextGetter(); diff --git a/chrome/service/net/service_url_request_context.cc b/chrome/service/net/service_url_request_context.cc index fa20f21..ad0671f 100644 --- a/chrome/service/net/service_url_request_context.cc +++ b/chrome/service/net/service_url_request_context.cc @@ -154,7 +154,7 @@ ServiceURLRequestContext::~ServiceURLRequestContext() { } ServiceURLRequestContextGetter::ServiceURLRequestContextGetter() - : io_message_loop_proxy_( + : network_task_runner_( g_service_process->io_thread()->message_loop_proxy()) { // Build the default user agent. user_agent_ = MakeUserAgentForServiceProcess(); @@ -177,9 +177,9 @@ ServiceURLRequestContextGetter::GetURLRequestContext() { return url_request_context_.get(); } -scoped_refptr<base::MessageLoopProxy> -ServiceURLRequestContextGetter::GetIOMessageLoopProxy() const { - return io_message_loop_proxy_; +scoped_refptr<base::SingleThreadTaskRunner> +ServiceURLRequestContextGetter::GetNetworkTaskRunner() const { + return network_task_runner_; } ServiceURLRequestContextGetter::~ServiceURLRequestContextGetter() {} diff --git a/chrome/service/net/service_url_request_context.h b/chrome/service/net/service_url_request_context.h index ae2b547..d2220ba 100644 --- a/chrome/service/net/service_url_request_context.h +++ b/chrome/service/net/service_url_request_context.h @@ -53,8 +53,8 @@ class ServiceURLRequestContext : public net::URLRequestContext { class ServiceURLRequestContextGetter : public net::URLRequestContextGetter { public: virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; - virtual scoped_refptr<base::MessageLoopProxy> - GetIOMessageLoopProxy() const OVERRIDE; + virtual scoped_refptr<base::SingleThreadTaskRunner> + GetNetworkTaskRunner() const OVERRIDE; void set_user_agent(const std::string& ua) { user_agent_ = ua; @@ -69,7 +69,7 @@ class ServiceURLRequestContextGetter : public net::URLRequestContextGetter { virtual ~ServiceURLRequestContextGetter(); std::string user_agent_; - scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; + scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; scoped_ptr<net::ProxyConfigService> proxy_config_service_; scoped_ptr<net::URLRequestContext> url_request_context_; }; diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc index 11c649c..dad75db 100644 --- a/chrome/test/base/testing_profile.cc +++ b/chrome/test/base/testing_profile.cc @@ -117,7 +117,8 @@ class TestExtensionURLRequestContextGetter context_.reset(new TestExtensionURLRequestContext()); return context_.get(); } - virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const { + virtual scoped_refptr<base::SingleThreadTaskRunner> + GetNetworkTaskRunner() const OVERRIDE { return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); } diff --git a/content/shell/shell_url_request_context_getter.cc b/content/shell/shell_url_request_context_getter.cc index 2c4b337..06af8f7 100644 --- a/content/shell/shell_url_request_context_getter.cc +++ b/content/shell/shell_url_request_context_getter.cc @@ -110,8 +110,8 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { return url_request_context_.get(); } -scoped_refptr<base::MessageLoopProxy> - ShellURLRequestContextGetter::GetIOMessageLoopProxy() const { +scoped_refptr<base::SingleThreadTaskRunner> + ShellURLRequestContextGetter::GetNetworkTaskRunner() const { return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); } diff --git a/content/shell/shell_url_request_context_getter.h b/content/shell/shell_url_request_context_getter.h index b97e876..3775304 100644 --- a/content/shell/shell_url_request_context_getter.h +++ b/content/shell/shell_url_request_context_getter.h @@ -32,8 +32,8 @@ class ShellURLRequestContextGetter : public net::URLRequestContextGetter { // net::URLRequestContextGetter implementation. virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; - virtual scoped_refptr<base::MessageLoopProxy> - GetIOMessageLoopProxy() const OVERRIDE; + virtual scoped_refptr<base::SingleThreadTaskRunner> + GetNetworkTaskRunner() const OVERRIDE; net::HostResolver* host_resolver(); diff --git a/jingle/notifier/listener/push_client.cc b/jingle/notifier/listener/push_client.cc index f96e8f8..f18ed52 100644 --- a/jingle/notifier/listener/push_client.cc +++ b/jingle/notifier/listener/push_client.cc @@ -27,13 +27,13 @@ scoped_ptr<PushClient> CreateXmppPushClient( scoped_ptr<PushClient> PushClient::CreateDefault( const NotifierOptions& notifier_options) { return scoped_ptr<PushClient>(new NonBlockingPushClient( - notifier_options.request_context_getter->GetIOMessageLoopProxy(), + notifier_options.request_context_getter->GetNetworkTaskRunner(), base::Bind(&CreateXmppPushClient, notifier_options))); } scoped_ptr<PushClient> PushClient::CreateDefaultOnIOThread( const NotifierOptions& notifier_options) { - CHECK(notifier_options.request_context_getter->GetIOMessageLoopProxy()-> + CHECK(notifier_options.request_context_getter->GetNetworkTaskRunner()-> BelongsToCurrentThread()); return CreateXmppPushClient(notifier_options); } diff --git a/jingle/notifier/listener/xmpp_push_client.cc b/jingle/notifier/listener/xmpp_push_client.cc index dcf828d8..b1272f3 100644 --- a/jingle/notifier/listener/xmpp_push_client.cc +++ b/jingle/notifier/listener/xmpp_push_client.cc @@ -15,7 +15,7 @@ namespace notifier { XmppPushClient::XmppPushClient(const NotifierOptions& notifier_options) : notifier_options_(notifier_options) { DCHECK(notifier_options_.request_context_getter-> - GetIOMessageLoopProxy()->BelongsToCurrentThread()); + GetNetworkTaskRunner()->BelongsToCurrentThread()); } XmppPushClient::~XmppPushClient() { diff --git a/net/url_request/url_fetcher_core.cc b/net/url_request/url_fetcher_core.cc index 8300d0f..7a33964 100644 --- a/net/url_request/url_fetcher_core.cc +++ b/net/url_request/url_fetcher_core.cc @@ -7,9 +7,10 @@ #include "base/bind.h" #include "base/file_util_proxy.h" #include "base/logging.h" -#include "base/message_loop_proxy.h" +#include "base/single_thread_task_runner.h" #include "base/metrics/histogram.h" #include "base/stl_util.h" +#include "base/thread_task_runner_handle.h" #include "base/tracked_objects.h" #include "net/base/io_buffer.h" #include "net/base/load_flags.h" @@ -55,11 +56,11 @@ void URLFetcherCore::Registry::CancelAll() { URLFetcherCore::FileWriter::FileWriter( URLFetcherCore* core, - scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy) + scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) : core_(core), error_code_(base::PLATFORM_FILE_OK), ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), - file_message_loop_proxy_(file_message_loop_proxy), + file_task_runner_(file_task_runner), file_handle_(base::kInvalidPlatformFileValue) { } @@ -69,10 +70,10 @@ URLFetcherCore::FileWriter::~FileWriter() { void URLFetcherCore::FileWriter::CreateFileAtPath( const FilePath& file_path) { - DCHECK(core_->io_message_loop_proxy_->BelongsToCurrentThread()); - DCHECK(file_message_loop_proxy_.get()); + DCHECK(core_->network_task_runner_->BelongsToCurrentThread()); + DCHECK(file_task_runner_.get()); base::FileUtilProxy::CreateOrOpen( - file_message_loop_proxy_, + file_task_runner_, file_path, base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE, base::Bind(&URLFetcherCore::FileWriter::DidCreateFile, @@ -81,17 +82,17 @@ void URLFetcherCore::FileWriter::CreateFileAtPath( } void URLFetcherCore::FileWriter::CreateTempFile() { - DCHECK(core_->io_message_loop_proxy_->BelongsToCurrentThread()); - DCHECK(file_message_loop_proxy_.get()); + DCHECK(core_->network_task_runner_->BelongsToCurrentThread()); + DCHECK(file_task_runner_.get()); base::FileUtilProxy::CreateTemporary( - file_message_loop_proxy_, + file_task_runner_, 0, // No additional file flags. base::Bind(&URLFetcherCore::FileWriter::DidCreateTempFile, weak_factory_.GetWeakPtr())); } void URLFetcherCore::FileWriter::WriteBuffer(int num_bytes) { - DCHECK(core_->io_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(core_->network_task_runner_->BelongsToCurrentThread()); // Start writing to the file by setting the initial state // of |pending_bytes_| and |buffer_offset_| to indicate that the @@ -104,7 +105,7 @@ void URLFetcherCore::FileWriter::WriteBuffer(int num_bytes) { void URLFetcherCore::FileWriter::ContinueWrite( base::PlatformFileError error_code, int bytes_written) { - DCHECK(core_->io_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(core_->network_task_runner_->BelongsToCurrentThread()); if (file_handle_ == base::kInvalidPlatformFileValue) { // While a write was being done on the file thread, a request @@ -124,7 +125,7 @@ void URLFetcherCore::FileWriter::ContinueWrite( if (base::PLATFORM_FILE_OK != error_code) { error_code_ = error_code; RemoveFile(); - core_->delegate_loop_proxy_->PostTask( + core_->delegate_task_runner_->PostTask( FROM_HERE, base::Bind(&URLFetcherCore::InformDelegateFetchIsComplete, core_)); return; @@ -136,7 +137,7 @@ void URLFetcherCore::FileWriter::ContinueWrite( if (pending_bytes_ > 0) { base::FileUtilProxy::Write( - file_message_loop_proxy_, file_handle_, + file_task_runner_, file_handle_, total_bytes_written_, // Append to the end (core_->buffer_->data() + buffer_offset_), pending_bytes_, base::Bind(&URLFetcherCore::FileWriter::ContinueWrite, @@ -148,7 +149,7 @@ void URLFetcherCore::FileWriter::ContinueWrite( } void URLFetcherCore::FileWriter::DisownFile() { - DCHECK(core_->io_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(core_->network_task_runner_->BelongsToCurrentThread()); // Disowning is done by the delegate's OnURLFetchComplete method. // The file should be closed by the time that method is called. @@ -159,11 +160,11 @@ void URLFetcherCore::FileWriter::DisownFile() { } void URLFetcherCore::FileWriter::CloseFileAndCompleteRequest() { - DCHECK(core_->io_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(core_->network_task_runner_->BelongsToCurrentThread()); if (file_handle_ != base::kInvalidPlatformFileValue) { base::FileUtilProxy::Close( - file_message_loop_proxy_, file_handle_, + file_task_runner_, file_handle_, base::Bind(&URLFetcherCore::FileWriter::DidCloseFile, weak_factory_.GetWeakPtr())); file_handle_ = base::kInvalidPlatformFileValue; @@ -171,19 +172,19 @@ void URLFetcherCore::FileWriter::CloseFileAndCompleteRequest() { } void URLFetcherCore::FileWriter::RemoveFile() { - DCHECK(core_->io_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(core_->network_task_runner_->BelongsToCurrentThread()); // Close the file if it is open. if (file_handle_ != base::kInvalidPlatformFileValue) { base::FileUtilProxy::Close( - file_message_loop_proxy_, file_handle_, + file_task_runner_, file_handle_, base::FileUtilProxy::StatusCallback()); // No callback: Ignore errors. file_handle_ = base::kInvalidPlatformFileValue; } if (!file_path_.empty()) { base::FileUtilProxy::Delete( - file_message_loop_proxy_, file_path_, + file_task_runner_, file_path_, false, // No need to recurse, as the path is to a file. base::FileUtilProxy::StatusCallback()); // No callback: Ignore errors. DisownFile(); @@ -209,12 +210,12 @@ void URLFetcherCore::FileWriter::DidCreateFileInternal( const FilePath& file_path, base::PlatformFileError error_code, base::PassPlatformFile file_handle) { - DCHECK(core_->io_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(core_->network_task_runner_->BelongsToCurrentThread()); if (base::PLATFORM_FILE_OK != error_code) { error_code_ = error_code; RemoveFile(); - core_->delegate_loop_proxy_->PostTask( + core_->delegate_task_runner_->PostTask( FROM_HERE, base::Bind(&URLFetcherCore::InformDelegateFetchIsComplete, core_)); return; @@ -224,19 +225,19 @@ void URLFetcherCore::FileWriter::DidCreateFileInternal( file_handle_ = file_handle.ReleaseValue(); total_bytes_written_ = 0; - core_->io_message_loop_proxy_->PostTask( + core_->network_task_runner_->PostTask( FROM_HERE, base::Bind(&URLFetcherCore::StartURLRequestWhenAppropriate, core_)); } void URLFetcherCore::FileWriter::DidCloseFile( base::PlatformFileError error_code) { - DCHECK(core_->io_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(core_->network_task_runner_->BelongsToCurrentThread()); if (base::PLATFORM_FILE_OK != error_code) { error_code_ = error_code; RemoveFile(); - core_->delegate_loop_proxy_->PostTask( + core_->delegate_task_runner_->PostTask( FROM_HERE, base::Bind(&URLFetcherCore::InformDelegateFetchIsComplete, core_)); return; @@ -261,8 +262,8 @@ URLFetcherCore::URLFetcherCore(URLFetcher* fetcher, original_url_(original_url), request_type_(request_type), delegate_(d), - delegate_loop_proxy_( - base::MessageLoopProxy::current()), + delegate_task_runner_( + base::ThreadTaskRunnerHandle::Get()), request_(NULL), load_flags_(LOAD_NORMAL), response_code_(URLFetcher::RESPONSE_CODE_INVALID), @@ -284,32 +285,32 @@ URLFetcherCore::URLFetcherCore(URLFetcher* fetcher, } void URLFetcherCore::Start() { - DCHECK(delegate_loop_proxy_); + DCHECK(delegate_task_runner_); DCHECK(request_context_getter_) << "We need an URLRequestContext!"; - if (io_message_loop_proxy_) { - DCHECK_EQ(io_message_loop_proxy_, - request_context_getter_->GetIOMessageLoopProxy()); + if (network_task_runner_) { + DCHECK_EQ(network_task_runner_, + request_context_getter_->GetNetworkTaskRunner()); } else { - io_message_loop_proxy_ = request_context_getter_->GetIOMessageLoopProxy(); + network_task_runner_ = request_context_getter_->GetNetworkTaskRunner(); } - DCHECK(io_message_loop_proxy_.get()) << "We need an IO message loop proxy"; + DCHECK(network_task_runner_.get()) << "We need an IO task runner"; - io_message_loop_proxy_->PostTask( + network_task_runner_->PostTask( FROM_HERE, base::Bind(&URLFetcherCore::StartOnIOThread, this)); } void URLFetcherCore::Stop() { - if (delegate_loop_proxy_) // May be NULL in tests. - DCHECK(delegate_loop_proxy_->BelongsToCurrentThread()); + if (delegate_task_runner_) // May be NULL in tests. + DCHECK(delegate_task_runner_->BelongsToCurrentThread()); delegate_ = NULL; fetcher_ = NULL; - if (!io_message_loop_proxy_.get()) + if (!network_task_runner_.get()) return; - if (io_message_loop_proxy_->RunsTasksOnCurrentThread()) { + if (network_task_runner_->RunsTasksOnCurrentThread()) { CancelURLRequest(); } else { - io_message_loop_proxy_->PostTask( + network_task_runner_->PostTask( FROM_HERE, base::Bind(&URLFetcherCore::CancelURLRequest, this)); } } @@ -332,9 +333,9 @@ void URLFetcherCore::SetChunkedUpload(const std::string& content_type) { void URLFetcherCore::AppendChunkToUpload(const std::string& content, bool is_last_chunk) { - DCHECK(delegate_loop_proxy_); - DCHECK(io_message_loop_proxy_.get()); - io_message_loop_proxy_->PostTask( + DCHECK(delegate_task_runner_); + DCHECK(network_task_runner_.get()); + network_task_runner_->PostTask( FROM_HERE, base::Bind(&URLFetcherCore::CompleteAddingUploadDataChunk, this, content, is_last_chunk)); @@ -410,17 +411,17 @@ base::TimeDelta URLFetcherCore::GetBackoffDelay() const { void URLFetcherCore::SaveResponseToFileAtPath( const FilePath& file_path, - scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy) { - DCHECK(delegate_loop_proxy_->BelongsToCurrentThread()); - file_message_loop_proxy_ = file_message_loop_proxy; + scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) { + DCHECK(delegate_task_runner_->BelongsToCurrentThread()); + file_task_runner_ = file_task_runner; response_destination_ = URLFetcherCore::PERMANENT_FILE; response_destination_file_path_ = file_path; } void URLFetcherCore::SaveResponseToTemporaryFile( - scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy) { - DCHECK(delegate_loop_proxy_->BelongsToCurrentThread()); - file_message_loop_proxy_ = file_message_loop_proxy; + scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) { + DCHECK(delegate_task_runner_->BelongsToCurrentThread()); + file_task_runner_ = file_task_runner; response_destination_ = URLFetcherCore::TEMP_FILE; } @@ -475,9 +476,9 @@ bool URLFetcherCore::FileErrorOccurred( } void URLFetcherCore::ReceivedContentWasMalformed() { - DCHECK(delegate_loop_proxy_->BelongsToCurrentThread()); - if (io_message_loop_proxy_.get()) { - io_message_loop_proxy_->PostTask( + DCHECK(delegate_task_runner_->BelongsToCurrentThread()); + if (network_task_runner_.get()) { + network_task_runner_->PostTask( FROM_HERE, base::Bind(&URLFetcherCore::NotifyMalformedContent, this)); } } @@ -496,7 +497,7 @@ bool URLFetcherCore::GetResponseAsString( bool URLFetcherCore::GetResponseAsFilePath(bool take_ownership, FilePath* out_response_path) { - DCHECK(delegate_loop_proxy_->BelongsToCurrentThread()); + DCHECK(delegate_task_runner_->BelongsToCurrentThread()); const bool destination_is_file = response_destination_ == URLFetcherCore::TEMP_FILE || response_destination_ == URLFetcherCore::PERMANENT_FILE; @@ -506,7 +507,7 @@ bool URLFetcherCore::GetResponseAsFilePath(bool take_ownership, *out_response_path = file_writer_->file_path(); if (take_ownership) { - io_message_loop_proxy_->PostTask( + network_task_runner_->PostTask( FROM_HERE, base::Bind(&URLFetcherCore::DisownFile, this)); } @@ -517,7 +518,7 @@ void URLFetcherCore::OnReceivedRedirect(URLRequest* request, const GURL& new_url, bool* defer_redirect) { DCHECK_EQ(request, request_.get()); - DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(network_task_runner_->BelongsToCurrentThread()); if (stop_on_redirect_) { stopped_on_redirect_ = true; url_ = new_url; @@ -530,7 +531,7 @@ void URLFetcherCore::OnReceivedRedirect(URLRequest* request, void URLFetcherCore::OnResponseStarted(URLRequest* request) { DCHECK_EQ(request, request_.get()); - DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(network_task_runner_->BelongsToCurrentThread()); if (request_->status().is_success()) { response_code_ = request_->GetResponseCode(); response_headers_ = request_->response_headers(); @@ -545,7 +546,7 @@ void URLFetcherCore::OnResponseStarted(URLRequest* request) { void URLFetcherCore::OnReadCompleted(URLRequest* request, int bytes_read) { DCHECK(request == request_); - DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(network_task_runner_->BelongsToCurrentThread()); if (!stopped_on_redirect_) url_ = request->url(); @@ -614,7 +615,7 @@ URLFetcherCore::~URLFetcherCore() { } void URLFetcherCore::StartOnIOThread() { - DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(network_task_runner_->BelongsToCurrentThread()); switch (response_destination_) { case STRING: @@ -623,10 +624,10 @@ void URLFetcherCore::StartOnIOThread() { case PERMANENT_FILE: case TEMP_FILE: - DCHECK(file_message_loop_proxy_.get()) - << "Need to set the file message loop proxy."; + DCHECK(file_task_runner_.get()) + << "Need to set the file task runner."; - file_writer_.reset(new FileWriter(this, file_message_loop_proxy_)); + file_writer_.reset(new FileWriter(this, file_task_runner_)); // If the file is successfully created, // URLFetcherCore::StartURLRequestWhenAppropriate() will be called. @@ -648,7 +649,7 @@ void URLFetcherCore::StartOnIOThread() { } void URLFetcherCore::StartURLRequest() { - DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(network_task_runner_->BelongsToCurrentThread()); if (was_cancelled_) { // Since StartURLRequest() is posted as a *delayed* task, it may @@ -735,7 +736,7 @@ void URLFetcherCore::StartURLRequest() { } void URLFetcherCore::StartURLRequestWhenAppropriate() { - DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(network_task_runner_->BelongsToCurrentThread()); if (was_cancelled_) return; @@ -759,14 +760,14 @@ void URLFetcherCore::StartURLRequestWhenAppropriate() { if (delay == 0) { StartURLRequest(); } else { - MessageLoop::current()->PostDelayedTask( + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( FROM_HERE, base::Bind(&URLFetcherCore::StartURLRequest, this), base::TimeDelta::FromMilliseconds(delay)); } } void URLFetcherCore::CancelURLRequest() { - DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(network_task_runner_->BelongsToCurrentThread()); if (request_.get()) { request_->Cancel(); @@ -786,7 +787,7 @@ void URLFetcherCore::CancelURLRequest() { void URLFetcherCore::OnCompletedURLRequest( base::TimeDelta backoff_delay) { - DCHECK(delegate_loop_proxy_->BelongsToCurrentThread()); + DCHECK(delegate_task_runner_->BelongsToCurrentThread()); // Save the status and backoff_delay so that delegates can read it. if (delegate_) { @@ -796,13 +797,13 @@ void URLFetcherCore::OnCompletedURLRequest( } void URLFetcherCore::InformDelegateFetchIsComplete() { - DCHECK(delegate_loop_proxy_->BelongsToCurrentThread()); + DCHECK(delegate_task_runner_->BelongsToCurrentThread()); if (delegate_) delegate_->OnURLFetchComplete(fetcher_); } void URLFetcherCore::NotifyMalformedContent() { - DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(network_task_runner_->BelongsToCurrentThread()); if (url_throttler_entry_ != NULL) { int status_code = response_code_; if (status_code == URLFetcher::RESPONSE_CODE_INVALID) { @@ -818,7 +819,7 @@ void URLFetcherCore::NotifyMalformedContent() { } void URLFetcherCore::RetryOrCompleteUrlFetch() { - DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(network_task_runner_->BelongsToCurrentThread()); base::TimeDelta backoff_delay; // Checks the response from server. @@ -849,7 +850,7 @@ void URLFetcherCore::RetryOrCompleteUrlFetch() { first_party_for_cookies_ = GURL(); url_request_data_key_ = NULL; url_request_create_data_callback_.Reset(); - bool posted = delegate_loop_proxy_->PostTask( + bool posted = delegate_task_runner_->PostTask( FROM_HERE, base::Bind(&URLFetcherCore::OnCompletedURLRequest, this, backoff_delay)); @@ -865,7 +866,7 @@ void URLFetcherCore::ReleaseRequest() { } base::TimeTicks URLFetcherCore::GetBackoffReleaseTime() { - DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(network_task_runner_->BelongsToCurrentThread()); if (original_url_throttler_entry_) { base::TimeTicks original_url_backoff = @@ -941,7 +942,7 @@ void URLFetcherCore::DisownFile() { } void URLFetcherCore::InformDelegateUploadProgress() { - DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(network_task_runner_->BelongsToCurrentThread()); if (request_.get()) { int64 current = request_->GetUploadProgress(); if (current_upload_bytes_ != current) { @@ -949,7 +950,7 @@ void URLFetcherCore::InformDelegateUploadProgress() { int64 total = -1; if (!is_chunked_upload_) total = static_cast<int64>(upload_content_.size()); - delegate_loop_proxy_->PostTask( + delegate_task_runner_->PostTask( FROM_HERE, base::Bind( &URLFetcherCore::InformDelegateUploadProgressInDelegateThread, @@ -960,14 +961,14 @@ void URLFetcherCore::InformDelegateUploadProgress() { void URLFetcherCore::InformDelegateUploadProgressInDelegateThread( int64 current, int64 total) { - DCHECK(delegate_loop_proxy_->BelongsToCurrentThread()); + DCHECK(delegate_task_runner_->BelongsToCurrentThread()); if (delegate_) delegate_->OnURLFetchUploadProgress(fetcher_, current, total); } void URLFetcherCore::InformDelegateDownloadProgress() { - DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); - delegate_loop_proxy_->PostTask( + DCHECK(network_task_runner_->BelongsToCurrentThread()); + delegate_task_runner_->PostTask( FROM_HERE, base::Bind( &URLFetcherCore::InformDelegateDownloadProgressInDelegateThread, @@ -976,17 +977,17 @@ void URLFetcherCore::InformDelegateDownloadProgress() { void URLFetcherCore::InformDelegateDownloadProgressInDelegateThread( int64 current, int64 total) { - DCHECK(delegate_loop_proxy_->BelongsToCurrentThread()); + DCHECK(delegate_task_runner_->BelongsToCurrentThread()); if (delegate_) delegate_->OnURLFetchDownloadProgress(fetcher_, current, total); } void URLFetcherCore::InformDelegateDownloadDataIfNecessary(int bytes_read) { - DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); + DCHECK(network_task_runner_->BelongsToCurrentThread()); if (delegate_ && delegate_->ShouldSendDownloadData()) { scoped_ptr<std::string> download_data( new std::string(buffer_->data(), bytes_read)); - delegate_loop_proxy_->PostTask( + delegate_task_runner_->PostTask( FROM_HERE, base::Bind( &URLFetcherCore::InformDelegateDownloadDataInDelegateThread, @@ -996,7 +997,7 @@ void URLFetcherCore::InformDelegateDownloadDataIfNecessary(int bytes_read) { void URLFetcherCore::InformDelegateDownloadDataInDelegateThread( scoped_ptr<std::string> download_data) { - DCHECK(delegate_loop_proxy_->BelongsToCurrentThread()); + DCHECK(delegate_task_runner_->BelongsToCurrentThread()); if (delegate_) delegate_->OnURLFetchDownloadData(fetcher_, download_data.Pass()); } diff --git a/net/url_request/url_fetcher_core.h b/net/url_request/url_fetcher_core.h index f431d90..ee4113d 100644 --- a/net/url_request/url_fetcher_core.h +++ b/net/url_request/url_fetcher_core.h @@ -27,7 +27,7 @@ #include "net/url_request/url_request_status.h" namespace base { -class MessageLoopProxy; +class SingleThreadTaskRunner; } // namespace base namespace net { @@ -92,9 +92,9 @@ class URLFetcherCore base::TimeDelta GetBackoffDelay() const; void SaveResponseToFileAtPath( const FilePath& file_path, - scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy); + scoped_refptr<base::SingleThreadTaskRunner> file_task_runner); void SaveResponseToTemporaryFile( - scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy); + scoped_refptr<base::SingleThreadTaskRunner> file_task_runner); HttpResponseHeaders* GetResponseHeaders() const; HostPortPair GetSocketAddress() const; bool WasFetchedViaProxy() const; @@ -168,7 +168,7 @@ class URLFetcherCore class FileWriter { public: FileWriter(URLFetcherCore* core, - scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy); + scoped_refptr<base::SingleThreadTaskRunner> file_task_runner); ~FileWriter(); void CreateFileAtPath(const FilePath& file_path); @@ -223,8 +223,8 @@ class URLFetcherCore // Callbacks are created for use with base::FileUtilProxy. base::WeakPtrFactory<URLFetcherCore::FileWriter> weak_factory_; - // Message loop on which file operations should happen. - scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy_; + // Task runner for the thread on which file operations should happen. + scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; // Path to the file. This path is empty when there is no file. FilePath file_path_; @@ -299,14 +299,13 @@ class URLFetcherCore URLFetcher::RequestType request_type_; // What type of request is this? URLRequestStatus status_; // Status of the request URLFetcherDelegate* delegate_; // Object to notify on completion - scoped_refptr<base::MessageLoopProxy> delegate_loop_proxy_; - // Message loop proxy of the creating - // thread. - scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; - // The message loop proxy for the thread + scoped_refptr<base::SingleThreadTaskRunner> delegate_task_runner_; + // Task runner for the creating thread. + scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; + // Task runner for the thread // on which the request IO happens. - scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy_; - // The message loop proxy for the thread + scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; + // Task runner for the thread // on which file access happens. scoped_ptr<URLRequest> request_; // The actual request this wraps int load_flags_; // Flags for the load operation diff --git a/net/url_request/url_request_context_getter.cc b/net/url_request/url_request_context_getter.cc index 844807f..db73fe3 100644 --- a/net/url_request/url_request_context_getter.cc +++ b/net/url_request/url_request_context_getter.cc @@ -5,7 +5,7 @@ #include "net/url_request/url_request_context_getter.h" #include "base/location.h" -#include "base/message_loop_proxy.h" +#include "base/single_thread_task_runner.h" #include "net/url_request/url_request_context.h" namespace net { @@ -15,14 +15,15 @@ URLRequestContextGetter::URLRequestContextGetter() {} URLRequestContextGetter::~URLRequestContextGetter() {} void URLRequestContextGetter::OnDestruct() const { - scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy = - GetIOMessageLoopProxy(); - DCHECK(io_message_loop_proxy); - if (io_message_loop_proxy) { - if (io_message_loop_proxy->BelongsToCurrentThread()) + scoped_refptr<base::SingleThreadTaskRunner> network_task_runner = + GetNetworkTaskRunner(); + DCHECK(network_task_runner); + if (network_task_runner) { + if (network_task_runner->BelongsToCurrentThread()) { delete this; - else - io_message_loop_proxy->DeleteSoon(FROM_HERE, this); + } else { + network_task_runner->DeleteSoon(FROM_HERE, this); + } } // If no IO message loop proxy was available, we will just leak memory. // This is also true if the IO thread is gone. diff --git a/net/url_request/url_request_context_getter.h b/net/url_request/url_request_context_getter.h index c654f16..239a62e 100644 --- a/net/url_request/url_request_context_getter.h +++ b/net/url_request/url_request_context_getter.h @@ -11,8 +11,8 @@ #include "net/base/net_export.h" namespace base { -class MessageLoopProxy; -} +class SingleThreadTaskRunner; +} // namespace base namespace net { class CookieStore; @@ -27,11 +27,11 @@ class NET_EXPORT URLRequestContextGetter public: virtual URLRequestContext* GetURLRequestContext() = 0; - // Returns a MessageLoopProxy corresponding to the thread on which the - // request IO happens (the thread on which the returned net::URLRequestContext - // may be used). - virtual scoped_refptr<base::MessageLoopProxy> - GetIOMessageLoopProxy() const = 0; + // Returns a SingleThreadTaskRunner corresponding to the thread on + // which the network IO happens (the thread on which the returned + // net::URLRequestContext may be used). + virtual scoped_refptr<base::SingleThreadTaskRunner> + GetNetworkTaskRunner() const = 0; protected: friend class base::RefCountedThreadSafe<URLRequestContextGetter, diff --git a/net/url_request/url_request_test_util.cc b/net/url_request/url_request_test_util.cc index de814ef..0d1081b 100644 --- a/net/url_request/url_request_test_util.cc +++ b/net/url_request/url_request_test_util.cc @@ -123,16 +123,16 @@ TestURLRequest::~TestURLRequest() { } TestURLRequestContextGetter::TestURLRequestContextGetter( - const scoped_refptr<base::MessageLoopProxy>& io_message_loop_proxy) - : io_message_loop_proxy_(io_message_loop_proxy) { - DCHECK(io_message_loop_proxy.get()); + const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner) + : network_task_runner_(network_task_runner) { + DCHECK(network_task_runner_); } TestURLRequestContextGetter::TestURLRequestContextGetter( - const scoped_refptr<base::MessageLoopProxy>& io_message_loop_proxy, + const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner, scoped_ptr<TestURLRequestContext> context) - : io_message_loop_proxy_(io_message_loop_proxy), context_(context.Pass()) { - DCHECK(io_message_loop_proxy.get()); + : network_task_runner_(network_task_runner), context_(context.Pass()) { + DCHECK(network_task_runner_); } TestURLRequestContextGetter::~TestURLRequestContextGetter() {} @@ -143,9 +143,9 @@ TestURLRequestContext* TestURLRequestContextGetter::GetURLRequestContext() { return context_.get(); } -scoped_refptr<base::MessageLoopProxy> -TestURLRequestContextGetter::GetIOMessageLoopProxy() const { - return io_message_loop_proxy_; +scoped_refptr<base::SingleThreadTaskRunner> +TestURLRequestContextGetter::GetNetworkTaskRunner() const { + return network_task_runner_; } TestDelegate::TestDelegate() diff --git a/net/url_request/url_request_test_util.h b/net/url_request/url_request_test_util.h index 2035fdf..d76a4af 100644 --- a/net/url_request/url_request_test_util.h +++ b/net/url_request/url_request_test_util.h @@ -68,25 +68,25 @@ class TestURLRequestContext : public net::URLRequestContext { // given in the constructor. class TestURLRequestContextGetter : public net::URLRequestContextGetter { public: - // |io_message_loop_proxy| must not be NULL. + // |network_task_runner| must not be NULL. explicit TestURLRequestContextGetter( - const scoped_refptr<base::MessageLoopProxy>& io_message_loop_proxy); + const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner); // Use to pass a pre-initialized |context|. TestURLRequestContextGetter( - const scoped_refptr<base::MessageLoopProxy>& io_message_loop_proxy, + const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner, scoped_ptr<TestURLRequestContext> context); // net::URLRequestContextGetter implementation. virtual TestURLRequestContext* GetURLRequestContext() OVERRIDE; - virtual scoped_refptr<base::MessageLoopProxy> - GetIOMessageLoopProxy() const OVERRIDE; + virtual scoped_refptr<base::SingleThreadTaskRunner> + GetNetworkTaskRunner() const OVERRIDE; protected: virtual ~TestURLRequestContextGetter(); private: - const scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; + const scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; scoped_ptr<TestURLRequestContext> context_; }; diff --git a/remoting/host/url_fetcher.cc b/remoting/host/url_fetcher.cc index 606d1f9..91b23b3 100644 --- a/remoting/host/url_fetcher.cc +++ b/remoting/host/url_fetcher.cc @@ -51,7 +51,7 @@ class UrlFetcher::Core : public base::RefCountedThreadSafe<Core>, Method method_; scoped_refptr<base::MessageLoopProxy> delegate_message_loop_; - scoped_refptr<base::MessageLoopProxy> io_message_loop_; + scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; scoped_refptr<net::URLRequestContextGetter> request_context_getter_; @@ -100,29 +100,29 @@ void UrlFetcher::Core::SetHeader(const std::string& key, void UrlFetcher::Core::Start(const UrlFetcher::DoneCallback& done_callback) { done_callback_ = done_callback; - io_message_loop_ = request_context_getter_->GetIOMessageLoopProxy(); - DCHECK(io_message_loop_); - io_message_loop_->PostTask(FROM_HERE, base::Bind( + network_task_runner_ = request_context_getter_->GetNetworkTaskRunner(); + DCHECK(network_task_runner_); + network_task_runner_->PostTask(FROM_HERE, base::Bind( &UrlFetcher::Core::DoStart, this)); } void UrlFetcher::Core::Detach() { DCHECK(delegate_message_loop_->BelongsToCurrentThread()); - io_message_loop_->PostTask( + network_task_runner_->PostTask( FROM_HERE, base::Bind(&UrlFetcher::Core::CancelRequest, this)); done_callback_.Reset(); } void UrlFetcher::Core::OnResponseStarted(net::URLRequest* request) { DCHECK_EQ(request, request_.get()); - DCHECK(io_message_loop_->BelongsToCurrentThread()); + DCHECK(network_task_runner_->BelongsToCurrentThread()); ReadResponse(); } void UrlFetcher::Core::OnReadCompleted(net::URLRequest* request, int bytes_read) { DCHECK_EQ(request, request_.get()); - DCHECK(io_message_loop_->BelongsToCurrentThread()); + DCHECK(network_task_runner_->BelongsToCurrentThread()); do { if (!request_->status().is_success() || bytes_read <= 0) @@ -141,7 +141,7 @@ void UrlFetcher::Core::OnReadCompleted(net::URLRequest* request, } void UrlFetcher::Core::DoStart() { - DCHECK(io_message_loop_->BelongsToCurrentThread()); + DCHECK(network_task_runner_->BelongsToCurrentThread()); request_.reset(new net::URLRequest(url_, this)); request_->set_context(request_context_getter_->GetURLRequestContext()); diff --git a/remoting/host/url_request_context.cc b/remoting/host/url_request_context.cc index f254258..3781b39 100644 --- a/remoting/host/url_request_context.cc +++ b/remoting/host/url_request_context.cc @@ -116,9 +116,9 @@ URLRequestContextGetter::URLRequestContextGetter( base::MessageLoopProxy* ui_message_loop, MessageLoop* io_message_loop, MessageLoopForIO* file_message_loop) - : io_message_loop_proxy_(io_message_loop->message_loop_proxy()) { + : network_task_runner_(io_message_loop->message_loop_proxy()) { proxy_config_service_.reset(CreateSystemProxyConfigService( - ui_message_loop, io_message_loop_proxy_, file_message_loop)); + ui_message_loop, network_task_runner_, file_message_loop)); } net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() { @@ -129,9 +129,9 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() { return url_request_context_.get(); } -scoped_refptr<base::MessageLoopProxy> -URLRequestContextGetter::GetIOMessageLoopProxy() const { - return io_message_loop_proxy_; +scoped_refptr<base::SingleThreadTaskRunner> +URLRequestContextGetter::GetNetworkTaskRunner() const { + return network_task_runner_; } URLRequestContextGetter::~URLRequestContextGetter() {} diff --git a/remoting/host/url_request_context.h b/remoting/host/url_request_context.h index d1f2cd3..71766b7 100644 --- a/remoting/host/url_request_context.h +++ b/remoting/host/url_request_context.h @@ -45,14 +45,14 @@ class URLRequestContextGetter : public net::URLRequestContextGetter { // Overridden from net::URLRequestContextGetter: virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE; - virtual scoped_refptr<base::MessageLoopProxy> - GetIOMessageLoopProxy() const OVERRIDE; + virtual scoped_refptr<base::SingleThreadTaskRunner> + GetNetworkTaskRunner() const OVERRIDE; protected: virtual ~URLRequestContextGetter(); private: - scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; + scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; scoped_ptr<net::ProxyConfigService> proxy_config_service_; scoped_ptr<net::URLRequestContext> url_request_context_; 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); }; |