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 WaitFlagsState ProducerGetWaitFlagsStateNoLock() const OVERRIDE; | 43 virtual HandleSignalsState |
| 44 ProducerGetHandleSignalsStateNoLock() const OVERRIDE; |
44 virtual void ConsumerCloseImplNoLock() OVERRIDE; | 45 virtual void ConsumerCloseImplNoLock() OVERRIDE; |
45 virtual MojoResult ConsumerReadDataImplNoLock(void* elements, | 46 virtual MojoResult ConsumerReadDataImplNoLock(void* elements, |
46 uint32_t* num_bytes, | 47 uint32_t* num_bytes, |
47 bool all_or_none) OVERRIDE; | 48 bool all_or_none) OVERRIDE; |
48 virtual MojoResult ConsumerDiscardDataImplNoLock(uint32_t* num_bytes, | 49 virtual MojoResult ConsumerDiscardDataImplNoLock(uint32_t* num_bytes, |
49 bool all_or_none) OVERRIDE; | 50 bool all_or_none) OVERRIDE; |
50 virtual MojoResult ConsumerQueryDataImplNoLock(uint32_t* num_bytes) OVERRIDE; | 51 virtual MojoResult ConsumerQueryDataImplNoLock(uint32_t* num_bytes) OVERRIDE; |
51 virtual MojoResult ConsumerBeginReadDataImplNoLock(const void** buffer, | 52 virtual MojoResult ConsumerBeginReadDataImplNoLock(const void** buffer, |
52 uint32_t* buffer_num_bytes, | 53 uint32_t* buffer_num_bytes, |
53 bool all_or_none) OVERRIDE; | 54 bool all_or_none) OVERRIDE; |
54 virtual MojoResult ConsumerEndReadDataImplNoLock( | 55 virtual MojoResult ConsumerEndReadDataImplNoLock( |
55 uint32_t num_bytes_read) OVERRIDE; | 56 uint32_t num_bytes_read) OVERRIDE; |
56 virtual WaitFlagsState ConsumerGetWaitFlagsStateNoLock() const OVERRIDE; | 57 virtual HandleSignalsState |
| 58 ConsumerGetHandleSignalsStateNoLock() const OVERRIDE; |
57 | 59 |
58 void EnsureBufferNoLock(); | 60 void EnsureBufferNoLock(); |
59 void DestroyBufferNoLock(); | 61 void DestroyBufferNoLock(); |
60 | 62 |
61 // Get the maximum (single) write/read size right now (in number of elements); | 63 // Get the maximum (single) write/read size right now (in number of elements); |
62 // result fits in a |uint32_t|. | 64 // result fits in a |uint32_t|. |
63 size_t GetMaxNumBytesToWriteNoLock(); | 65 size_t GetMaxNumBytesToWriteNoLock(); |
64 size_t GetMaxNumBytesToReadNoLock(); | 66 size_t GetMaxNumBytesToReadNoLock(); |
65 | 67 |
66 // Marks the given number of bytes as consumed/discarded. |num_bytes| must be | 68 // Marks the given number of bytes as consumed/discarded. |num_bytes| must be |
67 // greater than |current_num_bytes_|. | 69 // greater than |current_num_bytes_|. |
68 void MarkDataAsConsumedNoLock(size_t num_bytes); | 70 void MarkDataAsConsumedNoLock(size_t num_bytes); |
69 | 71 |
70 // The members below are protected by |DataPipe|'s |lock_|: | 72 // The members below are protected by |DataPipe|'s |lock_|: |
71 scoped_ptr<char, base::AlignedFreeDeleter> buffer_; | 73 scoped_ptr<char, base::AlignedFreeDeleter> buffer_; |
72 // Circular buffer. | 74 // Circular buffer. |
73 size_t start_index_; | 75 size_t start_index_; |
74 size_t current_num_bytes_; | 76 size_t current_num_bytes_; |
75 | 77 |
76 DISALLOW_COPY_AND_ASSIGN(LocalDataPipe); | 78 DISALLOW_COPY_AND_ASSIGN(LocalDataPipe); |
77 }; | 79 }; |
78 | 80 |
79 } // namespace system | 81 } // namespace system |
80 } // namespace mojo | 82 } // namespace mojo |
81 | 83 |
82 #endif // MOJO_SYSTEM_LOCAL_DATA_PIPE_H_ | 84 #endif // MOJO_SYSTEM_LOCAL_DATA_PIPE_H_ |
OLD | NEW |