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

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: rebase 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 inline MojoResult ReadMessageRaw(MessagePipeHandle message_pipe, 81 inline MojoResult ReadMessageRaw(MessagePipeHandle message_pipe,
82 void* bytes, 82 void* bytes,
83 uint32_t* num_bytes, 83 uint32_t* num_bytes,
84 MojoHandle* handles, 84 MojoHandle* handles,
85 uint32_t* num_handles, 85 uint32_t* num_handles,
86 MojoReadMessageFlags flags) { 86 MojoReadMessageFlags flags) {
87 return MojoReadMessage( 87 return MojoReadMessage(
88 message_pipe.value(), bytes, num_bytes, handles, num_handles, flags); 88 message_pipe.value(), bytes, num_bytes, handles, num_handles, flags);
89 } 89 }
90 90
91 // Fuses two message pipes together at the given handles. See
92 // |MojoFuseMessagePipes()| for complete documentation.
93 inline MojoResult FuseMessagePipes(ScopedMessagePipeHandle message_pipe0,
94 ScopedMessagePipeHandle message_pipe1) {
95 return MojoFuseMessagePipes(message_pipe0.release().value(),
96 message_pipe1.release().value());
97 }
98
91 // A wrapper class that automatically creates a message pipe and owns both 99 // A wrapper class that automatically creates a message pipe and owns both
92 // handles. 100 // handles.
93 class MessagePipe { 101 class MessagePipe {
94 public: 102 public:
95 MessagePipe(); 103 MessagePipe();
96 explicit MessagePipe(const MojoCreateMessagePipeOptions& options); 104 explicit MessagePipe(const MojoCreateMessagePipeOptions& options);
97 ~MessagePipe(); 105 ~MessagePipe();
98 106
99 ScopedMessagePipeHandle handle0; 107 ScopedMessagePipeHandle handle0;
100 ScopedMessagePipeHandle handle1; 108 ScopedMessagePipeHandle handle1;
101 }; 109 };
102 110
103 inline MessagePipe::MessagePipe() { 111 inline MessagePipe::MessagePipe() {
104 MojoResult result = CreateMessagePipe(nullptr, &handle0, &handle1); 112 MojoResult result = CreateMessagePipe(nullptr, &handle0, &handle1);
105 DCHECK_EQ(MOJO_RESULT_OK, result); 113 DCHECK_EQ(MOJO_RESULT_OK, result);
106 } 114 }
107 115
108 inline MessagePipe::MessagePipe(const MojoCreateMessagePipeOptions& options) { 116 inline MessagePipe::MessagePipe(const MojoCreateMessagePipeOptions& options) {
109 MojoResult result = CreateMessagePipe(&options, &handle0, &handle1); 117 MojoResult result = CreateMessagePipe(&options, &handle0, &handle1);
110 DCHECK_EQ(MOJO_RESULT_OK, result); 118 DCHECK_EQ(MOJO_RESULT_OK, result);
111 } 119 }
112 120
113 inline MessagePipe::~MessagePipe() { 121 inline MessagePipe::~MessagePipe() {
114 } 122 }
115 123
116 } // namespace mojo 124 } // namespace mojo
117 125
118 #endif // MOJO_PUBLIC_CPP_SYSTEM_MESSAGE_PIPE_H_ 126 #endif // MOJO_PUBLIC_CPP_SYSTEM_MESSAGE_PIPE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698