Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(839)

Unified Diff: net/dns/serial_worker.cc

Issue 1137433003: Encouraging ThreadTaskRunnerHandle usage in net/dns module (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed build failure Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/dns/serial_worker.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/serial_worker.cc
diff --git a/net/dns/serial_worker.cc b/net/dns/serial_worker.cc
index 4da7df98ba2d878b4f694a5fca60c0a46d5d0313..6cf692d0acad1ced3ecde91a7908d5f2c2b9aa3e 100644
--- a/net/dns/serial_worker.cc
+++ b/net/dns/serial_worker.cc
@@ -6,19 +6,19 @@
#include "base/bind.h"
#include "base/location.h"
-#include "base/message_loop/message_loop_proxy.h"
+#include "base/thread_task_runner_handle.h"
#include "base/threading/worker_pool.h"
namespace net {
SerialWorker::SerialWorker()
- : message_loop_(base::MessageLoopProxy::current()),
- state_(IDLE) {}
+ : task_runner_(base::ThreadTaskRunnerHandle::Get()), state_(IDLE) {
+}
SerialWorker::~SerialWorker() {}
void SerialWorker::WorkNow() {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
switch (state_) {
case IDLE:
if (!base::WorkerPool::PostTask(FROM_HERE, base::Bind(
@@ -29,7 +29,7 @@ void SerialWorker::WorkNow() {
#else
LOG(WARNING) << "Failed to WorkerPool::PostTask, will retry later";
const int kWorkerPoolRetryDelayMs = 100;
- message_loop_->PostDelayedTask(
+ task_runner_->PostDelayedTask(
FROM_HERE,
base::Bind(&SerialWorker::RetryWork, this),
base::TimeDelta::FromMilliseconds(kWorkerPoolRetryDelayMs));
@@ -53,19 +53,19 @@ void SerialWorker::WorkNow() {
}
void SerialWorker::Cancel() {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
state_ = CANCELLED;
}
void SerialWorker::DoWorkJob() {
this->DoWork();
// If this fails, the loop is gone, so there is no point retrying.
- message_loop_->PostTask(FROM_HERE, base::Bind(
- &SerialWorker::OnWorkJobFinished, this));
+ task_runner_->PostTask(FROM_HERE,
+ base::Bind(&SerialWorker::OnWorkJobFinished, this));
}
void SerialWorker::OnWorkJobFinished() {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
switch (state_) {
case CANCELLED:
return;
@@ -83,7 +83,7 @@ void SerialWorker::OnWorkJobFinished() {
}
void SerialWorker::RetryWork() {
- DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK(task_runner_->BelongsToCurrentThread());
switch (state_) {
case CANCELLED:
return;
« no previous file with comments | « net/dns/serial_worker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698