| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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_PORTS_EVENT_H_ | 5 #ifndef MOJO_EDK_SYSTEM_PORTS_EVENT_H_ |
| 6 #define MOJO_EDK_SYSTEM_PORTS_EVENT_H_ | 6 #define MOJO_EDK_SYSTEM_PORTS_EVENT_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "mojo/edk/system/ports/message.h" | 10 #include "mojo/edk/system/ports/message.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 uint64_t last_sequence_num_to_receive; | 27 uint64_t last_sequence_num_to_receive; |
| 28 bool peer_closed; | 28 bool peer_closed; |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 enum struct EventType : uint32_t { | 31 enum struct EventType : uint32_t { |
| 32 kUser, | 32 kUser, |
| 33 kPortAccepted, | 33 kPortAccepted, |
| 34 kObserveProxy, | 34 kObserveProxy, |
| 35 kObserveProxyAck, | 35 kObserveProxyAck, |
| 36 kObserveClosure, | 36 kObserveClosure, |
| 37 kMergePort, | |
| 38 }; | 37 }; |
| 39 | 38 |
| 40 struct EventHeader { | 39 struct EventHeader { |
| 41 EventType type; | 40 EventType type; |
| 42 uint32_t padding; | 41 uint32_t padding; |
| 43 PortName port_name; | 42 PortName port_name; |
| 44 }; | 43 }; |
| 45 | 44 |
| 46 struct UserEventData { | 45 struct UserEventData { |
| 47 uint64_t sequence_num; | 46 uint64_t sequence_num; |
| 48 uint32_t num_ports; | 47 uint32_t num_ports; |
| 49 uint32_t padding; | 48 uint32_t padding; |
| 50 }; | 49 }; |
| 51 | 50 |
| 52 struct ObserveProxyEventData { | 51 struct ObserveProxyEventData { |
| 53 NodeName proxy_node_name; | 52 NodeName proxy_node_name; |
| 54 PortName proxy_port_name; | 53 PortName proxy_port_name; |
| 55 NodeName proxy_to_node_name; | 54 NodeName proxy_to_node_name; |
| 56 PortName proxy_to_port_name; | 55 PortName proxy_to_port_name; |
| 57 }; | 56 }; |
| 58 | 57 |
| 59 struct ObserveProxyAckEventData { | 58 struct ObserveProxyAckEventData { |
| 60 uint64_t last_sequence_num; | 59 uint64_t last_sequence_num; |
| 61 }; | 60 }; |
| 62 | 61 |
| 63 struct ObserveClosureEventData { | 62 struct ObserveClosureEventData { |
| 64 uint64_t last_sequence_num; | 63 uint64_t last_sequence_num; |
| 65 }; | 64 }; |
| 66 | 65 |
| 67 struct MergePortEventData { | |
| 68 PortName new_port_name; | |
| 69 PortDescriptor new_port_descriptor; | |
| 70 }; | |
| 71 | |
| 72 inline const EventHeader* GetEventHeader(const Message& message) { | 66 inline const EventHeader* GetEventHeader(const Message& message) { |
| 73 return static_cast<const EventHeader*>(message.header_bytes()); | 67 return static_cast<const EventHeader*>(message.header_bytes()); |
| 74 } | 68 } |
| 75 | 69 |
| 76 inline EventHeader* GetMutableEventHeader(Message* message) { | 70 inline EventHeader* GetMutableEventHeader(Message* message) { |
| 77 return static_cast<EventHeader*>(message->mutable_header_bytes()); | 71 return static_cast<EventHeader*>(message->mutable_header_bytes()); |
| 78 } | 72 } |
| 79 | 73 |
| 80 template <typename EventData> | 74 template <typename EventData> |
| 81 inline const EventData* GetEventData(const Message& message) { | 75 inline const EventData* GetEventData(const Message& message) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 96 | 90 |
| 97 inline PortDescriptor* GetMutablePortDescriptors(UserEventData* event) { | 91 inline PortDescriptor* GetMutablePortDescriptors(UserEventData* event) { |
| 98 return reinterpret_cast<PortDescriptor*>(reinterpret_cast<char*>(event + 1)); | 92 return reinterpret_cast<PortDescriptor*>(reinterpret_cast<char*>(event + 1)); |
| 99 } | 93 } |
| 100 | 94 |
| 101 } // namespace ports | 95 } // namespace ports |
| 102 } // namespace edk | 96 } // namespace edk |
| 103 } // namespace mojo | 97 } // namespace mojo |
| 104 | 98 |
| 105 #endif // MOJO_EDK_SYSTEM_PORTS_EVENT_H_ | 99 #endif // MOJO_EDK_SYSTEM_PORTS_EVENT_H_ |
| OLD | NEW |