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" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
14 #include "mojo/public/c/system/data_pipe.h" | 14 #include "mojo/public/c/system/data_pipe.h" |
15 #include "mojo/public/c/system/types.h" | 15 #include "mojo/public/c/system/types.h" |
16 #include "mojo/system/handle_signals_state.h" | 16 #include "mojo/system/handle_signals_state.h" |
| 17 #include "mojo/system/memory.h" |
17 #include "mojo/system/system_impl_export.h" | 18 #include "mojo/system/system_impl_export.h" |
18 | 19 |
19 namespace mojo { | 20 namespace mojo { |
20 namespace system { | 21 namespace system { |
21 | 22 |
22 class Waiter; | 23 class Waiter; |
23 class WaiterList; | 24 class WaiterList; |
24 | 25 |
25 // |DataPipe| is a base class for secondary objects implementing data pipes, | 26 // |DataPipe| is a base class for secondary objects implementing data pipes, |
26 // similar to |MessagePipe| (see the explanatory comment in core.cc). It is | 27 // similar to |MessagePipe| (see the explanatory comment in core.cc). It is |
(...skipping 20 matching lines...) Expand all Loading... |
47 | 48 |
48 // These are called by the producer dispatcher to implement its methods of | 49 // These are called by the producer dispatcher to implement its methods of |
49 // corresponding names. | 50 // corresponding names. |
50 void ProducerCancelAllWaiters(); | 51 void ProducerCancelAllWaiters(); |
51 void ProducerClose(); | 52 void ProducerClose(); |
52 // This does not validate its arguments, except to check that |*num_bytes| is | 53 // This does not validate its arguments, except to check that |*num_bytes| is |
53 // a multiple of |element_num_bytes_|. | 54 // a multiple of |element_num_bytes_|. |
54 MojoResult ProducerWriteData(const void* elements, | 55 MojoResult ProducerWriteData(const void* elements, |
55 uint32_t* num_bytes, | 56 uint32_t* num_bytes, |
56 bool all_or_none); | 57 bool all_or_none); |
57 // This does not validate its arguments. | 58 MojoResult ProducerBeginWriteData(UserPointer<void*> buffer, |
58 MojoResult ProducerBeginWriteData(void** buffer, | 59 UserPointer<uint32_t> buffer_num_bytes, |
59 uint32_t* buffer_num_bytes, | |
60 bool all_or_none); | 60 bool all_or_none); |
61 MojoResult ProducerEndWriteData(uint32_t num_bytes_written); | 61 MojoResult ProducerEndWriteData(uint32_t num_bytes_written); |
62 MojoResult ProducerAddWaiter(Waiter* waiter, | 62 MojoResult ProducerAddWaiter(Waiter* waiter, |
63 MojoHandleSignals signals, | 63 MojoHandleSignals signals, |
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. |
(...skipping 25 matching lines...) Expand all Loading... |
95 | 95 |
96 friend class base::RefCountedThreadSafe<DataPipe>; | 96 friend class base::RefCountedThreadSafe<DataPipe>; |
97 virtual ~DataPipe(); | 97 virtual ~DataPipe(); |
98 | 98 |
99 virtual void ProducerCloseImplNoLock() = 0; | 99 virtual void ProducerCloseImplNoLock() = 0; |
100 // |*num_bytes| will be a nonzero multiple of |element_num_bytes_|. | 100 // |*num_bytes| will be a nonzero multiple of |element_num_bytes_|. |
101 virtual MojoResult ProducerWriteDataImplNoLock(const void* elements, | 101 virtual MojoResult ProducerWriteDataImplNoLock(const void* elements, |
102 uint32_t* num_bytes, | 102 uint32_t* num_bytes, |
103 bool all_or_none) = 0; | 103 bool all_or_none) = 0; |
104 virtual MojoResult ProducerBeginWriteDataImplNoLock( | 104 virtual MojoResult ProducerBeginWriteDataImplNoLock( |
105 void** buffer, | 105 UserPointer<void*> buffer, |
106 uint32_t* buffer_num_bytes, | 106 UserPointer<uint32_t> buffer_num_bytes, |
107 bool all_or_none) = 0; | 107 uint32_t min_num_bytes_to_write) = 0; |
108 virtual MojoResult ProducerEndWriteDataImplNoLock( | 108 virtual MojoResult ProducerEndWriteDataImplNoLock( |
109 uint32_t num_bytes_written) = 0; | 109 uint32_t num_bytes_written) = 0; |
110 // Note: A producer should not be writable during a two-phase write. | 110 // Note: A producer should not be writable during a two-phase write. |
111 virtual HandleSignalsState ProducerGetHandleSignalsStateNoLock() const = 0; | 111 virtual HandleSignalsState ProducerGetHandleSignalsStateNoLock() const = 0; |
112 | 112 |
113 virtual void ConsumerCloseImplNoLock() = 0; | 113 virtual void ConsumerCloseImplNoLock() = 0; |
114 // |*num_bytes| will be a nonzero multiple of |element_num_bytes_|. | 114 // |*num_bytes| will be a nonzero multiple of |element_num_bytes_|. |
115 virtual MojoResult ConsumerReadDataImplNoLock(void* elements, | 115 virtual MojoResult ConsumerReadDataImplNoLock(void* elements, |
116 uint32_t* num_bytes, | 116 uint32_t* num_bytes, |
117 bool all_or_none) = 0; | 117 bool all_or_none) = 0; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 uint32_t producer_two_phase_max_num_bytes_written_; | 196 uint32_t producer_two_phase_max_num_bytes_written_; |
197 uint32_t consumer_two_phase_max_num_bytes_read_; | 197 uint32_t consumer_two_phase_max_num_bytes_read_; |
198 | 198 |
199 DISALLOW_COPY_AND_ASSIGN(DataPipe); | 199 DISALLOW_COPY_AND_ASSIGN(DataPipe); |
200 }; | 200 }; |
201 | 201 |
202 } // namespace system | 202 } // namespace system |
203 } // namespace mojo | 203 } // namespace mojo |
204 | 204 |
205 #endif // MOJO_SYSTEM_DATA_PIPE_H_ | 205 #endif // MOJO_SYSTEM_DATA_PIPE_H_ |
OLD | NEW |