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

Side by Side Diff: mojo/edk/system/watcher_set.h

Issue 1748503002: [mojo-edk] Add MojoWatch and MojoCancelWatch APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: there can be only one RequestContext! Created 4 years, 9 months 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MOJO_EDK_SYSTEM_WATCHER_SET_H_
6 #define MOJO_EDK_SYSTEM_WATCHER_SET_H_
7
8 #include <unordered_map>
9
10 #include "base/callback.h"
Anand Mistry (off Chromium) 2016/03/02 01:50:36 #include "base/macros.h"
Ken Rockot(use gerrit already) 2016/03/02 02:09:39 done
11 #include "base/memory/ref_counted.h"
12 #include "base/synchronization/lock.h"
Anand Mistry (off Chromium) 2016/03/02 01:50:36 Unused
Ken Rockot(use gerrit already) 2016/03/02 02:09:39 removed
13 #include "mojo/edk/system/handle_signals_state.h"
14 #include "mojo/edk/system/watcher.h"
15 #include "mojo/public/c/system/types.h"
16
17 namespace mojo {
18 namespace edk {
19
20 // A WatcherSet maintains a set of Watchers attached to a single handle and
21 // keyed on an arbitrary user context.
22 class WatcherSet {
23 public:
24 WatcherSet();
25 ~WatcherSet();
26
27 // Notifies all Watchers of a state change.
28 void NotifyForStateChange(const HandleSignalsState& state);
29
30 // Notifies all Watchers that their watched handle has been closed.
31 void NotifyClosed();
32
33 // Adds a new watcher to watch for signals in |signals| to be satisfied or
34 // unsatisfiable. |current_state| is the current signals state of the
35 // handle being watched.
36 MojoResult Add(MojoHandleSignals signals,
37 const Watcher::WatchCallback& callback,
38 uintptr_t context,
39 const HandleSignalsState& current_state);
40
41 MojoResult Remove(uintptr_t context);
Anand Mistry (off Chromium) 2016/03/02 01:50:36 For consistency, add a comment.
Ken Rockot(use gerrit already) 2016/03/02 02:09:39 done
42
43 private:
44 // A map of watchers keyed on context value.
45 std::unordered_map<uintptr_t, scoped_refptr<Watcher>> watchers_;
46
47 DISALLOW_COPY_AND_ASSIGN(WatcherSet);
48 };
49
50 } // namespace edk
51 } // namespace mojo
52
53 #endif // MOJO_EDK_SYSTEM_WATCHER_SET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698