Commit 64b2534a authored by zea's avatar zea Committed by Commit bot

Revert of ios: Remove use of MessageLoopProxy and deprecated MessageLoop APIs...

Revert of ios: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (patchset #3 id:40001 of https://codereview.chromium.org/1160403005/)

Reason for revert:
Broke IOS_Device compile.
https://build.chromium.org/p/chromium.mac/builders/iOS_Device/builds/8802

Original issue's description:
> ios: Remove use of MessageLoopProxy and deprecated MessageLoop APIs
>
> BUG=465354
>
> Committed: https://crrev.com/9c8e5d7259661cda32b698ee88254491e6984900
> Cr-Commit-Position: refs/heads/master@{#333080}

TBR=stuartmorgan@chromium.org,skyostil@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=465354

Review URL: https://codereview.chromium.org/1167533009

Cr-Commit-Position: refs/heads/master@{#333083}
parent 44547d35
...@@ -60,7 +60,7 @@ class RetryableURLFetcherTest : public PlatformTest { ...@@ -60,7 +60,7 @@ class RetryableURLFetcherTest : public PlatformTest {
TEST_F(RetryableURLFetcherTest, TestResponse200) { TEST_F(RetryableURLFetcherTest, TestResponse200) {
scoped_refptr<net::URLRequestContextGetter> request_context_getter = scoped_refptr<net::URLRequestContextGetter> request_context_getter =
new net::TestURLRequestContextGetter(message_loop_.task_runner()); new net::TestURLRequestContextGetter(message_loop_.message_loop_proxy());
base::scoped_nsobject<RetryableURLFetcher> retryableFetcher( base::scoped_nsobject<RetryableURLFetcher> retryableFetcher(
[[RetryableURLFetcher alloc] [[RetryableURLFetcher alloc]
initWithRequestContextGetter:request_context_getter.get() initWithRequestContextGetter:request_context_getter.get()
...@@ -81,7 +81,7 @@ TEST_F(RetryableURLFetcherTest, TestResponse200) { ...@@ -81,7 +81,7 @@ TEST_F(RetryableURLFetcherTest, TestResponse200) {
TEST_F(RetryableURLFetcherTest, TestResponse404) { TEST_F(RetryableURLFetcherTest, TestResponse404) {
scoped_refptr<net::URLRequestContextGetter> request_context_getter = scoped_refptr<net::URLRequestContextGetter> request_context_getter =
new net::TestURLRequestContextGetter(message_loop_.task_runner()); new net::TestURLRequestContextGetter(message_loop_.message_loop_proxy());
base::scoped_nsobject<RetryableURLFetcher> retryableFetcher( base::scoped_nsobject<RetryableURLFetcher> retryableFetcher(
[[RetryableURLFetcher alloc] [[RetryableURLFetcher alloc]
initWithRequestContextGetter:request_context_getter.get() initWithRequestContextGetter:request_context_getter.get()
......
...@@ -212,8 +212,8 @@ void ConvertAndSaveGreyImage( ...@@ -212,8 +212,8 @@ void ConvertAndSaveGreyImage(
} }
base::PostTaskAndReplyWithResult( base::PostTaskAndReplyWithResult(
web::WebThread::GetTaskRunnerForThread(web::WebThread::FILE_USER_BLOCKING) web::WebThread::GetMessageLoopProxyForThread(
.get(), web::WebThread::FILE_USER_BLOCKING).get(),
FROM_HERE, base::BindBlock(^base::scoped_nsobject<UIImage>() { FROM_HERE, base::BindBlock(^base::scoped_nsobject<UIImage>() {
// Retrieve the image on a high priority thread. // Retrieve the image on a high priority thread.
return base::scoped_nsobject<UIImage>([ReadImageFromDisk( return base::scoped_nsobject<UIImage>([ReadImageFromDisk(
...@@ -401,9 +401,10 @@ void ConvertAndSaveGreyImage( ...@@ -401,9 +401,10 @@ void ConvertAndSaveGreyImage(
// already in the cache, use it. // already in the cache, use it.
UIImage* img = [imageDictionary_ objectForKey:sessionID]; UIImage* img = [imageDictionary_ objectForKey:sessionID];
base::PostTaskAndReplyWithResult( base::PostTaskAndReplyWithResult(
web::WebThread::GetTaskRunnerForThread(web::WebThread::FILE_USER_BLOCKING) web::WebThread::GetMessageLoopProxyForThread(
.get(), web::WebThread::FILE_USER_BLOCKING).get(),
FROM_HERE, base::BindBlock(^base::scoped_nsobject<UIImage>() { FROM_HERE,
base::BindBlock(^base::scoped_nsobject<UIImage>() {
base::scoped_nsobject<UIImage> result([img retain]); base::scoped_nsobject<UIImage> result([img retain]);
// If the image is not in the cache, load it from disk. // If the image is not in the cache, load it from disk.
if (!result) if (!result)
...@@ -464,9 +465,10 @@ void ConvertAndSaveGreyImage( ...@@ -464,9 +465,10 @@ void ConvertAndSaveGreyImage(
} }
base::PostTaskAndReplyWithResult( base::PostTaskAndReplyWithResult(
web::WebThread::GetTaskRunnerForThread(web::WebThread::FILE_USER_BLOCKING) web::WebThread::GetMessageLoopProxyForThread(
.get(), web::WebThread::FILE_USER_BLOCKING).get(),
FROM_HERE, base::BindBlock(^base::scoped_nsobject<UIImage>() { FROM_HERE,
base::BindBlock(^base::scoped_nsobject<UIImage>() {
// Retrieve the image on a high priority thread. // Retrieve the image on a high priority thread.
// Loading the file into NSData is more reliable. // Loading the file into NSData is more reliable.
// -imageWithContentsOfFile would ocassionally claim the image was not a // -imageWithContentsOfFile would ocassionally claim the image was not a
......
...@@ -55,21 +55,21 @@ class CrNetURLRequestContextGetter : public net::URLRequestContextGetter { ...@@ -55,21 +55,21 @@ class CrNetURLRequestContextGetter : public net::URLRequestContextGetter {
public: public:
CrNetURLRequestContextGetter( CrNetURLRequestContextGetter(
net::URLRequestContext* context, net::URLRequestContext* context,
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) const scoped_refptr<base::MessageLoopProxy>& loop)
: context_(context), task_runner_(task_runner) {} : context_(context), loop_(loop) {}
net::URLRequestContext* GetURLRequestContext() override { return context_; } net::URLRequestContext* GetURLRequestContext() override { return context_; }
scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner()
const override { const override {
return task_runner_; return loop_;
} }
private: private:
// Must be called on the IO thread. // Must be called on the IO thread.
~CrNetURLRequestContextGetter() override {} ~CrNetURLRequestContextGetter() override {}
net::URLRequestContext* context_; net::URLRequestContext* context_;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_; scoped_refptr<base::MessageLoopProxy> loop_;
DISALLOW_COPY_AND_ASSIGN(CrNetURLRequestContextGetter); DISALLOW_COPY_AND_ASSIGN(CrNetURLRequestContextGetter);
}; };
...@@ -260,7 +260,7 @@ void CrNetEnvironment::Install() { ...@@ -260,7 +260,7 @@ void CrNetEnvironment::Install() {
// delegates will receive callbacks. // delegates will receive callbacks.
network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); network_change_notifier_.reset(net::NetworkChangeNotifier::Create());
proxy_config_service_.reset(net::ProxyService::CreateSystemProxyConfigService( proxy_config_service_.reset(net::ProxyService::CreateSystemProxyConfigService(
network_io_thread_->task_runner(), nullptr)); network_io_thread_->message_loop_proxy(), nullptr));
PostToNetworkThread(FROM_HERE, PostToNetworkThread(FROM_HERE,
base::Bind(&CrNetEnvironment::InitializeOnNetworkThread, base::Bind(&CrNetEnvironment::InitializeOnNetworkThread,
...@@ -268,7 +268,7 @@ void CrNetEnvironment::Install() { ...@@ -268,7 +268,7 @@ void CrNetEnvironment::Install() {
net::SetURLRequestContextForNSSHttpIO(main_context_.get()); net::SetURLRequestContextForNSSHttpIO(main_context_.get());
main_context_getter_ = new CrNetURLRequestContextGetter( main_context_getter_ = new CrNetURLRequestContextGetter(
main_context_.get(), network_io_thread_->task_runner()); main_context_.get(), network_io_thread_->message_loop_proxy());
SetRequestFilterBlock(nil); SetRequestFilterBlock(nil);
net_log_started_ = false; net_log_started_ = false;
} }
...@@ -310,7 +310,7 @@ void CrNetEnvironment::InitializeOnNetworkThread() { ...@@ -310,7 +310,7 @@ void CrNetEnvironment::InitializeOnNetworkThread() {
net::RequestTracker::AddGlobalNetworkClientFactory( net::RequestTracker::AddGlobalNetworkClientFactory(
[[[WebPNetworkClientFactory alloc] [[[WebPNetworkClientFactory alloc]
initWithTaskRunner:file_user_blocking_thread_ initWithTaskRunner:file_user_blocking_thread_
->task_runner()] autorelease]); ->message_loop_proxy()] autorelease]);
#if 0 #if 0
// TODO(huey): Re-enable this once SDCH supports SSL and dictionaries from // TODO(huey): Re-enable this once SDCH supports SSL and dictionaries from
...@@ -373,10 +373,12 @@ void CrNetEnvironment::InitializeOnNetworkThread() { ...@@ -373,10 +373,12 @@ void CrNetEnvironment::InitializeOnNetworkThread() {
base::mac::NSStringToFilePath([dirs objectAtIndex:0]); base::mac::NSStringToFilePath([dirs objectAtIndex:0]);
cache_path = cache_path.Append(FILE_PATH_LITERAL("crnet")); cache_path = cache_path.Append(FILE_PATH_LITERAL("crnet"));
net::HttpCache::DefaultBackend* main_backend = net::HttpCache::DefaultBackend* main_backend =
new net::HttpCache::DefaultBackend(net::DISK_CACHE, new net::HttpCache::DefaultBackend(
net::CACHE_BACKEND_DEFAULT, cache_path, net::DISK_CACHE,
0, // Default cache size. net::CACHE_BACKEND_DEFAULT,
network_cache_thread_->task_runner()); cache_path,
0, // Default cache size.
network_cache_thread_->message_loop_proxy());
net::HttpNetworkSession::Params params; net::HttpNetworkSession::Params params;
params.host_resolver = main_context_->host_resolver(); params.host_resolver = main_context_->host_resolver();
...@@ -419,7 +421,7 @@ void CrNetEnvironment::InitializeOnNetworkThread() { ...@@ -419,7 +421,7 @@ void CrNetEnvironment::InitializeOnNetworkThread() {
new net::URLRequestJobFactoryImpl; new net::URLRequestJobFactoryImpl;
job_factory->SetProtocolHandler("data", new net::DataProtocolHandler); job_factory->SetProtocolHandler("data", new net::DataProtocolHandler);
job_factory->SetProtocolHandler( job_factory->SetProtocolHandler(
"file", new net::FileProtocolHandler(file_thread_->task_runner())); "file", new net::FileProtocolHandler(file_thread_->message_loop_proxy()));
main_context_->set_job_factory(job_factory); main_context_->set_job_factory(job_factory);
} }
......
...@@ -15,13 +15,13 @@ ...@@ -15,13 +15,13 @@
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#include "base/mac/scoped_nsobject.h" #include "base/mac/scoped_nsobject.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
#include "base/observer_list.h" #include "base/observer_list.h"
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "base/task_runner_util.h" #include "base/task_runner_util.h"
#include "base/thread_task_runner_handle.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "ios/net/cookies/cookie_creation_time_manager.h" #include "ios/net/cookies/cookie_creation_time_manager.h"
#include "ios/net/cookies/cookie_store_ios_client.h" #include "ios/net/cookies/cookie_store_ios_client.h"
...@@ -798,7 +798,7 @@ void CookieStoreIOS::OnSystemCookiesChanged() { ...@@ -798,7 +798,7 @@ void CookieStoreIOS::OnSystemCookiesChanged() {
flush_closure_.Reset(base::Bind(&CookieStoreIOS::Flush, flush_closure_.Reset(base::Bind(&CookieStoreIOS::Flush,
base::Unretained(this), base::Closure())); base::Unretained(this), base::Closure()));
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( base::MessageLoopProxy::current()->PostDelayedTask(
FROM_HERE, flush_closure_.callback(), flush_delay_); FROM_HERE, flush_closure_.callback(), flush_delay_);
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/task_runner_util.h" #include "base/task_runner_util.h"
namespace base { namespace base {
...@@ -83,8 +84,8 @@ class WebThread { ...@@ -83,8 +84,8 @@ class WebThread {
// NOTE: do not add new threads here that are only used by a small number of // NOTE: do not add new threads here that are only used by a small number of
// files. Instead you should just use a Thread class and pass its // files. Instead you should just use a Thread class and pass its
// SingleThreadTaskRunner around. Named threads there are only for threads // MessageLoopProxy around. Named threads there are only for threads that
// that are used in many places. // are used in many places.
// This identifier does not represent a thread. Instead it counts the // This identifier does not represent a thread. Instead it counts the
// number of well-known threads. Insert new well-known threads before this // number of well-known threads. Insert new well-known threads before this
...@@ -123,17 +124,18 @@ class WebThread { ...@@ -123,17 +124,18 @@ class WebThread {
const tracked_objects::Location& from_here, const tracked_objects::Location& from_here,
const base::Callback<ReturnType(void)>& task, const base::Callback<ReturnType(void)>& task,
const base::Callback<void(ReplyArgType)>& reply) { const base::Callback<void(ReplyArgType)>& reply) {
scoped_refptr<base::SingleThreadTaskRunner> task_runner = scoped_refptr<base::MessageLoopProxy> message_loop_proxy =
GetTaskRunnerForThread(identifier); GetMessageLoopProxyForThread(identifier);
return base::PostTaskAndReplyWithResult(task_runner.get(), from_here, task, return base::PostTaskAndReplyWithResult(message_loop_proxy.get(), from_here,
reply); task, reply);
} }
template <class T> template <class T>
static bool DeleteSoon(ID identifier, static bool DeleteSoon(ID identifier,
const tracked_objects::Location& from_here, const tracked_objects::Location& from_here,
const T* object) { const T* object) {
return GetTaskRunnerForThread(identifier)->DeleteSoon(from_here, object); return GetMessageLoopProxyForThread(identifier)
->DeleteSoon(from_here, object);
} }
// Simplified wrappers for posting to the blocking thread pool. Use this // Simplified wrappers for posting to the blocking thread pool. Use this
...@@ -200,9 +202,9 @@ class WebThread { ...@@ -200,9 +202,9 @@ class WebThread {
// sets identifier to its ID. // sets identifier to its ID.
static bool GetCurrentThreadIdentifier(ID* identifier) WARN_UNUSED_RESULT; static bool GetCurrentThreadIdentifier(ID* identifier) WARN_UNUSED_RESULT;
// Callers can hold on to a refcounted SingleThreadTaskRunner beyond the // Callers can hold on to a refcounted MessageLoopProxy beyond the lifetime
// lifetime of the thread. // of the thread.
static scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunnerForThread( static scoped_refptr<base::MessageLoopProxy> GetMessageLoopProxyForThread(
ID identifier); ID identifier);
// Returns an appropriate error message for when // Returns an appropriate error message for when
......
...@@ -20,9 +20,9 @@ ShellBrowserState::ShellBrowserState() : BrowserState() { ...@@ -20,9 +20,9 @@ ShellBrowserState::ShellBrowserState() : BrowserState() {
request_context_getter_ = new ShellURLRequestContextGetter( request_context_getter_ = new ShellURLRequestContextGetter(
GetStatePath(), GetStatePath(),
web::WebThread::GetTaskRunnerForThread(web::WebThread::IO), web::WebThread::GetMessageLoopProxyForThread(web::WebThread::IO),
web::WebThread::GetTaskRunnerForThread(web::WebThread::FILE), web::WebThread::GetMessageLoopProxyForThread(web::WebThread::FILE),
web::WebThread::GetTaskRunnerForThread(web::WebThread::CACHE)); web::WebThread::GetMessageLoopProxyForThread(web::WebThread::CACHE));
} }
ShellBrowserState::~ShellBrowserState() { ShellBrowserState::~ShellBrowserState() {
......
...@@ -40,7 +40,7 @@ ShellURLRequestContextGetter::ShellURLRequestContextGetter( ...@@ -40,7 +40,7 @@ ShellURLRequestContextGetter::ShellURLRequestContextGetter(
const base::FilePath& base_path, const base::FilePath& base_path,
const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner, const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner,
const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner, const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner,
const scoped_refptr<base::SingleThreadTaskRunner>& cache_task_runner) const scoped_refptr<base::MessageLoopProxy>& cache_task_runner)
: base_path_(base_path), : base_path_(base_path),
file_task_runner_(file_task_runner), file_task_runner_(file_task_runner),
network_task_runner_(network_task_runner), network_task_runner_(network_task_runner),
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
#include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_context_getter.h"
...@@ -31,7 +32,7 @@ class ShellURLRequestContextGetter : public net::URLRequestContextGetter { ...@@ -31,7 +32,7 @@ class ShellURLRequestContextGetter : public net::URLRequestContextGetter {
const base::FilePath& base_path, const base::FilePath& base_path,
const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner, const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner,
const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner, const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner,
const scoped_refptr<base::SingleThreadTaskRunner>& cache_task_runner); const scoped_refptr<base::MessageLoopProxy>& cache_task_runner);
// net::URLRequestContextGetter implementation. // net::URLRequestContextGetter implementation.
net::URLRequestContext* GetURLRequestContext() override; net::URLRequestContext* GetURLRequestContext() override;
...@@ -45,7 +46,7 @@ class ShellURLRequestContextGetter : public net::URLRequestContextGetter { ...@@ -45,7 +46,7 @@ class ShellURLRequestContextGetter : public net::URLRequestContextGetter {
base::FilePath base_path_; base::FilePath base_path_;
scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
scoped_refptr<base::SingleThreadTaskRunner> cache_task_runner_; scoped_refptr<base::MessageLoopProxy> cache_task_runner_;
scoped_ptr<net::ProxyConfigService> proxy_config_service_; scoped_ptr<net::ProxyConfigService> proxy_config_service_;
scoped_ptr<net::NetworkDelegate> network_delegate_; scoped_ptr<net::NetworkDelegate> network_delegate_;
scoped_ptr<net::URLRequestContextStorage> storage_; scoped_ptr<net::URLRequestContextStorage> storage_;
......
...@@ -164,9 +164,9 @@ bool WebThread::GetCurrentThreadIdentifier(ID* identifier) { ...@@ -164,9 +164,9 @@ bool WebThread::GetCurrentThreadIdentifier(ID* identifier) {
} }
// static // static
scoped_refptr<base::SingleThreadTaskRunner> WebThread::GetTaskRunnerForThread( scoped_refptr<base::MessageLoopProxy> WebThread::GetMessageLoopProxyForThread(
ID identifier) { ID identifier) {
return content::BrowserThread::GetTaskRunnerForThread( return content::BrowserThread::GetMessageLoopProxyForThread(
BrowserThreadIDFromWebThreadID(identifier)); BrowserThreadIDFromWebThreadID(identifier));
} }
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/lazy_instance.h" #include "base/lazy_instance.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/single_thread_task_runner.h" #include "base/message_loop/message_loop_proxy.h"
#include "base/threading/sequenced_worker_pool.h" #include "base/threading/sequenced_worker_pool.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "ios/web/public/web_thread_delegate.h" #include "ios/web/public/web_thread_delegate.h"
...@@ -32,13 +32,14 @@ const char* g_web_thread_names[WebThread::ID_COUNT] = { ...@@ -32,13 +32,14 @@ const char* g_web_thread_names[WebThread::ID_COUNT] = {
"Web_IOThread", // IO "Web_IOThread", // IO
}; };
// An implementation of SingleThreadTaskRunner to be used in conjunction // An implementation of MessageLoopProxy to be used in conjunction
// with WebThread. // with WebThread.
class WebThreadTaskRunner : public base::SingleThreadTaskRunner { class WebThreadMessageLoopProxy : public base::MessageLoopProxy {
public: public:
explicit WebThreadTaskRunner(WebThread::ID identifier) : id_(identifier) {} explicit WebThreadMessageLoopProxy(WebThread::ID identifier)
: id_(identifier) {}
// SingleThreadTaskRunner implementation. // MessageLoopProxy implementation.
bool PostDelayedTask(const tracked_objects::Location& from_here, bool PostDelayedTask(const tracked_objects::Location& from_here,
const base::Closure& task, const base::Closure& task,
base::TimeDelta delay) override { base::TimeDelta delay) override {
...@@ -56,26 +57,26 @@ class WebThreadTaskRunner : public base::SingleThreadTaskRunner { ...@@ -56,26 +57,26 @@ class WebThreadTaskRunner : public base::SingleThreadTaskRunner {
} }
protected: protected:
~WebThreadTaskRunner() override {} ~WebThreadMessageLoopProxy() override {}
private: private:
WebThread::ID id_; WebThread::ID id_;
DISALLOW_COPY_AND_ASSIGN(WebThreadTaskRunner); DISALLOW_COPY_AND_ASSIGN(WebThreadMessageLoopProxy);
}; };
// A separate helper is used just for the task runners, in order to avoid // A separate helper is used just for the proxies, in order to avoid needing
// needing to initialize the globals to create a task runner. // to initialize the globals to create a proxy.
struct WebThreadTaskRunners { struct WebThreadProxies {
WebThreadTaskRunners() { WebThreadProxies() {
for (int i = 0; i < WebThread::ID_COUNT; ++i) { for (int i = 0; i < WebThread::ID_COUNT; ++i) {
task_runners[i] = new WebThreadTaskRunner(static_cast<WebThread::ID>(i)); proxies[i] = new WebThreadMessageLoopProxy(static_cast<WebThread::ID>(i));
} }
} }
scoped_refptr<base::SingleThreadTaskRunner> task_runners[WebThread::ID_COUNT]; scoped_refptr<base::MessageLoopProxy> proxies[WebThread::ID_COUNT];
}; };
base::LazyInstance<WebThreadTaskRunners>::Leaky g_task_runners = base::LazyInstance<WebThreadProxies>::Leaky g_proxies =
LAZY_INSTANCE_INITIALIZER; LAZY_INSTANCE_INITIALIZER;
struct WebThreadGlobals { struct WebThreadGlobals {
...@@ -450,7 +451,7 @@ bool WebThread::PostTaskAndReply(ID identifier, ...@@ -450,7 +451,7 @@ bool WebThread::PostTaskAndReply(ID identifier,
const tracked_objects::Location& from_here, const tracked_objects::Location& from_here,
const base::Closure& task, const base::Closure& task,
const base::Closure& reply) { const base::Closure& reply) {
return GetTaskRunnerForThread(identifier) return GetMessageLoopProxyForThread(identifier)
->PostTaskAndReply(from_here, task, reply); ->PostTaskAndReply(from_here, task, reply);
} }
...@@ -478,9 +479,9 @@ bool WebThread::GetCurrentThreadIdentifier(ID* identifier) { ...@@ -478,9 +479,9 @@ bool WebThread::GetCurrentThreadIdentifier(ID* identifier) {
} }
// static // static
scoped_refptr<base::SingleThreadTaskRunner> WebThread::GetTaskRunnerForThread( scoped_refptr<base::MessageLoopProxy> WebThread::GetMessageLoopProxyForThread(
ID identifier) { ID identifier) {
return g_task_runners.Get().task_runners[identifier]; return g_proxies.Get().proxies[identifier];
} }
// static // static
......
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