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

Side by Side Diff: mojo/public/cpp/bindings/message.h

Issue 1723673002: Reland "Mojo C++ bindings: support sync methods - part 2" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 #ifndef MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 115
116 // A variant on Accept that registers a MessageReceiver (known as the 116 // A variant on Accept that registers a MessageReceiver (known as the
117 // responder) to handle the response message generated from the given 117 // responder) to handle the response message generated from the given
118 // message. The responder's Accept method may be called during 118 // message. The responder's Accept method may be called during
119 // AcceptWithResponder or some time after its return. 119 // AcceptWithResponder or some time after its return.
120 // 120 //
121 // NOTE: Upon returning true, AcceptWithResponder assumes ownership of 121 // NOTE: Upon returning true, AcceptWithResponder assumes ownership of
122 // |responder| and will delete it after calling |responder->Accept| or upon 122 // |responder| and will delete it after calling |responder->Accept| or upon
123 // its own destruction. 123 // its own destruction.
124 // 124 //
125 // TODO(yzshen): consider changing |responder| to scoped_ptr<MessageReceiver>.
125 virtual bool AcceptWithResponder(Message* message, MessageReceiver* responder) 126 virtual bool AcceptWithResponder(Message* message, MessageReceiver* responder)
126 MOJO_WARN_UNUSED_RESULT = 0; 127 MOJO_WARN_UNUSED_RESULT = 0;
127 }; 128 };
128 129
129 // A MessageReceiver that is also able to provide status about the state 130 // A MessageReceiver that is also able to provide status about the state
130 // of the underlying MessagePipe to which it will be forwarding messages 131 // of the underlying MessagePipe to which it will be forwarding messages
131 // received via the |Accept()| call. 132 // received via the |Accept()| call.
132 class MessageReceiverWithStatus : public MessageReceiver { 133 class MessageReceiverWithStatus : public MessageReceiver {
133 public: 134 public:
134 ~MessageReceiverWithStatus() override {} 135 ~MessageReceiverWithStatus() override {}
(...skipping 12 matching lines...) Expand all
147 148
148 // A variant on Accept that registers a MessageReceiverWithStatus (known as 149 // A variant on Accept that registers a MessageReceiverWithStatus (known as
149 // the responder) to handle the response message generated from the given 150 // the responder) to handle the response message generated from the given
150 // message. Any of the responder's methods (Accept or IsValid) may be called 151 // message. Any of the responder's methods (Accept or IsValid) may be called
151 // during AcceptWithResponder or some time after its return. 152 // during AcceptWithResponder or some time after its return.
152 // 153 //
153 // NOTE: Upon returning true, AcceptWithResponder assumes ownership of 154 // NOTE: Upon returning true, AcceptWithResponder assumes ownership of
154 // |responder| and will delete it after calling |responder->Accept| or upon 155 // |responder| and will delete it after calling |responder->Accept| or upon
155 // its own destruction. 156 // its own destruction.
156 // 157 //
158 // TODO(yzshen): consider changing |responder| to scoped_ptr<MessageReceiver>.
157 virtual bool AcceptWithResponder(Message* message, 159 virtual bool AcceptWithResponder(Message* message,
158 MessageReceiverWithStatus* responder) 160 MessageReceiverWithStatus* responder)
159 MOJO_WARN_UNUSED_RESULT = 0; 161 MOJO_WARN_UNUSED_RESULT = 0;
160 }; 162 };
161 163
162 // Read a single message from the pipe. The caller should have created the 164 // Read a single message from the pipe. The caller should have created the
163 // Message, but not called Initialize(). Returns MOJO_RESULT_SHOULD_WAIT if 165 // Message, but not called Initialize(). Returns MOJO_RESULT_SHOULD_WAIT if
164 // the caller should wait on the handle to become readable. Returns 166 // the caller should wait on the handle to become readable. Returns
165 // MOJO_RESULT_OK if the message was read successfully and should be 167 // MOJO_RESULT_OK if the message was read successfully and should be
166 // dispatched, otherwise returns an error code if something went wrong. 168 // dispatched, otherwise returns an error code if something went wrong.
167 // 169 //
168 // NOTE: The message hasn't been validated and may be malformed! 170 // NOTE: The message hasn't been validated and may be malformed!
169 MojoResult ReadMessage(MessagePipeHandle handle, Message* message); 171 MojoResult ReadMessage(MessagePipeHandle handle, Message* message);
170 172
171 } // namespace mojo 173 } // namespace mojo
172 174
173 #endif // MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_ 175 #endif // MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/sync_handle_watcher.cc ('k') | mojo/public/cpp/bindings/tests/router_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698