#include "base/bind.h"
#include "base/location.h"
#include "base/logging.h"
+#include "base/single_thread_task_runner.h"
+#include "base/task_runner.h"
+#include "base/thread_task_runner_handle.h"
#include "base/threading/thread_restrictions.h"
namespace disk_cache {
// ---------------------------------------------------------------------------
InFlightIO::InFlightIO()
- : callback_thread_(base::MessageLoopProxy::current()),
- running_(false), single_thread_(false) {
+ : callback_task_runner_(base::ThreadTaskRunnerHandle::Get()),
+ running_(false),
+ single_thread_(false) {
}
InFlightIO::~InFlightIO() {
// Runs on a background thread.
void InFlightIO::OnIOComplete(BackgroundIO* operation) {
#ifndef NDEBUG
- if (callback_thread_->BelongsToCurrentThread()) {
+ if (callback_task_runner_->RunsTasksOnCurrentThread()) {
DCHECK(single_thread_ || !running_);
single_thread_ = true;
}
#endif
- callback_thread_->PostTask(FROM_HERE,
- base::Bind(&BackgroundIO::OnIOSignalled,
- operation));
+ callback_task_runner_->PostTask(
+ FROM_HERE, base::Bind(&BackgroundIO::OnIOSignalled, operation));
operation->io_completed()->Signal();
}
// Runs on the primary thread.
void InFlightIO::OnOperationPosted(BackgroundIO* operation) {
- DCHECK(callback_thread_->BelongsToCurrentThread());
+ DCHECK(callback_task_runner_->RunsTasksOnCurrentThread());
io_list_.insert(make_scoped_refptr(operation));
}