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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 const MojoCreateDataPipeOptions* in_options, | 46 const MojoCreateDataPipeOptions* in_options, |
47 MojoCreateDataPipeOptions* out_options); | 47 MojoCreateDataPipeOptions* out_options); |
48 | 48 |
49 // 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 |
50 // corresponding names. | 50 // corresponding names. |
51 void ProducerCancelAllWaiters(); | 51 void ProducerCancelAllWaiters(); |
52 void ProducerClose(); | 52 void ProducerClose(); |
53 // This does not validate its arguments, except to check that |*num_bytes| is | 53 MojoResult ProducerWriteData(UserPointer<const void> elements, |
54 // a multiple of |element_num_bytes_|. | 54 UserPointer<uint32_t> num_bytes, |
55 MojoResult ProducerWriteData(const void* elements, | |
56 uint32_t* num_bytes, | |
57 bool all_or_none); | 55 bool all_or_none); |
58 MojoResult ProducerBeginWriteData(UserPointer<void*> buffer, | 56 MojoResult ProducerBeginWriteData(UserPointer<void*> buffer, |
59 UserPointer<uint32_t> buffer_num_bytes, | 57 UserPointer<uint32_t> buffer_num_bytes, |
60 bool all_or_none); | 58 bool all_or_none); |
61 MojoResult ProducerEndWriteData(uint32_t num_bytes_written); | 59 MojoResult ProducerEndWriteData(uint32_t num_bytes_written); |
62 MojoResult ProducerAddWaiter(Waiter* waiter, | 60 MojoResult ProducerAddWaiter(Waiter* waiter, |
63 MojoHandleSignals signals, | 61 MojoHandleSignals signals, |
64 uint32_t context); | 62 uint32_t context); |
65 void ProducerRemoveWaiter(Waiter* waiter); | 63 void ProducerRemoveWaiter(Waiter* waiter); |
66 bool ProducerIsBusy() const; | 64 bool ProducerIsBusy() const; |
(...skipping 22 matching lines...) Expand all Loading... |
89 | 87 |
90 protected: | 88 protected: |
91 DataPipe(bool has_local_producer, | 89 DataPipe(bool has_local_producer, |
92 bool has_local_consumer, | 90 bool has_local_consumer, |
93 const MojoCreateDataPipeOptions& validated_options); | 91 const MojoCreateDataPipeOptions& validated_options); |
94 | 92 |
95 friend class base::RefCountedThreadSafe<DataPipe>; | 93 friend class base::RefCountedThreadSafe<DataPipe>; |
96 virtual ~DataPipe(); | 94 virtual ~DataPipe(); |
97 | 95 |
98 virtual void ProducerCloseImplNoLock() = 0; | 96 virtual void ProducerCloseImplNoLock() = 0; |
99 // |*num_bytes| will be a nonzero multiple of |element_num_bytes_|. | 97 // |num_bytes.Get()| will be a nonzero multiple of |element_num_bytes_|. |
100 virtual MojoResult ProducerWriteDataImplNoLock(const void* elements, | 98 virtual MojoResult ProducerWriteDataImplNoLock( |
101 uint32_t* num_bytes, | 99 UserPointer<const void> elements, |
102 bool all_or_none) = 0; | 100 UserPointer<uint32_t> num_bytes, |
| 101 uint32_t max_num_bytes_to_write, |
| 102 uint32_t min_num_bytes_to_write) = 0; |
103 virtual MojoResult ProducerBeginWriteDataImplNoLock( | 103 virtual MojoResult ProducerBeginWriteDataImplNoLock( |
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; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 uint32_t producer_two_phase_max_num_bytes_written_; | 201 uint32_t producer_two_phase_max_num_bytes_written_; |
202 uint32_t consumer_two_phase_max_num_bytes_read_; | 202 uint32_t consumer_two_phase_max_num_bytes_read_; |
203 | 203 |
204 DISALLOW_COPY_AND_ASSIGN(DataPipe); | 204 DISALLOW_COPY_AND_ASSIGN(DataPipe); |
205 }; | 205 }; |
206 | 206 |
207 } // namespace system | 207 } // namespace system |
208 } // namespace mojo | 208 } // namespace mojo |
209 | 209 |
210 #endif // MOJO_SYSTEM_DATA_PIPE_H_ | 210 #endif // MOJO_SYSTEM_DATA_PIPE_H_ |
OLD | NEW |