OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_DATA_PIPE_PRODUCER_DISPATCHER_H_ | 5 #ifndef MOJO_EDK_SYSTEM_DATA_PIPE_PRODUCER_DISPATCHER_H_ |
6 #define MOJO_EDK_SYSTEM_DATA_PIPE_PRODUCER_DISPATCHER_H_ | 6 #define MOJO_EDK_SYSTEM_DATA_PIPE_PRODUCER_DISPATCHER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
16 #include "mojo/edk/embedder/platform_handle_vector.h" | 16 #include "mojo/edk/embedder/platform_handle_vector.h" |
17 #include "mojo/edk/embedder/platform_shared_buffer.h" | 17 #include "mojo/edk/embedder/platform_shared_buffer.h" |
18 #include "mojo/edk/system/awakable_list.h" | |
19 #include "mojo/edk/system/dispatcher.h" | 18 #include "mojo/edk/system/dispatcher.h" |
20 #include "mojo/edk/system/ports/port_ref.h" | 19 #include "mojo/edk/system/ports/port_ref.h" |
21 #include "mojo/edk/system/system_impl_export.h" | 20 #include "mojo/edk/system/system_impl_export.h" |
22 #include "mojo/edk/system/watcher_set.h" | 21 #include "mojo/edk/system/watcher_set.h" |
23 | 22 |
24 namespace mojo { | 23 namespace mojo { |
25 namespace edk { | 24 namespace edk { |
26 | 25 |
27 struct DataPipeControlMessage; | 26 struct DataPipeControlMessage; |
28 class NodeController; | 27 class NodeController; |
(...skipping 20 matching lines...) Expand all Loading... |
49 MojoReadDataFlags flags) override; | 48 MojoReadDataFlags flags) override; |
50 MojoResult BeginWriteData(void** buffer, | 49 MojoResult BeginWriteData(void** buffer, |
51 uint32_t* buffer_num_bytes, | 50 uint32_t* buffer_num_bytes, |
52 MojoWriteDataFlags flags) override; | 51 MojoWriteDataFlags flags) override; |
53 MojoResult EndWriteData(uint32_t num_bytes_written) override; | 52 MojoResult EndWriteData(uint32_t num_bytes_written) override; |
54 HandleSignalsState GetHandleSignalsState() const override; | 53 HandleSignalsState GetHandleSignalsState() const override; |
55 MojoResult AddWatcherRef(const scoped_refptr<WatcherDispatcher>& watcher, | 54 MojoResult AddWatcherRef(const scoped_refptr<WatcherDispatcher>& watcher, |
56 uintptr_t context) override; | 55 uintptr_t context) override; |
57 MojoResult RemoveWatcherRef(WatcherDispatcher* watcher, | 56 MojoResult RemoveWatcherRef(WatcherDispatcher* watcher, |
58 uintptr_t context) override; | 57 uintptr_t context) override; |
59 MojoResult AddAwakable(Awakable* awakable, | |
60 MojoHandleSignals signals, | |
61 uintptr_t context, | |
62 HandleSignalsState* signals_state) override; | |
63 void RemoveAwakable(Awakable* awakable, | |
64 HandleSignalsState* signals_state) override; | |
65 void StartSerialize(uint32_t* num_bytes, | 58 void StartSerialize(uint32_t* num_bytes, |
66 uint32_t* num_ports, | 59 uint32_t* num_ports, |
67 uint32_t* num_handles) override; | 60 uint32_t* num_handles) override; |
68 bool EndSerialize(void* destination, | 61 bool EndSerialize(void* destination, |
69 ports::PortName* ports, | 62 ports::PortName* ports, |
70 PlatformHandle* handles) override; | 63 PlatformHandle* handles) override; |
71 bool BeginTransit() override; | 64 bool BeginTransit() override; |
72 void CompleteTransitAndClose() override; | 65 void CompleteTransitAndClose() override; |
73 void CancelTransit() override; | 66 void CancelTransit() override; |
74 | 67 |
(...skipping 22 matching lines...) Expand all Loading... |
97 ScopedPlatformHandleVectorPtr handles); | 90 ScopedPlatformHandleVectorPtr handles); |
98 | 91 |
99 const MojoCreateDataPipeOptions options_; | 92 const MojoCreateDataPipeOptions options_; |
100 NodeController* const node_controller_; | 93 NodeController* const node_controller_; |
101 const ports::PortRef control_port_; | 94 const ports::PortRef control_port_; |
102 const uint64_t pipe_id_; | 95 const uint64_t pipe_id_; |
103 | 96 |
104 // Guards access to the fields below. | 97 // Guards access to the fields below. |
105 mutable base::Lock lock_; | 98 mutable base::Lock lock_; |
106 | 99 |
107 AwakableList awakable_list_; | |
108 WatcherSet watchers_; | 100 WatcherSet watchers_; |
109 | 101 |
110 bool buffer_requested_ = false; | 102 bool buffer_requested_ = false; |
111 | 103 |
112 scoped_refptr<PlatformSharedBuffer> shared_ring_buffer_; | 104 scoped_refptr<PlatformSharedBuffer> shared_ring_buffer_; |
113 std::unique_ptr<PlatformSharedBufferMapping> ring_buffer_mapping_; | 105 std::unique_ptr<PlatformSharedBufferMapping> ring_buffer_mapping_; |
114 ScopedPlatformHandle buffer_handle_for_transit_; | 106 ScopedPlatformHandle buffer_handle_for_transit_; |
115 | 107 |
116 bool in_transit_ = false; | 108 bool in_transit_ = false; |
117 bool is_closed_ = false; | 109 bool is_closed_ = false; |
118 bool peer_closed_ = false; | 110 bool peer_closed_ = false; |
119 bool transferred_ = false; | 111 bool transferred_ = false; |
120 bool in_two_phase_write_ = false; | 112 bool in_two_phase_write_ = false; |
121 | 113 |
122 uint32_t write_offset_ = 0; | 114 uint32_t write_offset_ = 0; |
123 uint32_t available_capacity_; | 115 uint32_t available_capacity_; |
124 | 116 |
125 DISALLOW_COPY_AND_ASSIGN(DataPipeProducerDispatcher); | 117 DISALLOW_COPY_AND_ASSIGN(DataPipeProducerDispatcher); |
126 }; | 118 }; |
127 | 119 |
128 } // namespace edk | 120 } // namespace edk |
129 } // namespace mojo | 121 } // namespace mojo |
130 | 122 |
131 #endif // MOJO_EDK_SYSTEM_DATA_PIPE_PRODUCER_DISPATCHER_H_ | 123 #endif // MOJO_EDK_SYSTEM_DATA_PIPE_PRODUCER_DISPATCHER_H_ |
OLD | NEW |