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

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

Issue 2766523002: mojo: MessageReceiver*::AcceptWithResponder() now take a unique_ptr to the responder (Closed)
Patch Set: comments Created 3 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 #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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 }; 176 };
177 177
178 class MessageReceiverWithResponder : public MessageReceiver { 178 class MessageReceiverWithResponder : public MessageReceiver {
179 public: 179 public:
180 ~MessageReceiverWithResponder() override {} 180 ~MessageReceiverWithResponder() override {}
181 181
182 // A variant on Accept that registers a MessageReceiver (known as the 182 // A variant on Accept that registers a MessageReceiver (known as the
183 // responder) to handle the response message generated from the given 183 // responder) to handle the response message generated from the given
184 // message. The responder's Accept method may be called during 184 // message. The responder's Accept method may be called during
185 // AcceptWithResponder or some time after its return. 185 // AcceptWithResponder or some time after its return.
186 // 186 virtual bool AcceptWithResponder(Message* message,
187 // NOTE: Upon returning true, AcceptWithResponder assumes ownership of 187 std::unique_ptr<MessageReceiver> responder)
188 // |responder| and will delete it after calling |responder->Accept| or upon
189 // its own destruction.
190 //
191 // TODO(yzshen): consider changing |responder| to
192 // std::unique_ptr<MessageReceiver>.
193 virtual bool AcceptWithResponder(Message* message, MessageReceiver* responder)
194 WARN_UNUSED_RESULT = 0; 188 WARN_UNUSED_RESULT = 0;
195 }; 189 };
196 190
197 // A MessageReceiver that is also able to provide status about the state 191 // A MessageReceiver that is also able to provide status about the state
198 // of the underlying MessagePipe to which it will be forwarding messages 192 // of the underlying MessagePipe to which it will be forwarding messages
199 // received via the |Accept()| call. 193 // received via the |Accept()| call.
200 class MessageReceiverWithStatus : public MessageReceiver { 194 class MessageReceiverWithStatus : public MessageReceiver {
201 public: 195 public:
202 ~MessageReceiverWithStatus() override {} 196 ~MessageReceiverWithStatus() override {}
203 197
(...skipping 11 matching lines...) Expand all
215 // is necessary for the implementor of this interface to know about the status 209 // is necessary for the implementor of this interface to know about the status
216 // of the MessagePipe which will carry the responses. 210 // of the MessagePipe which will carry the responses.
217 class MessageReceiverWithResponderStatus : public MessageReceiver { 211 class MessageReceiverWithResponderStatus : public MessageReceiver {
218 public: 212 public:
219 ~MessageReceiverWithResponderStatus() override {} 213 ~MessageReceiverWithResponderStatus() override {}
220 214
221 // A variant on Accept that registers a MessageReceiverWithStatus (known as 215 // A variant on Accept that registers a MessageReceiverWithStatus (known as
222 // the responder) to handle the response message generated from the given 216 // the responder) to handle the response message generated from the given
223 // message. Any of the responder's methods (Accept or IsValid) may be called 217 // message. Any of the responder's methods (Accept or IsValid) may be called
224 // during AcceptWithResponder or some time after its return. 218 // during AcceptWithResponder or some time after its return.
225 //
226 // NOTE: Upon returning true, AcceptWithResponder assumes ownership of
227 // |responder| and will delete it after calling |responder->Accept| or upon
228 // its own destruction.
229 //
230 // TODO(yzshen): consider changing |responder| to
231 // std::unique_ptr<MessageReceiver>.
232 virtual bool AcceptWithResponder(Message* message, 219 virtual bool AcceptWithResponder(Message* message,
233 MessageReceiverWithStatus* responder) 220 std::unique_ptr<MessageReceiverWithStatus>
234 WARN_UNUSED_RESULT = 0; 221 responder) WARN_UNUSED_RESULT = 0;
235 }; 222 };
236 223
237 class MOJO_CPP_BINDINGS_EXPORT PassThroughFilter 224 class MOJO_CPP_BINDINGS_EXPORT PassThroughFilter
238 : NON_EXPORTED_BASE(public MessageReceiver) { 225 : NON_EXPORTED_BASE(public MessageReceiver) {
239 public: 226 public:
240 PassThroughFilter(); 227 PassThroughFilter();
241 ~PassThroughFilter() override; 228 ~PassThroughFilter() override;
242 229
243 // MessageReceiver: 230 // MessageReceiver:
244 bool Accept(Message* message) override; 231 bool Accept(Message* message) override;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 // Message as bad. Note that this is only legal to call from directly within the 293 // Message as bad. Note that this is only legal to call from directly within the
307 // stack frame of a message dispatch, but the returned callback may be called 294 // stack frame of a message dispatch, but the returned callback may be called
308 // exactly once any time thereafter to report the message as bad. This may only 295 // exactly once any time thereafter to report the message as bad. This may only
309 // be called once per message. 296 // be called once per message.
310 MOJO_CPP_BINDINGS_EXPORT 297 MOJO_CPP_BINDINGS_EXPORT
311 ReportBadMessageCallback GetBadMessageCallback(); 298 ReportBadMessageCallback GetBadMessageCallback();
312 299
313 } // namespace mojo 300 } // namespace mojo
314 301
315 #endif // MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_ 302 #endif // MOJO_PUBLIC_CPP_BINDINGS_MESSAGE_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/pipe_control_message_proxy.cc ('k') | mojo/public/cpp/bindings/tests/bindings_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698