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

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: revert RequestContext usage, nits 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
« no previous file with comments | « mojo/edk/system/watcher.cc ('k') | mojo/edk/system/watcher_set.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
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 // Removes a watcher from the set.
42 MojoResult Remove(uintptr_t context);
43
44 private:
45 // A map of watchers keyed on context value.
46 std::unordered_map<uintptr_t, scoped_refptr<Watcher>> watchers_;
47
48 DISALLOW_COPY_AND_ASSIGN(WatcherSet);
49 };
50
51 } // namespace edk
52 } // namespace mojo
53
54 #endif // MOJO_EDK_SYSTEM_WATCHER_SET_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/watcher.cc ('k') | mojo/edk/system/watcher_set.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698