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 #ifndef MOJO_SHELL_HANDLE_WATCHER_H_ | 5 #ifndef MOJO_COMMON_HANDLE_WATCHER_H_ |
6 #define MOJO_SHELL_HANDLE_WATCHER_H_ | 6 #define MOJO_COMMON_HANDLE_WATCHER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback_forward.h" | 9 #include "base/callback_forward.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "mojo/common/mojo_common_export.h" |
11 #include "mojo/public/system/core.h" | 12 #include "mojo/public/system/core.h" |
12 | 13 |
13 namespace base { | 14 namespace base { |
14 class Thread; | 15 class Thread; |
15 class TickClock; | 16 class TickClock; |
16 class TimeTicks; | 17 class TimeTicks; |
17 } | 18 } |
18 | 19 |
19 namespace mojo { | 20 namespace mojo { |
20 namespace shell { | 21 namespace common { |
21 namespace test { | 22 namespace test { |
22 class HandleWatcherTest; | 23 class HandleWatcherTest; |
23 } | 24 } |
24 | 25 |
25 // HandleWatcher is used to asynchronously wait on a handle and notify a Closure | 26 // HandleWatcher is used to asynchronously wait on a handle and notify a Closure |
26 // when the handle is ready, or the deadline has expired. | 27 // when the handle is ready, or the deadline has expired. |
27 class HandleWatcher { | 28 class MOJO_COMMON_EXPORT HandleWatcher { |
28 public: | 29 public: |
29 HandleWatcher(); | 30 HandleWatcher(); |
30 ~HandleWatcher(); | 31 ~HandleWatcher(); |
31 | 32 |
32 // Starts listening for |handle|. This implicitly invokes Stop(). In other | 33 // Starts listening for |handle|. This implicitly invokes Stop(). In other |
33 // words, Start() performs one asynchronous watch at a time. It is ok to call | 34 // words, Start() performs one asynchronous watch at a time. It is ok to call |
34 // Start() multiple times, but it cancels any existing watches. |callback| is | 35 // Start() multiple times, but it cancels any existing watches. |callback| is |
35 // notified when the handle is ready, invalid or deadline has passed and is | 36 // notified when the handle is ready, invalid or deadline has passed and is |
36 // notified on the thread Start() was invoked on. | 37 // notified on the thread Start() was invoked on. |
37 void Start(MojoHandle handle, | 38 void Start(MojoHandle handle, |
(...skipping 19 matching lines...) Expand all Loading... |
57 | 58 |
58 // If non-NULL Start() has been invoked. | 59 // If non-NULL Start() has been invoked. |
59 scoped_ptr<StartState> start_state_; | 60 scoped_ptr<StartState> start_state_; |
60 | 61 |
61 // Used for getting the time. Only set by tests. | 62 // Used for getting the time. Only set by tests. |
62 static base::TickClock* tick_clock_; | 63 static base::TickClock* tick_clock_; |
63 | 64 |
64 DISALLOW_COPY_AND_ASSIGN(HandleWatcher); | 65 DISALLOW_COPY_AND_ASSIGN(HandleWatcher); |
65 }; | 66 }; |
66 | 67 |
67 } // namespace shell | 68 } // namespace common |
68 } // namespace mojo | 69 } // namespace mojo |
69 | 70 |
70 #endif // MOJO_SHELL_HANDLE_WATCHER_H_ | 71 #endif // MOJO_COMMON_HANDLE_WATCHER_H_ |
OLD | NEW |