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_DATA_PIPE_IMPL_H_ | 5 #ifndef MOJO_EDK_SYSTEM_DATA_PIPE_IMPL_H_ |
6 #define MOJO_EDK_SYSTEM_DATA_PIPE_IMPL_H_ | 6 #define MOJO_EDK_SYSTEM_DATA_PIPE_IMPL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <utility> | 10 #include <utility> |
| 11 #include <vector> |
11 | 12 |
12 #include "mojo/edk/embedder/platform_handle_vector.h" | 13 #include "mojo/edk/embedder/scoped_platform_handle.h" |
13 #include "mojo/edk/system/data_pipe.h" | 14 #include "mojo/edk/system/data_pipe.h" |
14 #include "mojo/edk/system/handle_signals_state.h" | 15 #include "mojo/edk/system/handle_signals_state.h" |
15 #include "mojo/edk/system/memory.h" | 16 #include "mojo/edk/system/memory.h" |
16 #include "mojo/edk/util/thread_annotations.h" | 17 #include "mojo/edk/util/thread_annotations.h" |
17 #include "mojo/public/c/system/data_pipe.h" | 18 #include "mojo/public/c/system/data_pipe.h" |
18 #include "mojo/public/c/system/macros.h" | 19 #include "mojo/public/c/system/macros.h" |
19 #include "mojo/public/c/system/types.h" | 20 #include "mojo/public/c/system/types.h" |
20 | 21 |
21 namespace mojo { | 22 namespace mojo { |
22 namespace system { | 23 namespace system { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 virtual MojoResult ProducerEndWriteData(uint32_t num_bytes_written) = 0; | 69 virtual MojoResult ProducerEndWriteData(uint32_t num_bytes_written) = 0; |
69 // Note: A producer should not be writable during a two-phase write. | 70 // Note: A producer should not be writable during a two-phase write. |
70 virtual HandleSignalsState ProducerGetHandleSignalsState() const = 0; | 71 virtual HandleSignalsState ProducerGetHandleSignalsState() const = 0; |
71 virtual void ProducerStartSerialize(Channel* channel, | 72 virtual void ProducerStartSerialize(Channel* channel, |
72 size_t* max_size, | 73 size_t* max_size, |
73 size_t* max_platform_handles) = 0; | 74 size_t* max_platform_handles) = 0; |
74 virtual bool ProducerEndSerialize( | 75 virtual bool ProducerEndSerialize( |
75 Channel* channel, | 76 Channel* channel, |
76 void* destination, | 77 void* destination, |
77 size_t* actual_size, | 78 size_t* actual_size, |
78 embedder::PlatformHandleVector* platform_handles) = 0; | 79 std::vector<embedder::ScopedPlatformHandle>* platform_handles) = 0; |
79 | 80 |
80 virtual void ConsumerClose() = 0; | 81 virtual void ConsumerClose() = 0; |
81 // |num_bytes.Get()| will be a nonzero multiple of |element_num_bytes()|. | 82 // |num_bytes.Get()| will be a nonzero multiple of |element_num_bytes()|. |
82 virtual MojoResult ConsumerReadData(UserPointer<void> elements, | 83 virtual MojoResult ConsumerReadData(UserPointer<void> elements, |
83 UserPointer<uint32_t> num_bytes, | 84 UserPointer<uint32_t> num_bytes, |
84 uint32_t max_num_bytes_to_read, | 85 uint32_t max_num_bytes_to_read, |
85 uint32_t min_num_bytes_to_read, | 86 uint32_t min_num_bytes_to_read, |
86 bool peek) = 0; | 87 bool peek) = 0; |
87 virtual MojoResult ConsumerDiscardData(UserPointer<uint32_t> num_bytes, | 88 virtual MojoResult ConsumerDiscardData(UserPointer<uint32_t> num_bytes, |
88 uint32_t max_num_bytes_to_discard, | 89 uint32_t max_num_bytes_to_discard, |
89 uint32_t min_num_bytes_to_discard) = 0; | 90 uint32_t min_num_bytes_to_discard) = 0; |
90 // |num_bytes.Get()| will be a nonzero multiple of |element_num_bytes()|. | 91 // |num_bytes.Get()| will be a nonzero multiple of |element_num_bytes()|. |
91 virtual MojoResult ConsumerQueryData(UserPointer<uint32_t> num_bytes) = 0; | 92 virtual MojoResult ConsumerQueryData(UserPointer<uint32_t> num_bytes) = 0; |
92 virtual MojoResult ConsumerBeginReadData( | 93 virtual MojoResult ConsumerBeginReadData( |
93 UserPointer<const void*> buffer, | 94 UserPointer<const void*> buffer, |
94 UserPointer<uint32_t> buffer_num_bytes) = 0; | 95 UserPointer<uint32_t> buffer_num_bytes) = 0; |
95 virtual MojoResult ConsumerEndReadData(uint32_t num_bytes_read) = 0; | 96 virtual MojoResult ConsumerEndReadData(uint32_t num_bytes_read) = 0; |
96 // Note: A consumer should not be writable during a two-phase read. | 97 // Note: A consumer should not be writable during a two-phase read. |
97 virtual HandleSignalsState ConsumerGetHandleSignalsState() const = 0; | 98 virtual HandleSignalsState ConsumerGetHandleSignalsState() const = 0; |
98 virtual void ConsumerStartSerialize(Channel* channel, | 99 virtual void ConsumerStartSerialize(Channel* channel, |
99 size_t* max_size, | 100 size_t* max_size, |
100 size_t* max_platform_handles) = 0; | 101 size_t* max_platform_handles) = 0; |
101 virtual bool ConsumerEndSerialize( | 102 virtual bool ConsumerEndSerialize( |
102 Channel* channel, | 103 Channel* channel, |
103 void* destination, | 104 void* destination, |
104 size_t* actual_size, | 105 size_t* actual_size, |
105 embedder::PlatformHandleVector* platform_handles) = 0; | 106 std::vector<embedder::ScopedPlatformHandle>* platform_handles) = 0; |
106 | 107 |
107 virtual bool OnReadMessage(unsigned port, MessageInTransit* message) = 0; | 108 virtual bool OnReadMessage(unsigned port, MessageInTransit* message) = 0; |
108 virtual void OnDetachFromChannel(unsigned port) = 0; | 109 virtual void OnDetachFromChannel(unsigned port) = 0; |
109 | 110 |
110 protected: | 111 protected: |
111 DataPipeImpl() : owner_() {} | 112 DataPipeImpl() : owner_() {} |
112 | 113 |
113 // Helper to convert the given circular buffer into messages. The input is a | 114 // Helper to convert the given circular buffer into messages. The input is a |
114 // circular buffer |buffer| (with appropriate element size and capacity), with | 115 // circular buffer |buffer| (with appropriate element size and capacity), with |
115 // current contents starting at |start_index| of length |current_num_bytes|. | 116 // current contents starting at |start_index| of length |current_num_bytes|. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 struct MOJO_ALIGNAS(8) SerializedDataPipeConsumerDispatcher { | 193 struct MOJO_ALIGNAS(8) SerializedDataPipeConsumerDispatcher { |
193 // Only validated (and thus canonicalized) options should be serialized. | 194 // Only validated (and thus canonicalized) options should be serialized. |
194 // However, the deserializer must revalidate (as with everything received). | 195 // However, the deserializer must revalidate (as with everything received). |
195 MojoCreateDataPipeOptions validated_options; | 196 MojoCreateDataPipeOptions validated_options; |
196 }; | 197 }; |
197 | 198 |
198 } // namespace system | 199 } // namespace system |
199 } // namespace mojo | 200 } // namespace mojo |
200 | 201 |
201 #endif // MOJO_EDK_SYSTEM_DATA_PIPE_IMPL_H_ | 202 #endif // MOJO_EDK_SYSTEM_DATA_PIPE_IMPL_H_ |
OLD | NEW |