Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(551)

Side by Side Diff: mojo/public/cpp/system/message_pipe.h

Issue 1785843002: [mojo] Implement pipe fusion API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 // This file provides a C++ wrapping around the Mojo C API for message pipes, 5 // This file provides a C++ wrapping around the Mojo C API for message pipes,
6 // replacing the prefix of "Mojo" with a "mojo" namespace, and using more 6 // replacing the prefix of "Mojo" with a "mojo" namespace, and using more
7 // strongly-typed representations of |MojoHandle|s. 7 // strongly-typed representations of |MojoHandle|s.
8 // 8 //
9 // Please see "mojo/public/c/system/message_pipe.h" for complete documentation 9 // Please see "mojo/public/c/system/message_pipe.h" for complete documentation
10 // of the API. 10 // of the API.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 inline MojoResult ReadMessageRaw(MessagePipeHandle message_pipe, 82 inline MojoResult ReadMessageRaw(MessagePipeHandle message_pipe,
83 void* bytes, 83 void* bytes,
84 uint32_t* num_bytes, 84 uint32_t* num_bytes,
85 MojoHandle* handles, 85 MojoHandle* handles,
86 uint32_t* num_handles, 86 uint32_t* num_handles,
87 MojoReadMessageFlags flags) { 87 MojoReadMessageFlags flags) {
88 return MojoReadMessage( 88 return MojoReadMessage(
89 message_pipe.value(), bytes, num_bytes, handles, num_handles, flags); 89 message_pipe.value(), bytes, num_bytes, handles, num_handles, flags);
90 } 90 }
91 91
92 // Fuses two message pipes together at the given handles. See
93 // |MojoFuseMessagePipes()| for complete documentation.
94 inline MojoResult FuseMessagePipes(ScopedMessagePipeHandle message_pipe0,
95 ScopedMessagePipeHandle message_pipe1) {
96 return MojoFuseMessagePipes(message_pipe0.release().value(),
97 message_pipe1.release().value());
98 }
99
92 // A wrapper class that automatically creates a message pipe and owns both 100 // A wrapper class that automatically creates a message pipe and owns both
93 // handles. 101 // handles.
94 class MessagePipe { 102 class MessagePipe {
95 public: 103 public:
96 MessagePipe(); 104 MessagePipe();
97 explicit MessagePipe(const MojoCreateMessagePipeOptions& options); 105 explicit MessagePipe(const MojoCreateMessagePipeOptions& options);
98 ~MessagePipe(); 106 ~MessagePipe();
99 107
100 ScopedMessagePipeHandle handle0; 108 ScopedMessagePipeHandle handle0;
101 ScopedMessagePipeHandle handle1; 109 ScopedMessagePipeHandle handle1;
102 }; 110 };
103 111
104 inline MessagePipe::MessagePipe() { 112 inline MessagePipe::MessagePipe() {
105 MojoResult result = CreateMessagePipe(nullptr, &handle0, &handle1); 113 MojoResult result = CreateMessagePipe(nullptr, &handle0, &handle1);
106 DCHECK_EQ(MOJO_RESULT_OK, result); 114 DCHECK_EQ(MOJO_RESULT_OK, result);
107 } 115 }
108 116
109 inline MessagePipe::MessagePipe(const MojoCreateMessagePipeOptions& options) { 117 inline MessagePipe::MessagePipe(const MojoCreateMessagePipeOptions& options) {
110 MojoResult result = CreateMessagePipe(&options, &handle0, &handle1); 118 MojoResult result = CreateMessagePipe(&options, &handle0, &handle1);
111 DCHECK_EQ(MOJO_RESULT_OK, result); 119 DCHECK_EQ(MOJO_RESULT_OK, result);
112 } 120 }
113 121
114 inline MessagePipe::~MessagePipe() { 122 inline MessagePipe::~MessagePipe() {
115 } 123 }
116 124
117 } // namespace mojo 125 } // namespace mojo
118 126
119 #endif // MOJO_PUBLIC_CPP_SYSTEM_MESSAGE_PIPE_H_ 127 #endif // MOJO_PUBLIC_CPP_SYSTEM_MESSAGE_PIPE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698