| 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_LOCAL_DATA_PIPE_H_ | 5 #ifndef MOJO_SYSTEM_LOCAL_DATA_PIPE_H_ |
| 6 #define MOJO_SYSTEM_LOCAL_DATA_PIPE_H_ | 6 #define MOJO_SYSTEM_LOCAL_DATA_PIPE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/aligned_memory.h" | 9 #include "base/memory/aligned_memory.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 virtual void ProducerCloseImplNoLock() OVERRIDE; | 33 virtual void ProducerCloseImplNoLock() OVERRIDE; |
| 34 virtual MojoResult ProducerWriteDataImplNoLock(const void* elements, | 34 virtual MojoResult ProducerWriteDataImplNoLock(const void* elements, |
| 35 uint32_t* num_bytes, | 35 uint32_t* num_bytes, |
| 36 bool all_or_none) OVERRIDE; | 36 bool all_or_none) OVERRIDE; |
| 37 virtual MojoResult ProducerBeginWriteDataImplNoLock( | 37 virtual MojoResult ProducerBeginWriteDataImplNoLock( |
| 38 void** buffer, | 38 void** buffer, |
| 39 uint32_t* buffer_num_bytes, | 39 uint32_t* buffer_num_bytes, |
| 40 bool all_or_none) OVERRIDE; | 40 bool all_or_none) OVERRIDE; |
| 41 virtual MojoResult ProducerEndWriteDataImplNoLock( | 41 virtual MojoResult ProducerEndWriteDataImplNoLock( |
| 42 uint32_t num_bytes_written) OVERRIDE; | 42 uint32_t num_bytes_written) OVERRIDE; |
| 43 virtual MojoWaitFlags ProducerSatisfiedFlagsNoLock() OVERRIDE; | 43 virtual WaitFlagsState ProducerGetWaitFlagsStateNoLock() const OVERRIDE; |
| 44 virtual MojoWaitFlags ProducerSatisfiableFlagsNoLock() OVERRIDE; | |
| 45 virtual void ConsumerCloseImplNoLock() OVERRIDE; | 44 virtual void ConsumerCloseImplNoLock() OVERRIDE; |
| 46 virtual MojoResult ConsumerReadDataImplNoLock(void* elements, | 45 virtual MojoResult ConsumerReadDataImplNoLock(void* elements, |
| 47 uint32_t* num_bytes, | 46 uint32_t* num_bytes, |
| 48 bool all_or_none) OVERRIDE; | 47 bool all_or_none) OVERRIDE; |
| 49 virtual MojoResult ConsumerDiscardDataImplNoLock(uint32_t* num_bytes, | 48 virtual MojoResult ConsumerDiscardDataImplNoLock(uint32_t* num_bytes, |
| 50 bool all_or_none) OVERRIDE; | 49 bool all_or_none) OVERRIDE; |
| 51 virtual MojoResult ConsumerQueryDataImplNoLock(uint32_t* num_bytes) OVERRIDE; | 50 virtual MojoResult ConsumerQueryDataImplNoLock(uint32_t* num_bytes) OVERRIDE; |
| 52 virtual MojoResult ConsumerBeginReadDataImplNoLock(const void** buffer, | 51 virtual MojoResult ConsumerBeginReadDataImplNoLock(const void** buffer, |
| 53 uint32_t* buffer_num_bytes, | 52 uint32_t* buffer_num_bytes, |
| 54 bool all_or_none) OVERRIDE; | 53 bool all_or_none) OVERRIDE; |
| 55 virtual MojoResult ConsumerEndReadDataImplNoLock( | 54 virtual MojoResult ConsumerEndReadDataImplNoLock( |
| 56 uint32_t num_bytes_read) OVERRIDE; | 55 uint32_t num_bytes_read) OVERRIDE; |
| 57 virtual MojoWaitFlags ConsumerSatisfiedFlagsNoLock() OVERRIDE; | 56 virtual WaitFlagsState ConsumerGetWaitFlagsStateNoLock() const OVERRIDE; |
| 58 virtual MojoWaitFlags ConsumerSatisfiableFlagsNoLock() OVERRIDE; | |
| 59 | 57 |
| 60 void EnsureBufferNoLock(); | 58 void EnsureBufferNoLock(); |
| 61 void DestroyBufferNoLock(); | 59 void DestroyBufferNoLock(); |
| 62 | 60 |
| 63 // Get the maximum (single) write/read size right now (in number of elements); | 61 // Get the maximum (single) write/read size right now (in number of elements); |
| 64 // result fits in a |uint32_t|. | 62 // result fits in a |uint32_t|. |
| 65 size_t GetMaxNumBytesToWriteNoLock(); | 63 size_t GetMaxNumBytesToWriteNoLock(); |
| 66 size_t GetMaxNumBytesToReadNoLock(); | 64 size_t GetMaxNumBytesToReadNoLock(); |
| 67 | 65 |
| 68 // Marks the given number of bytes as consumed/discarded. |num_bytes| must be | 66 // Marks the given number of bytes as consumed/discarded. |num_bytes| must be |
| 69 // greater than |current_num_bytes_|. | 67 // greater than |current_num_bytes_|. |
| 70 void MarkDataAsConsumedNoLock(size_t num_bytes); | 68 void MarkDataAsConsumedNoLock(size_t num_bytes); |
| 71 | 69 |
| 72 // The members below are protected by |DataPipe|'s |lock_|: | 70 // The members below are protected by |DataPipe|'s |lock_|: |
| 73 scoped_ptr<char, base::AlignedFreeDeleter> buffer_; | 71 scoped_ptr<char, base::AlignedFreeDeleter> buffer_; |
| 74 // Circular buffer. | 72 // Circular buffer. |
| 75 size_t start_index_; | 73 size_t start_index_; |
| 76 size_t current_num_bytes_; | 74 size_t current_num_bytes_; |
| 77 | 75 |
| 78 DISALLOW_COPY_AND_ASSIGN(LocalDataPipe); | 76 DISALLOW_COPY_AND_ASSIGN(LocalDataPipe); |
| 79 }; | 77 }; |
| 80 | 78 |
| 81 } // namespace system | 79 } // namespace system |
| 82 } // namespace mojo | 80 } // namespace mojo |
| 83 | 81 |
| 84 #endif // MOJO_SYSTEM_LOCAL_DATA_PIPE_H_ | 82 #endif // MOJO_SYSTEM_LOCAL_DATA_PIPE_H_ |
| OLD | NEW |