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_MESSAGE_PUMP_HANDLE_WATCHER_H_ | 5 #ifndef MOJO_MESSAGE_PUMP_HANDLE_WATCHER_H_ |
6 #define MOJO_MESSAGE_PUMP_HANDLE_WATCHER_H_ | 6 #define MOJO_MESSAGE_PUMP_HANDLE_WATCHER_H_ |
7 | 7 |
8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 // before the handle is ready, then |callback| is invoked with a result of | 38 // before the handle is ready, then |callback| is invoked with a result of |
39 // MOJO_RESULT_ABORTED. | 39 // MOJO_RESULT_ABORTED. |
40 void Start(const Handle& handle, | 40 void Start(const Handle& handle, |
41 MojoHandleSignals handle_signals, | 41 MojoHandleSignals handle_signals, |
42 MojoDeadline deadline, | 42 MojoDeadline deadline, |
43 const base::Callback<void(MojoResult)>& callback); | 43 const base::Callback<void(MojoResult)>& callback); |
44 | 44 |
45 // Stops listening. Does nothing if not in the process of listening. | 45 // Stops listening. Does nothing if not in the process of listening. |
46 void Stop(); | 46 void Stop(); |
47 | 47 |
| 48 bool is_watching() const { return !!state_; } |
| 49 |
48 private: | 50 private: |
49 class StateBase; | 51 class StateBase; |
50 class SameThreadWatchingState; | 52 class SameThreadWatchingState; |
51 class SecondaryThreadWatchingState; | 53 class SecondaryThreadWatchingState; |
52 | 54 |
53 // If non-NULL Start() has been invoked. | 55 // If non-NULL Start() has been invoked. |
54 scoped_ptr<StateBase> state_; | 56 scoped_ptr<StateBase> state_; |
55 | 57 |
56 DISALLOW_COPY_AND_ASSIGN(HandleWatcher); | 58 DISALLOW_COPY_AND_ASSIGN(HandleWatcher); |
57 }; | 59 }; |
58 | 60 |
59 } // namespace common | 61 } // namespace common |
60 } // namespace mojo | 62 } // namespace mojo |
61 | 63 |
62 #endif // MOJO_MESSAGE_PUMP_HANDLE_WATCHER_H_ | 64 #endif // MOJO_MESSAGE_PUMP_HANDLE_WATCHER_H_ |
OLD | NEW |