| 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_RAW_CHANNEL_H_ | 5 #ifndef MOJO_SYSTEM_RAW_CHANNEL_H_ |
| 6 #define MOJO_SYSTEM_RAW_CHANNEL_H_ | 6 #define MOJO_SYSTEM_RAW_CHANNEL_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 bool IsWriteBufferEmpty(); | 97 bool IsWriteBufferEmpty(); |
| 98 | 98 |
| 99 protected: | 99 protected: |
| 100 // Return values of |[Schedule]Read()| and |[Schedule]WriteNoLock()|. | 100 // Return values of |[Schedule]Read()| and |[Schedule]WriteNoLock()|. |
| 101 enum IOResult { | 101 enum IOResult { |
| 102 IO_SUCCEEDED, | 102 IO_SUCCEEDED, |
| 103 IO_FAILED, | 103 IO_FAILED, |
| 104 IO_PENDING | 104 IO_PENDING |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 class ReadBuffer { | 107 class MOJO_SYSTEM_IMPL_EXPORT ReadBuffer { |
| 108 public: | 108 public: |
| 109 ReadBuffer(); | 109 ReadBuffer(); |
| 110 ~ReadBuffer(); | 110 ~ReadBuffer(); |
| 111 | 111 |
| 112 void GetBuffer(char** addr, size_t* size); | 112 void GetBuffer(char** addr, size_t* size); |
| 113 | 113 |
| 114 private: | 114 private: |
| 115 friend class RawChannel; | 115 friend class RawChannel; |
| 116 | 116 |
| 117 // We store data from |[Schedule]Read()|s in |buffer_|. The start of | 117 // We store data from |[Schedule]Read()|s in |buffer_|. The start of |
| 118 // |buffer_| is always aligned with a message boundary (we will copy memory | 118 // |buffer_| is always aligned with a message boundary (we will copy memory |
| 119 // to ensure this), but |buffer_| may be larger than the actual number of | 119 // to ensure this), but |buffer_| may be larger than the actual number of |
| 120 // bytes we have. | 120 // bytes we have. |
| 121 std::vector<char> buffer_; | 121 std::vector<char> buffer_; |
| 122 size_t num_valid_bytes_; | 122 size_t num_valid_bytes_; |
| 123 | 123 |
| 124 DISALLOW_COPY_AND_ASSIGN(ReadBuffer); | 124 DISALLOW_COPY_AND_ASSIGN(ReadBuffer); |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 class WriteBuffer { | 127 class MOJO_SYSTEM_IMPL_EXPORT WriteBuffer { |
| 128 public: | 128 public: |
| 129 struct Buffer { | 129 struct Buffer { |
| 130 const char* addr; | 130 const char* addr; |
| 131 size_t size; | 131 size_t size; |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 WriteBuffer(); | 134 WriteBuffer(); |
| 135 ~WriteBuffer(); | 135 ~WriteBuffer(); |
| 136 | 136 |
| 137 void GetBuffers(std::vector<Buffer>* buffers) const; | 137 void GetBuffers(std::vector<Buffer>* buffers) const; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 // are only used/invalidated on the I/O thread. | 242 // are only used/invalidated on the I/O thread. |
| 243 base::WeakPtrFactory<RawChannel> weak_ptr_factory_; | 243 base::WeakPtrFactory<RawChannel> weak_ptr_factory_; |
| 244 | 244 |
| 245 DISALLOW_COPY_AND_ASSIGN(RawChannel); | 245 DISALLOW_COPY_AND_ASSIGN(RawChannel); |
| 246 }; | 246 }; |
| 247 | 247 |
| 248 } // namespace system | 248 } // namespace system |
| 249 } // namespace mojo | 249 } // namespace mojo |
| 250 | 250 |
| 251 #endif // MOJO_SYSTEM_RAW_CHANNEL_H_ | 251 #endif // MOJO_SYSTEM_RAW_CHANNEL_H_ |
| OLD | NEW |