Commit c2740989 authored by skyostil's avatar skyostil Committed by Commit bot

ios: Remove use of MessageLoopProxy and deprecated MessageLoop APIs

BUG=465354

Committed: https://crrev.com/9c8e5d7259661cda32b698ee88254491e6984900
Cr-Commit-Position: refs/heads/master@{#333080}

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

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