OLD | NEW |
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 <queue> | 10 #include <queue> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "mojo/edk/system/awakable_list.h" | 14 #include "mojo/edk/system/awakable_list.h" |
15 #include "mojo/edk/system/dispatcher.h" | 15 #include "mojo/edk/system/dispatcher.h" |
16 #include "mojo/edk/system/ports/port_ref.h" | 16 #include "mojo/edk/system/ports/port_ref.h" |
17 | 17 |
18 namespace mojo { | 18 namespace mojo { |
19 namespace edk { | 19 namespace edk { |
20 | 20 |
| 21 class MessageForTransit; |
21 class NodeController; | 22 class NodeController; |
22 class PortsMessage; | 23 class PortsMessage; |
23 | 24 |
24 class MessagePipeDispatcher : public Dispatcher { | 25 class MessagePipeDispatcher : public Dispatcher { |
25 public: | 26 public: |
26 // Constructs a MessagePipeDispatcher permanently tied to a specific port. | 27 // Constructs a MessagePipeDispatcher permanently tied to a specific port. |
27 // |connected| must indicate the state of the port at construction time; if | 28 // |connected| must indicate the state of the port at construction time; if |
28 // the port is initialized with a peer, |connected| must be true. Otherwise it | 29 // the port is initialized with a peer, |connected| must be true. Otherwise it |
29 // must be false. | 30 // must be false. |
30 // | 31 // |
(...skipping 13 matching lines...) Expand all Loading... |
44 // this call. | 45 // this call. |
45 bool Fuse(MessagePipeDispatcher* other); | 46 bool Fuse(MessagePipeDispatcher* other); |
46 | 47 |
47 // Dispatcher: | 48 // Dispatcher: |
48 Type GetType() const override; | 49 Type GetType() const override; |
49 MojoResult Close() override; | 50 MojoResult Close() override; |
50 MojoResult Watch(MojoHandleSignals signals, | 51 MojoResult Watch(MojoHandleSignals signals, |
51 const Watcher::WatchCallback& callback, | 52 const Watcher::WatchCallback& callback, |
52 uintptr_t context) override; | 53 uintptr_t context) override; |
53 MojoResult CancelWatch(uintptr_t context) override; | 54 MojoResult CancelWatch(uintptr_t context) override; |
54 MojoResult WriteMessage(const void* bytes, | 55 MojoResult WriteMessage(std::unique_ptr<MessageForTransit> message, |
55 uint32_t num_bytes, | |
56 const DispatcherInTransit* dispatchers, | |
57 uint32_t num_dispatchers, | |
58 MojoWriteMessageFlags flags) override; | 56 MojoWriteMessageFlags flags) override; |
59 MojoResult ReadMessage(void* bytes, | 57 MojoResult ReadMessage(std::unique_ptr<MessageForTransit>* message, |
60 uint32_t* num_bytes, | 58 uint32_t* num_bytes, |
61 MojoHandle* handles, | 59 MojoHandle* handles, |
62 uint32_t* num_handles, | 60 uint32_t* num_handles, |
63 MojoReadMessageFlags flags) override; | 61 MojoReadMessageFlags flags, |
| 62 bool ignore_num_bytes) override; |
64 HandleSignalsState GetHandleSignalsState() const override; | 63 HandleSignalsState GetHandleSignalsState() const override; |
65 MojoResult AddAwakable(Awakable* awakable, | 64 MojoResult AddAwakable(Awakable* awakable, |
66 MojoHandleSignals signals, | 65 MojoHandleSignals signals, |
67 uintptr_t context, | 66 uintptr_t context, |
68 HandleSignalsState* signals_state) override; | 67 HandleSignalsState* signals_state) override; |
69 void RemoveAwakable(Awakable* awakable, | 68 void RemoveAwakable(Awakable* awakable, |
70 HandleSignalsState* signals_state) override; | 69 HandleSignalsState* signals_state) override; |
71 void StartSerialize(uint32_t* num_bytes, | 70 void StartSerialize(uint32_t* num_bytes, |
72 uint32_t* num_ports, | 71 uint32_t* num_ports, |
73 uint32_t* num_handles) override; | 72 uint32_t* num_handles) override; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 bool port_closed_ = false; | 112 bool port_closed_ = false; |
114 AwakableList awakables_; | 113 AwakableList awakables_; |
115 | 114 |
116 DISALLOW_COPY_AND_ASSIGN(MessagePipeDispatcher); | 115 DISALLOW_COPY_AND_ASSIGN(MessagePipeDispatcher); |
117 }; | 116 }; |
118 | 117 |
119 } // namespace edk | 118 } // namespace edk |
120 } // namespace mojo | 119 } // namespace mojo |
121 | 120 |
122 #endif // MOJO_EDK_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_ | 121 #endif // MOJO_EDK_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_ |
OLD | NEW |