| Index: mojo/message_pump/handle_watcher.cc
|
| diff --git a/mojo/common/handle_watcher.cc b/mojo/message_pump/handle_watcher.cc
|
| similarity index 95%
|
| rename from mojo/common/handle_watcher.cc
|
| rename to mojo/message_pump/handle_watcher.cc
|
| index 79cdcdb616b7e8cc5c1b69603b945b52f06ced65..c330d31b1c5295958ea20527de520dc28c9efa34 100644
|
| --- a/mojo/common/handle_watcher.cc
|
| +++ b/mojo/message_pump/handle_watcher.cc
|
| @@ -2,27 +2,26 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "mojo/common/handle_watcher.h"
|
| +#include "mojo/message_pump/handle_watcher.h"
|
|
|
| #include <map>
|
|
|
| #include "base/atomic_sequence_num.h"
|
| #include "base/bind.h"
|
| -#include "base/lazy_instance.h"
|
| #include "base/logging.h"
|
| #include "base/macros.h"
|
| #include "base/memory/singleton.h"
|
| #include "base/memory/weak_ptr.h"
|
| #include "base/message_loop/message_loop.h"
|
| -#include "base/message_loop/message_loop_proxy.h"
|
| #include "base/synchronization/lock.h"
|
| #include "base/synchronization/waitable_event.h"
|
| +#include "base/thread_task_runner_handle.h"
|
| #include "base/threading/thread.h"
|
| #include "base/threading/thread_restrictions.h"
|
| #include "base/time/time.h"
|
| -#include "mojo/common/message_pump_mojo.h"
|
| -#include "mojo/common/message_pump_mojo_handler.h"
|
| -#include "mojo/common/time_helper.h"
|
| +#include "mojo/message_pump/message_pump_mojo.h"
|
| +#include "mojo/message_pump/message_pump_mojo_handler.h"
|
| +#include "mojo/message_pump/time_helper.h"
|
|
|
| namespace mojo {
|
| namespace common {
|
| @@ -43,14 +42,14 @@ struct WatchData {
|
| WatchData()
|
| : id(0),
|
| handle_signals(MOJO_HANDLE_SIGNAL_NONE),
|
| - message_loop(NULL) {}
|
| + task_runner(NULL) {}
|
|
|
| WatcherID id;
|
| Handle handle;
|
| MojoHandleSignals handle_signals;
|
| base::TimeTicks deadline;
|
| base::Callback<void(MojoResult)> callback;
|
| - scoped_refptr<base::MessageLoopProxy> message_loop;
|
| + scoped_refptr<base::SingleThreadTaskRunner> task_runner;
|
| };
|
|
|
| // WatcherBackend --------------------------------------------------------------
|
| @@ -123,8 +122,7 @@ void WatcherBackend::RemoveAndNotify(const Handle& handle,
|
| const WatchData data(handle_to_data_[handle]);
|
| handle_to_data_.erase(handle);
|
| MessagePumpMojo::current()->RemoveHandler(handle);
|
| -
|
| - data.message_loop->PostTask(FROM_HERE, base::Bind(data.callback, result));
|
| + data.task_runner->PostTask(FROM_HERE, base::Bind(data.callback, result));
|
| }
|
|
|
| bool WatcherBackend::GetMojoHandleByWatcherID(WatcherID watcher_id,
|
| @@ -238,9 +236,7 @@ WatcherID WatcherThreadManager::StartWatching(
|
| request_data.start_data.callback = callback;
|
| request_data.start_data.handle_signals = handle_signals;
|
| request_data.start_data.deadline = deadline;
|
| - request_data.start_data.message_loop = base::MessageLoopProxy::current();
|
| - DCHECK_NE(static_cast<base::MessageLoopProxy*>(NULL),
|
| - request_data.start_data.message_loop.get());
|
| + request_data.start_data.task_runner = base::ThreadTaskRunnerHandle::Get();
|
| AddRequest(request_data);
|
| return request_data.start_data.id;
|
| }
|
| @@ -280,7 +276,7 @@ void WatcherThreadManager::AddRequest(const RequestData& data) {
|
| return;
|
| }
|
| // We own |thread_|, so it's safe to use Unretained() here.
|
| - thread_.message_loop()->PostTask(
|
| + thread_.task_runner()->PostTask(
|
| FROM_HERE,
|
| base::Bind(&WatcherThreadManager::ProcessRequestsOnBackendThread,
|
| base::Unretained(this)));
|
|
|