| 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_COMMON_HANDLE_WATCHER_H_ | 5 #ifndef MOJO_MESSAGE_PUMP_HANDLE_WATCHER_H_ |
| 6 #define MOJO_COMMON_HANDLE_WATCHER_H_ | 6 #define MOJO_MESSAGE_PUMP_HANDLE_WATCHER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
| 9 #include "base/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "mojo/common/mojo_common_export.h" | 12 #include "mojo/public/c/system/time.h" |
| 13 #include "third_party/mojo/src/mojo/public/cpp/system/core.h" | 13 #include "mojo/public/cpp/system/handle.h" |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 class Thread; | 16 class Thread; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace mojo { | 19 namespace mojo { |
| 20 namespace common { | 20 namespace common { |
| 21 namespace test { | 21 namespace test { |
| 22 class HandleWatcherTest; | 22 class HandleWatcherTest; |
| 23 } | 23 } |
| 24 | 24 |
| 25 // HandleWatcher is used to asynchronously wait on a handle and notify a Closure | 25 // HandleWatcher is used to asynchronously wait on a handle and notify a Closure |
| 26 // when the handle is ready, or the deadline has expired. | 26 // when the handle is ready, or the deadline has expired. |
| 27 class MOJO_COMMON_EXPORT HandleWatcher { | 27 class HandleWatcher { |
| 28 public: | 28 public: |
| 29 HandleWatcher(); | 29 HandleWatcher(); |
| 30 | 30 |
| 31 // The destructor implicitly stops listening. See Stop() for details. | 31 // The destructor implicitly stops listening. See Stop() for details. |
| 32 ~HandleWatcher(); | 32 ~HandleWatcher(); |
| 33 | 33 |
| 34 // Starts listening for |handle|. This implicitly invokes Stop(). In other | 34 // Starts listening for |handle|. This implicitly invokes Stop(). In other |
| 35 // words, Start() performs one asynchronous watch at a time. It is ok to call | 35 // words, Start() performs one asynchronous watch at a time. It is ok to call |
| 36 // Start() multiple times, but it cancels any existing watches. |callback| is | 36 // Start() multiple times, but it cancels any existing watches. |callback| is |
| 37 // notified when the handle is ready, invalid or deadline has passed and is | 37 // notified when the handle is ready, invalid or deadline has passed and is |
| (...skipping 16 matching lines...) Expand all Loading... |
| 54 | 54 |
| 55 // If non-NULL Start() has been invoked. | 55 // If non-NULL Start() has been invoked. |
| 56 scoped_ptr<StateBase> state_; | 56 scoped_ptr<StateBase> state_; |
| 57 | 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(HandleWatcher); | 58 DISALLOW_COPY_AND_ASSIGN(HandleWatcher); |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 } // namespace common | 61 } // namespace common |
| 62 } // namespace mojo | 62 } // namespace mojo |
| 63 | 63 |
| 64 #endif // MOJO_COMMON_HANDLE_WATCHER_H_ | 64 #endif // MOJO_MESSAGE_PUMP_HANDLE_WATCHER_H_ |
| OLD | NEW |