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

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

Issue 2725133002: Mojo: Armed Watchers (Closed)
Patch Set: . Created 3 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/dispatcher.cc ('k') | mojo/edk/system/message_pipe_dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_EDK_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_ 5 #ifndef MOJO_EDK_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_
6 #define MOJO_EDK_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_ 6 #define MOJO_EDK_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <queue> 11 #include <queue>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "mojo/edk/system/atomic_flag.h" 14 #include "mojo/edk/system/atomic_flag.h"
15 #include "mojo/edk/system/awakable_list.h" 15 #include "mojo/edk/system/awakable_list.h"
16 #include "mojo/edk/system/dispatcher.h" 16 #include "mojo/edk/system/dispatcher.h"
17 #include "mojo/edk/system/message_for_transit.h" 17 #include "mojo/edk/system/message_for_transit.h"
18 #include "mojo/edk/system/ports/port_ref.h" 18 #include "mojo/edk/system/ports/port_ref.h"
19 #include "mojo/edk/system/watcher_set.h"
19 20
20 namespace mojo { 21 namespace mojo {
21 namespace edk { 22 namespace edk {
22 23
23 class NodeController; 24 class NodeController;
24 25
25 class MessagePipeDispatcher : public Dispatcher { 26 class MessagePipeDispatcher : public Dispatcher {
26 public: 27 public:
27 // Constructs a MessagePipeDispatcher permanently tied to a specific port. 28 // Constructs a MessagePipeDispatcher permanently tied to a specific port.
28 // |connected| must indicate the state of the port at construction time; if 29 // |connected| must indicate the state of the port at construction time; if
(...skipping 12 matching lines...) Expand all
41 int endpoint); 42 int endpoint);
42 43
43 // Fuses this pipe with |other|. Returns |true| on success or |false| on 44 // Fuses this pipe with |other|. Returns |true| on success or |false| on
44 // failure. Regardless of the return value, both dispatchers are closed by 45 // failure. Regardless of the return value, both dispatchers are closed by
45 // this call. 46 // this call.
46 bool Fuse(MessagePipeDispatcher* other); 47 bool Fuse(MessagePipeDispatcher* other);
47 48
48 // Dispatcher: 49 // Dispatcher:
49 Type GetType() const override; 50 Type GetType() const override;
50 MojoResult Close() override; 51 MojoResult Close() override;
51 MojoResult Watch(MojoHandleSignals signals,
52 const Watcher::WatchCallback& callback,
53 uintptr_t context) override;
54 MojoResult CancelWatch(uintptr_t context) override;
55 MojoResult WriteMessage(std::unique_ptr<MessageForTransit> message, 52 MojoResult WriteMessage(std::unique_ptr<MessageForTransit> message,
56 MojoWriteMessageFlags flags) override; 53 MojoWriteMessageFlags flags) override;
57 MojoResult ReadMessage(std::unique_ptr<MessageForTransit>* message, 54 MojoResult ReadMessage(std::unique_ptr<MessageForTransit>* message,
58 uint32_t* num_bytes, 55 uint32_t* num_bytes,
59 MojoHandle* handles, 56 MojoHandle* handles,
60 uint32_t* num_handles, 57 uint32_t* num_handles,
61 MojoReadMessageFlags flags, 58 MojoReadMessageFlags flags,
62 bool read_any_size) override; 59 bool read_any_size) override;
63 HandleSignalsState GetHandleSignalsState() const override; 60 HandleSignalsState GetHandleSignalsState() const override;
61 MojoResult AddWatcherRef(const scoped_refptr<WatcherDispatcher>& watcher,
62 uintptr_t context) override;
63 MojoResult RemoveWatcherRef(WatcherDispatcher* watcher,
64 uintptr_t context) override;
64 MojoResult AddAwakable(Awakable* awakable, 65 MojoResult AddAwakable(Awakable* awakable,
65 MojoHandleSignals signals, 66 MojoHandleSignals signals,
66 uintptr_t context, 67 uintptr_t context,
67 HandleSignalsState* signals_state) override; 68 HandleSignalsState* signals_state) override;
68 void RemoveAwakable(Awakable* awakable, 69 void RemoveAwakable(Awakable* awakable,
69 HandleSignalsState* signals_state) override; 70 HandleSignalsState* signals_state) override;
70 void StartSerialize(uint32_t* num_bytes, 71 void StartSerialize(uint32_t* num_bytes,
71 uint32_t* num_ports, 72 uint32_t* num_ports,
72 uint32_t* num_handles) override; 73 uint32_t* num_handles) override;
73 bool EndSerialize(void* destination, 74 bool EndSerialize(void* destination,
(...skipping 30 matching lines...) Expand all
104 // Guards access to all the fields below. 105 // Guards access to all the fields below.
105 mutable base::Lock signal_lock_; 106 mutable base::Lock signal_lock_;
106 107
107 // This is not the same is |port_transferred_|. It's only held true between 108 // This is not the same is |port_transferred_|. It's only held true between
108 // BeginTransit() and Complete/CancelTransit(). 109 // BeginTransit() and Complete/CancelTransit().
109 AtomicFlag in_transit_; 110 AtomicFlag in_transit_;
110 111
111 bool port_transferred_ = false; 112 bool port_transferred_ = false;
112 AtomicFlag port_closed_; 113 AtomicFlag port_closed_;
113 AwakableList awakables_; 114 AwakableList awakables_;
115 WatcherSet watchers_;
114 116
115 DISALLOW_COPY_AND_ASSIGN(MessagePipeDispatcher); 117 DISALLOW_COPY_AND_ASSIGN(MessagePipeDispatcher);
116 }; 118 };
117 119
118 } // namespace edk 120 } // namespace edk
119 } // namespace mojo 121 } // namespace mojo
120 122
121 #endif // MOJO_EDK_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_ 123 #endif // MOJO_EDK_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/dispatcher.cc ('k') | mojo/edk/system/message_pipe_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698