OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "mojo/common/handle_watcher.h" | 5 #include "mojo/common/handle_watcher.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 base::TimeTicks MojoDeadlineToTimeTicks(MojoDeadline deadline) { | 40 base::TimeTicks MojoDeadlineToTimeTicks(MojoDeadline deadline) { |
41 return deadline == MOJO_DEADLINE_INDEFINITE ? base::TimeTicks() : | 41 return deadline == MOJO_DEADLINE_INDEFINITE ? base::TimeTicks() : |
42 internal::NowTicks() + base::TimeDelta::FromMicroseconds(deadline); | 42 internal::NowTicks() + base::TimeDelta::FromMicroseconds(deadline); |
43 } | 43 } |
44 | 44 |
45 // Tracks the data for a single call to Start(). | 45 // Tracks the data for a single call to Start(). |
46 struct WatchData { | 46 struct WatchData { |
47 WatchData() | 47 WatchData() |
48 : id(0), | 48 : id(0), |
49 handle_signals(MOJO_WAIT_FLAG_NONE), | 49 handle_signals(MOJO_HANDLE_SIGNAL_NONE), |
50 message_loop(NULL) {} | 50 message_loop(NULL) {} |
51 | 51 |
52 WatcherID id; | 52 WatcherID id; |
53 Handle handle; | 53 Handle handle; |
54 MojoHandleSignals handle_signals; | 54 MojoHandleSignals handle_signals; |
55 base::TimeTicks deadline; | 55 base::TimeTicks deadline; |
56 base::Callback<void(MojoResult)> callback; | 56 base::Callback<void(MojoResult)> callback; |
57 scoped_refptr<base::MessageLoopProxy> message_loop; | 57 scoped_refptr<base::MessageLoopProxy> message_loop; |
58 }; | 58 }; |
59 | 59 |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 } | 292 } |
293 | 293 |
294 HandleWatcher::~HandleWatcher() { | 294 HandleWatcher::~HandleWatcher() { |
295 } | 295 } |
296 | 296 |
297 void HandleWatcher::Start(const Handle& handle, | 297 void HandleWatcher::Start(const Handle& handle, |
298 MojoHandleSignals handle_signals, | 298 MojoHandleSignals handle_signals, |
299 MojoDeadline deadline, | 299 MojoDeadline deadline, |
300 const base::Callback<void(MojoResult)>& callback) { | 300 const base::Callback<void(MojoResult)>& callback) { |
301 DCHECK(handle.is_valid()); | 301 DCHECK(handle.is_valid()); |
302 DCHECK_NE(MOJO_WAIT_FLAG_NONE, handle_signals); | 302 DCHECK_NE(MOJO_HANDLE_SIGNAL_NONE, handle_signals); |
303 | 303 |
304 state_.reset(new State(this, handle, handle_signals, deadline, callback)); | 304 state_.reset(new State(this, handle, handle_signals, deadline, callback)); |
305 } | 305 } |
306 | 306 |
307 void HandleWatcher::Stop() { | 307 void HandleWatcher::Stop() { |
308 state_.reset(); | 308 state_.reset(); |
309 } | 309 } |
310 | 310 |
311 } // namespace common | 311 } // namespace common |
312 } // namespace mojo | 312 } // namespace mojo |
OLD | NEW |