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_H_ | 5 #ifndef MOJO_EDK_SYSTEM_DATA_PIPE_H_ |
6 #define MOJO_EDK_SYSTEM_DATA_PIPE_H_ | 6 #define MOJO_EDK_SYSTEM_DATA_PIPE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 // typically owned by the dispatcher(s) corresponding to the local endpoints. | 28 // typically owned by the dispatcher(s) corresponding to the local endpoints. |
29 // Its subclasses implement the three cases: local producer and consumer, local | 29 // Its subclasses implement the three cases: local producer and consumer, local |
30 // producer and remote consumer, and remote producer and local consumer. This | 30 // producer and remote consumer, and remote producer and local consumer. This |
31 // class is thread-safe. | 31 // class is thread-safe. |
32 class MOJO_SYSTEM_IMPL_EXPORT DataPipe | 32 class MOJO_SYSTEM_IMPL_EXPORT DataPipe |
33 : public base::RefCountedThreadSafe<DataPipe> { | 33 : public base::RefCountedThreadSafe<DataPipe> { |
34 public: | 34 public: |
35 // The default options for |MojoCreateDataPipe()|. (Real uses should obtain | 35 // The default options for |MojoCreateDataPipe()|. (Real uses should obtain |
36 // this via |ValidateCreateOptions()| with a null |in_options|; this is | 36 // this via |ValidateCreateOptions()| with a null |in_options|; this is |
37 // exposed directly for testing convenience.) | 37 // exposed directly for testing convenience.) |
38 static MojoCreateDataPipeOptions GetDefaultCreateOptions(); | 38 static const MojoCreateDataPipeOptions kDefaultCreateOptions; |
39 | 39 |
40 // Validates and/or sets default options for |MojoCreateDataPipeOptions|. If | 40 // Validates and/or sets default options for |MojoCreateDataPipeOptions|. If |
41 // non-null, |in_options| must point to a struct of at least | 41 // non-null, |in_options| must point to a struct of at least |
42 // |in_options->struct_size| bytes. |out_options| must point to a (current) | 42 // |in_options->struct_size| bytes. |out_options| must point to a (current) |
43 // |MojoCreateDataPipeOptions| and will be entirely overwritten on success (it | 43 // |MojoCreateDataPipeOptions| and will be entirely overwritten on success (it |
44 // may be partly overwritten on failure). | 44 // may be partly overwritten on failure). |
45 static MojoResult ValidateCreateOptions( | 45 static MojoResult ValidateCreateOptions( |
46 UserPointer<const MojoCreateDataPipeOptions> in_options, | 46 UserPointer<const MojoCreateDataPipeOptions> in_options, |
47 MojoCreateDataPipeOptions* out_options); | 47 MojoCreateDataPipeOptions* out_options); |
48 | 48 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 UserPointer<uint32_t> buffer_num_bytes, | 110 UserPointer<uint32_t> buffer_num_bytes, |
111 uint32_t min_num_bytes_to_write) = 0; | 111 uint32_t min_num_bytes_to_write) = 0; |
112 virtual MojoResult ProducerEndWriteDataImplNoLock( | 112 virtual MojoResult ProducerEndWriteDataImplNoLock( |
113 uint32_t num_bytes_written) = 0; | 113 uint32_t num_bytes_written) = 0; |
114 // Note: A producer should not be writable during a two-phase write. | 114 // Note: A producer should not be writable during a two-phase write. |
115 virtual HandleSignalsState ProducerGetHandleSignalsStateImplNoLock() | 115 virtual HandleSignalsState ProducerGetHandleSignalsStateImplNoLock() |
116 const = 0; | 116 const = 0; |
117 | 117 |
118 virtual void ConsumerCloseImplNoLock() = 0; | 118 virtual void ConsumerCloseImplNoLock() = 0; |
119 // |*num_bytes| will be a nonzero multiple of |element_num_bytes_|. | 119 // |*num_bytes| will be a nonzero multiple of |element_num_bytes_|. |
120 virtual MojoResult ConsumerReadDataImplNoLock(UserPointer<void> elements, | 120 virtual MojoResult ConsumerReadDataImplNoLock( |
121 UserPointer<uint32_t> num_bytes, | 121 UserPointer<void> elements, |
122 uint32_t max_num_bytes_to_read, | 122 UserPointer<uint32_t> num_bytes, |
123 uint32_t min_num_bytes_to_read, | 123 uint32_t max_num_bytes_to_read, |
124 bool peek) = 0; | 124 uint32_t min_num_bytes_to_read, |
| 125 bool peek) = 0; |
125 virtual MojoResult ConsumerDiscardDataImplNoLock( | 126 virtual MojoResult ConsumerDiscardDataImplNoLock( |
126 UserPointer<uint32_t> num_bytes, | 127 UserPointer<uint32_t> num_bytes, |
127 uint32_t max_num_bytes_to_discard, | 128 uint32_t max_num_bytes_to_discard, |
128 uint32_t min_num_bytes_to_discard) = 0; | 129 uint32_t min_num_bytes_to_discard) = 0; |
129 // |*num_bytes| will be a nonzero multiple of |element_num_bytes_|. | 130 // |*num_bytes| will be a nonzero multiple of |element_num_bytes_|. |
130 virtual MojoResult ConsumerQueryDataImplNoLock( | 131 virtual MojoResult ConsumerQueryDataImplNoLock( |
131 UserPointer<uint32_t> num_bytes) = 0; | 132 UserPointer<uint32_t> num_bytes) = 0; |
132 virtual MojoResult ConsumerBeginReadDataImplNoLock( | 133 virtual MojoResult ConsumerBeginReadDataImplNoLock( |
133 UserPointer<const void*> buffer, | 134 UserPointer<const void*> buffer, |
134 UserPointer<uint32_t> buffer_num_bytes, | 135 UserPointer<uint32_t> buffer_num_bytes, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 uint32_t producer_two_phase_max_num_bytes_written_; | 209 uint32_t producer_two_phase_max_num_bytes_written_; |
209 uint32_t consumer_two_phase_max_num_bytes_read_; | 210 uint32_t consumer_two_phase_max_num_bytes_read_; |
210 | 211 |
211 DISALLOW_COPY_AND_ASSIGN(DataPipe); | 212 DISALLOW_COPY_AND_ASSIGN(DataPipe); |
212 }; | 213 }; |
213 | 214 |
214 } // namespace system | 215 } // namespace system |
215 } // namespace mojo | 216 } // namespace mojo |
216 | 217 |
217 #endif // MOJO_EDK_SYSTEM_DATA_PIPE_H_ | 218 #endif // MOJO_EDK_SYSTEM_DATA_PIPE_H_ |
OLD | NEW |