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_CONSUMER_DISPATCHER_H_ | 5 #ifndef MOJO_EDK_SYSTEM_DATA_PIPE_CONSUMER_DISPATCHER_H_ |
6 #define MOJO_EDK_SYSTEM_DATA_PIPE_CONSUMER_DISPATCHER_H_ | 6 #define MOJO_EDK_SYSTEM_DATA_PIPE_CONSUMER_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/embedder/scoped_platform_handle.h" | 18 #include "mojo/edk/embedder/scoped_platform_handle.h" |
19 #include "mojo/edk/system/awakable_list.h" | |
20 #include "mojo/edk/system/dispatcher.h" | 19 #include "mojo/edk/system/dispatcher.h" |
21 #include "mojo/edk/system/ports/port_ref.h" | 20 #include "mojo/edk/system/ports/port_ref.h" |
22 #include "mojo/edk/system/system_impl_export.h" | 21 #include "mojo/edk/system/system_impl_export.h" |
23 #include "mojo/edk/system/watcher_set.h" | 22 #include "mojo/edk/system/watcher_set.h" |
24 | 23 |
25 namespace mojo { | 24 namespace mojo { |
26 namespace edk { | 25 namespace edk { |
27 | 26 |
28 class NodeController; | 27 class NodeController; |
29 | 28 |
(...skipping 19 matching lines...) Expand all Loading... |
49 MojoReadDataFlags flags) override; | 48 MojoReadDataFlags flags) override; |
50 MojoResult BeginReadData(const void** buffer, | 49 MojoResult BeginReadData(const void** buffer, |
51 uint32_t* buffer_num_bytes, | 50 uint32_t* buffer_num_bytes, |
52 MojoReadDataFlags flags) override; | 51 MojoReadDataFlags flags) override; |
53 MojoResult EndReadData(uint32_t num_bytes_read) override; | 52 MojoResult EndReadData(uint32_t num_bytes_read) 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 19 matching lines...) Expand all Loading... |
94 void UpdateSignalsStateNoLock(); | 87 void UpdateSignalsStateNoLock(); |
95 | 88 |
96 const MojoCreateDataPipeOptions options_; | 89 const MojoCreateDataPipeOptions options_; |
97 NodeController* const node_controller_; | 90 NodeController* const node_controller_; |
98 const ports::PortRef control_port_; | 91 const ports::PortRef control_port_; |
99 const uint64_t pipe_id_; | 92 const uint64_t pipe_id_; |
100 | 93 |
101 // Guards access to the fields below. | 94 // Guards access to the fields below. |
102 mutable base::Lock lock_; | 95 mutable base::Lock lock_; |
103 | 96 |
104 AwakableList awakable_list_; | |
105 WatcherSet watchers_; | 97 WatcherSet watchers_; |
106 | 98 |
107 scoped_refptr<PlatformSharedBuffer> shared_ring_buffer_; | 99 scoped_refptr<PlatformSharedBuffer> shared_ring_buffer_; |
108 std::unique_ptr<PlatformSharedBufferMapping> ring_buffer_mapping_; | 100 std::unique_ptr<PlatformSharedBufferMapping> ring_buffer_mapping_; |
109 ScopedPlatformHandle buffer_handle_for_transit_; | 101 ScopedPlatformHandle buffer_handle_for_transit_; |
110 | 102 |
111 bool in_two_phase_read_ = false; | 103 bool in_two_phase_read_ = false; |
112 uint32_t two_phase_max_bytes_read_ = 0; | 104 uint32_t two_phase_max_bytes_read_ = 0; |
113 | 105 |
114 bool in_transit_ = false; | 106 bool in_transit_ = false; |
115 bool is_closed_ = false; | 107 bool is_closed_ = false; |
116 bool peer_closed_ = false; | 108 bool peer_closed_ = false; |
117 bool transferred_ = false; | 109 bool transferred_ = false; |
118 | 110 |
119 uint32_t read_offset_ = 0; | 111 uint32_t read_offset_ = 0; |
120 uint32_t bytes_available_ = 0; | 112 uint32_t bytes_available_ = 0; |
121 | 113 |
122 // Indicates whether any new data is available since the last read attempt. | 114 // Indicates whether any new data is available since the last read attempt. |
123 bool new_data_available_ = false; | 115 bool new_data_available_ = false; |
124 | 116 |
125 DISALLOW_COPY_AND_ASSIGN(DataPipeConsumerDispatcher); | 117 DISALLOW_COPY_AND_ASSIGN(DataPipeConsumerDispatcher); |
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_CONSUMER_DISPATCHER_H_ | 123 #endif // MOJO_EDK_SYSTEM_DATA_PIPE_CONSUMER_DISPATCHER_H_ |
OLD | NEW |