| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/dns/serial_worker.h" | 5 #include "net/dns/serial_worker.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 #include "base/threading/worker_pool.h" | 10 #include "base/threading/worker_pool.h" |
| 11 | 11 |
| 12 namespace net { | 12 namespace net { |
| 13 | 13 |
| 14 SerialWorker::SerialWorker() | 14 SerialWorker::SerialWorker() |
| 15 : message_loop_(base::MessageLoopProxy::current()), | 15 : message_loop_(base::ThreadTaskRunnerHandle::Get()), state_(IDLE) {} |
| 16 state_(IDLE) {} | |
| 17 | 16 |
| 18 SerialWorker::~SerialWorker() {} | 17 SerialWorker::~SerialWorker() {} |
| 19 | 18 |
| 20 void SerialWorker::WorkNow() { | 19 void SerialWorker::WorkNow() { |
| 21 DCHECK(message_loop_->BelongsToCurrentThread()); | 20 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 22 switch (state_) { | 21 switch (state_) { |
| 23 case IDLE: | 22 case IDLE: |
| 24 if (!base::WorkerPool::PostTask(FROM_HERE, base::Bind( | 23 if (!base::WorkerPool::PostTask(FROM_HERE, base::Bind( |
| 25 &SerialWorker::DoWorkJob, this), false)) { | 24 &SerialWorker::DoWorkJob, this), false)) { |
| 26 #if defined(OS_POSIX) | 25 #if defined(OS_POSIX) |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 state_ = IDLE; | 90 state_ = IDLE; |
| 92 WorkNow(); | 91 WorkNow(); |
| 93 return; | 92 return; |
| 94 default: | 93 default: |
| 95 NOTREACHED() << "Unexpected state " << state_; | 94 NOTREACHED() << "Unexpected state " << state_; |
| 96 } | 95 } |
| 97 } | 96 } |
| 98 | 97 |
| 99 } // namespace net | 98 } // namespace net |
| 100 | 99 |
| OLD | NEW |