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_SYSTEM_DATA_PIPE_H_ | 5 #ifndef MOJO_SYSTEM_DATA_PIPE_H_ |
6 #define MOJO_SYSTEM_DATA_PIPE_H_ | 6 #define MOJO_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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 uint32_t context); | 64 uint32_t context); |
65 void ProducerRemoveWaiter(Waiter* waiter); | 65 void ProducerRemoveWaiter(Waiter* waiter); |
66 bool ProducerIsBusy() const; | 66 bool ProducerIsBusy() const; |
67 | 67 |
68 // These are called by the consumer dispatcher to implement its methods of | 68 // These are called by the consumer dispatcher to implement its methods of |
69 // corresponding names. | 69 // corresponding names. |
70 void ConsumerCancelAllWaiters(); | 70 void ConsumerCancelAllWaiters(); |
71 void ConsumerClose(); | 71 void ConsumerClose(); |
72 // This does not validate its arguments, except to check that |*num_bytes| is | 72 // This does not validate its arguments, except to check that |*num_bytes| is |
73 // a multiple of |element_num_bytes_|. | 73 // a multiple of |element_num_bytes_|. |
74 MojoResult ConsumerReadData(void* elements, | 74 MojoResult ConsumerReadData(UserPointer<void> elements, |
75 uint32_t* num_bytes, | 75 UserPointer<uint32_t> num_bytes, |
76 bool all_or_none); | 76 bool all_or_none); |
77 MojoResult ConsumerDiscardData(uint32_t* num_bytes, | 77 MojoResult ConsumerDiscardData(UserPointer<uint32_t> num_bytes, |
78 bool all_or_none); | 78 bool all_or_none); |
79 MojoResult ConsumerQueryData(uint32_t* num_bytes); | 79 MojoResult ConsumerQueryData(UserPointer<uint32_t> num_bytes); |
80 MojoResult ConsumerBeginReadData(UserPointer<const void*> buffer, | 80 MojoResult ConsumerBeginReadData(UserPointer<const void*> buffer, |
81 UserPointer<uint32_t> buffer_num_bytes, | 81 UserPointer<uint32_t> buffer_num_bytes, |
82 bool all_or_none); | 82 bool all_or_none); |
83 MojoResult ConsumerEndReadData(uint32_t num_bytes_read); | 83 MojoResult ConsumerEndReadData(uint32_t num_bytes_read); |
84 MojoResult ConsumerAddWaiter(Waiter* waiter, | 84 MojoResult ConsumerAddWaiter(Waiter* waiter, |
85 MojoHandleSignals signals, | 85 MojoHandleSignals signals, |
86 uint32_t context); | 86 uint32_t context); |
87 void ConsumerRemoveWaiter(Waiter* waiter); | 87 void ConsumerRemoveWaiter(Waiter* waiter); |
88 bool ConsumerIsBusy() const; | 88 bool ConsumerIsBusy() const; |
89 | 89 |
(...skipping 14 matching lines...) Expand all Loading... |
104 UserPointer<void*> buffer, | 104 UserPointer<void*> buffer, |
105 UserPointer<uint32_t> buffer_num_bytes, | 105 UserPointer<uint32_t> buffer_num_bytes, |
106 uint32_t min_num_bytes_to_write) = 0; | 106 uint32_t min_num_bytes_to_write) = 0; |
107 virtual MojoResult ProducerEndWriteDataImplNoLock( | 107 virtual MojoResult ProducerEndWriteDataImplNoLock( |
108 uint32_t num_bytes_written) = 0; | 108 uint32_t num_bytes_written) = 0; |
109 // Note: A producer should not be writable during a two-phase write. | 109 // Note: A producer should not be writable during a two-phase write. |
110 virtual HandleSignalsState ProducerGetHandleSignalsStateNoLock() const = 0; | 110 virtual HandleSignalsState ProducerGetHandleSignalsStateNoLock() const = 0; |
111 | 111 |
112 virtual void ConsumerCloseImplNoLock() = 0; | 112 virtual void ConsumerCloseImplNoLock() = 0; |
113 // |*num_bytes| will be a nonzero multiple of |element_num_bytes_|. | 113 // |*num_bytes| will be a nonzero multiple of |element_num_bytes_|. |
114 virtual MojoResult ConsumerReadDataImplNoLock(void* elements, | 114 virtual MojoResult ConsumerReadDataImplNoLock( |
115 uint32_t* num_bytes, | 115 UserPointer<void> elements, |
116 bool all_or_none) = 0; | 116 UserPointer<uint32_t> num_bytes, |
117 virtual MojoResult ConsumerDiscardDataImplNoLock(uint32_t* num_bytes, | 117 uint32_t max_num_bytes_to_read, |
118 bool all_or_none) = 0; | 118 uint32_t min_num_bytes_to_read) = 0; |
| 119 virtual MojoResult ConsumerDiscardDataImplNoLock( |
| 120 UserPointer<uint32_t> num_bytes, |
| 121 uint32_t max_num_bytes_to_discard, |
| 122 uint32_t min_num_bytes_to_discard) = 0; |
119 // |*num_bytes| will be a nonzero multiple of |element_num_bytes_|. | 123 // |*num_bytes| will be a nonzero multiple of |element_num_bytes_|. |
120 virtual MojoResult ConsumerQueryDataImplNoLock(uint32_t* num_bytes) = 0; | 124 virtual MojoResult ConsumerQueryDataImplNoLock( |
| 125 UserPointer<uint32_t> num_bytes) = 0; |
121 virtual MojoResult ConsumerBeginReadDataImplNoLock( | 126 virtual MojoResult ConsumerBeginReadDataImplNoLock( |
122 UserPointer<const void*> buffer, | 127 UserPointer<const void*> buffer, |
123 UserPointer<uint32_t> buffer_num_bytes, | 128 UserPointer<uint32_t> buffer_num_bytes, |
124 uint32_t min_num_bytes_to_read) = 0; | 129 uint32_t min_num_bytes_to_read) = 0; |
125 virtual MojoResult ConsumerEndReadDataImplNoLock(uint32_t num_bytes_read) = 0; | 130 virtual MojoResult ConsumerEndReadDataImplNoLock(uint32_t num_bytes_read) = 0; |
126 // Note: A consumer should not be writable during a two-phase read. | 131 // Note: A consumer should not be writable during a two-phase read. |
127 virtual HandleSignalsState ConsumerGetHandleSignalsStateNoLock() const = 0; | 132 virtual HandleSignalsState ConsumerGetHandleSignalsStateNoLock() const = 0; |
128 | 133 |
129 // Thread-safe and fast (they don't take the lock): | 134 // Thread-safe and fast (they don't take the lock): |
130 bool may_discard() const { return may_discard_; } | 135 bool may_discard() const { return may_discard_; } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 uint32_t producer_two_phase_max_num_bytes_written_; | 201 uint32_t producer_two_phase_max_num_bytes_written_; |
197 uint32_t consumer_two_phase_max_num_bytes_read_; | 202 uint32_t consumer_two_phase_max_num_bytes_read_; |
198 | 203 |
199 DISALLOW_COPY_AND_ASSIGN(DataPipe); | 204 DISALLOW_COPY_AND_ASSIGN(DataPipe); |
200 }; | 205 }; |
201 | 206 |
202 } // namespace system | 207 } // namespace system |
203 } // namespace mojo | 208 } // namespace mojo |
204 | 209 |
205 #endif // MOJO_SYSTEM_DATA_PIPE_H_ | 210 #endif // MOJO_SYSTEM_DATA_PIPE_H_ |
OLD | NEW |