Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: mojo/message_pump/handle_watcher.h

Issue 1475983004: Revert making HandleWatcher block until no longer waiting on pipe (r285266). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update comment (undo change in r283888 Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/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"
(...skipping 10 matching lines...) Expand all
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_MESSAGE_PUMP_EXPORT HandleWatcher { 27 class MOJO_MESSAGE_PUMP_EXPORT HandleWatcher {
28 public: 28 public:
29 HandleWatcher(); 29 HandleWatcher();
30 30
31 // The destructor implicitly stops listening. See Stop() for details.
32 ~HandleWatcher(); 31 ~HandleWatcher();
33 32
34 // Starts listening for |handle|. This implicitly invokes Stop(). In other 33 // 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 34 // 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 35 // 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 36 // notified when the handle is ready, invalid or deadline has passed and is
38 // notified on the thread Start() was invoked on. If the current thread exits 37 // notified on the thread Start() was invoked on. If the current thread exits
39 // 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
40 // MOJO_RESULT_ABORTED. 39 // MOJO_RESULT_ABORTED.
41 void Start(const Handle& handle, 40 void Start(const Handle& handle,
42 MojoHandleSignals handle_signals, 41 MojoHandleSignals handle_signals,
43 MojoDeadline deadline, 42 MojoDeadline deadline,
44 const base::Callback<void(MojoResult)>& callback); 43 const base::Callback<void(MojoResult)>& callback);
45 44
46 // Stops listening. Does nothing if not in the process of listening. Blocks 45 // Stops listening. Does nothing if not in the process of listening.
47 // until no longer listening on the handle.
48 void Stop(); 46 void Stop();
49 47
50 private: 48 private:
51 class StateBase; 49 class StateBase;
52 class SameThreadWatchingState; 50 class SameThreadWatchingState;
53 class SecondaryThreadWatchingState; 51 class SecondaryThreadWatchingState;
54 52
55 // If non-NULL Start() has been invoked. 53 // If non-NULL Start() has been invoked.
56 scoped_ptr<StateBase> state_; 54 scoped_ptr<StateBase> state_;
57 55
58 DISALLOW_COPY_AND_ASSIGN(HandleWatcher); 56 DISALLOW_COPY_AND_ASSIGN(HandleWatcher);
59 }; 57 };
60 58
61 } // namespace common 59 } // namespace common
62 } // namespace mojo 60 } // namespace mojo
63 61
64 #endif // MOJO_MESSAGE_PUMP_HANDLE_WATCHER_H_ 62 #endif // MOJO_MESSAGE_PUMP_HANDLE_WATCHER_H_
OLDNEW
« no previous file with comments | « mojo/android/javatests/src/org/chromium/mojo/system/impl/CoreImplTest.java ('k') | mojo/message_pump/handle_watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698