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_PUBLIC_SYSTEM_CORE_CPP_H_ | 5 #ifndef MOJO_PUBLIC_SYSTEM_CORE_CPP_H_ |
6 #define MOJO_PUBLIC_SYSTEM_CORE_CPP_H_ | 6 #define MOJO_PUBLIC_SYSTEM_CORE_CPP_H_ |
7 | 7 |
8 #include <assert.h> | 8 #include <assert.h> |
9 | 9 |
10 #include <limits> | 10 #include <limits> |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 MOJO_COMPILE_ASSERT(sizeof(MessagePipeHandle) == sizeof(Handle), | 179 MOJO_COMPILE_ASSERT(sizeof(MessagePipeHandle) == sizeof(Handle), |
180 bad_size_for_cpp_MessagePipeHandle); | 180 bad_size_for_cpp_MessagePipeHandle); |
181 | 181 |
182 typedef ScopedHandleBase<MessagePipeHandle> ScopedMessagePipeHandle; | 182 typedef ScopedHandleBase<MessagePipeHandle> ScopedMessagePipeHandle; |
183 MOJO_COMPILE_ASSERT(sizeof(ScopedMessagePipeHandle) == | 183 MOJO_COMPILE_ASSERT(sizeof(ScopedMessagePipeHandle) == |
184 sizeof(MessagePipeHandle), | 184 sizeof(MessagePipeHandle), |
185 bad_size_for_cpp_ScopedMessagePipeHandle); | 185 bad_size_for_cpp_ScopedMessagePipeHandle); |
186 | 186 |
187 // TODO(vtl): In C++11, we could instead return a pair of | 187 // TODO(vtl): In C++11, we could instead return a pair of |
188 // |ScopedMessagePipeHandle|s. | 188 // |ScopedMessagePipeHandle|s. |
189 inline void CreateMessagePipe(ScopedMessagePipeHandle* message_pipe_0, | 189 inline void CreateMessagePipe(ScopedMessagePipeHandle* message_pipe0, |
190 ScopedMessagePipeHandle* message_pipe_1) { | 190 ScopedMessagePipeHandle* message_pipe1) { |
191 assert(message_pipe_0); | 191 assert(message_pipe0); |
192 assert(message_pipe_1); | 192 assert(message_pipe1); |
193 MessagePipeHandle h_0; | 193 MessagePipeHandle h0; |
194 MessagePipeHandle h_1; | 194 MessagePipeHandle h1; |
195 MojoResult result MOJO_ALLOW_UNUSED = | 195 MojoResult result MOJO_ALLOW_UNUSED = |
196 MojoCreateMessagePipe(h_0.mutable_value(), h_1.mutable_value()); | 196 MojoCreateMessagePipe(h0.mutable_value(), h1.mutable_value()); |
197 assert(result == MOJO_RESULT_OK); | 197 assert(result == MOJO_RESULT_OK); |
198 message_pipe_0->reset(h_0); | 198 message_pipe0->reset(h0); |
199 message_pipe_1->reset(h_1); | 199 message_pipe1->reset(h1); |
200 } | 200 } |
201 | 201 |
202 class MessagePipe { | 202 class MessagePipe { |
203 public: | 203 public: |
204 MessagePipe(); | 204 MessagePipe(); |
205 ~MessagePipe(); | 205 ~MessagePipe(); |
206 | 206 |
207 ScopedMessagePipeHandle handle0; | 207 ScopedMessagePipeHandle handle0; |
208 ScopedMessagePipeHandle handle1; | 208 ScopedMessagePipeHandle handle1; |
209 }; | 209 }; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 } | 325 } |
326 | 326 |
327 inline MojoResult EndReadDataRaw(DataPipeConsumerHandle data_pipe_consumer, | 327 inline MojoResult EndReadDataRaw(DataPipeConsumerHandle data_pipe_consumer, |
328 uint32_t num_bytes_read) { | 328 uint32_t num_bytes_read) { |
329 return MojoEndReadData(data_pipe_consumer.value(), num_bytes_read); | 329 return MojoEndReadData(data_pipe_consumer.value(), num_bytes_read); |
330 } | 330 } |
331 | 331 |
332 } // namespace mojo | 332 } // namespace mojo |
333 | 333 |
334 #endif // MOJO_PUBLIC_SYSTEM_CORE_CPP_H_ | 334 #endif // MOJO_PUBLIC_SYSTEM_CORE_CPP_H_ |
OLD | NEW |