OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_PUBLIC_CPP_SYSTEM_WATCHER_H_ | 5 #ifndef MOJO_PUBLIC_CPP_SYSTEM_WATCHER_H_ |
6 #define MOJO_PUBLIC_CPP_SYSTEM_WATCHER_H_ | 6 #define MOJO_PUBLIC_CPP_SYSTEM_WATCHER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
15 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
17 #include "mojo/public/c/system/types.h" | 17 #include "mojo/public/c/system/types.h" |
18 #include "mojo/public/cpp/system/handle.h" | 18 #include "mojo/public/cpp/system/handle.h" |
| 19 #include "mojo/public/cpp/system/system_export.h" |
19 | 20 |
20 namespace mojo { | 21 namespace mojo { |
21 | 22 |
22 // A Watcher watches a single Mojo handle for signal state changes. | 23 // A Watcher watches a single Mojo handle for signal state changes. |
23 // | 24 // |
24 // NOTE: Watchers may only be used on threads which have a running MessageLoop. | 25 // NOTE: Watchers may only be used on threads which have a running MessageLoop. |
25 class Watcher { | 26 class MOJO_CPP_SYSTEM_EXPORT Watcher { |
26 public: | 27 public: |
27 // A callback to be called any time a watched handle changes state in some | 28 // A callback to be called any time a watched handle changes state in some |
28 // interesting way. The |result| argument indicates one of the following | 29 // interesting way. The |result| argument indicates one of the following |
29 // conditions depending on its value: | 30 // conditions depending on its value: |
30 // | 31 // |
31 // |MOJO_RESULT_OK|: One or more of the signals being watched is satisfied. | 32 // |MOJO_RESULT_OK|: One or more of the signals being watched is satisfied. |
32 // | 33 // |
33 // |MOJO_RESULT_FAILED_PRECONDITION|: None of the signals being watched can | 34 // |MOJO_RESULT_FAILED_PRECONDITION|: None of the signals being watched can |
34 // ever be satisfied again. | 35 // ever be satisfied again. |
35 // | 36 // |
(...skipping 80 matching lines...) Loading... |
116 ReadyCallback callback_; | 117 ReadyCallback callback_; |
117 | 118 |
118 base::WeakPtrFactory<Watcher> weak_factory_; | 119 base::WeakPtrFactory<Watcher> weak_factory_; |
119 | 120 |
120 DISALLOW_COPY_AND_ASSIGN(Watcher); | 121 DISALLOW_COPY_AND_ASSIGN(Watcher); |
121 }; | 122 }; |
122 | 123 |
123 } // namespace mojo | 124 } // namespace mojo |
124 | 125 |
125 #endif // MOJO_PUBLIC_CPP_SYSTEM_WATCHER_H_ | 126 #endif // MOJO_PUBLIC_CPP_SYSTEM_WATCHER_H_ |
OLD | NEW |