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

Unified Diff: mojo/public/cpp/bindings/message.h

Issue 2064903002: Mojo: Report bindings validation errors via MojoNotifyBadMessage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/cpp/bindings/message.h
diff --git a/mojo/public/cpp/bindings/message.h b/mojo/public/cpp/bindings/message.h
index d8eed2bfc3ec00a96948954a86ade3b99fdc088c..cebb2041a599f50e3602171617e0aeaaf3a7a80a 100644
--- a/mojo/public/cpp/bindings/message.h
+++ b/mojo/public/cpp/bindings/message.h
@@ -19,6 +19,8 @@
namespace mojo {
+class Error;
+
// Message is a holder for the data and handles to be sent over a MessagePipe.
// Message owns its data and handles, but a consumer of Message is free to
// mutate the data and handles. The message's data is comprised of a header
@@ -99,6 +101,10 @@ class Message {
// ownership of its internal storage and any attached handles.
ScopedMessageHandle TakeMojoMessage();
+ // Notifies the system that this message is "bad," in this case meaning it was
+ // rejected by bindings validation code.
+ void NotifyBadMessage(const std::string& error);
+
private:
void CloseHandles();
@@ -114,8 +120,9 @@ class MessageReceiver {
// The receiver may mutate the given message. Returns true if the message
// was accepted and false otherwise, indicating that the message was invalid
- // or malformed.
- virtual bool Accept(Message* message) WARN_UNUSED_RESULT = 0;
+ // or malformed. If this returns false, |*error| may be populated with
+ // additional information about the failure reason.
+ virtual bool Accept(Message* message, Error* error) WARN_UNUSED_RESULT = 0;
yzshen1 2016/06/14 16:45:32 Does it make sense to merge the return value with
Ken Rockot(use gerrit already) 2016/06/14 21:20:40 Done!
};
class MessageReceiverWithResponder : public MessageReceiver {
@@ -133,7 +140,9 @@ class MessageReceiverWithResponder : public MessageReceiver {
//
// TODO(yzshen): consider changing |responder| to
// std::unique_ptr<MessageReceiver>.
- virtual bool AcceptWithResponder(Message* message, MessageReceiver* responder)
+ virtual bool AcceptWithResponder(Message* message,
+ MessageReceiver* responder,
+ Error* error)
WARN_UNUSED_RESULT = 0;
};
@@ -173,7 +182,8 @@ class MessageReceiverWithResponderStatus : public MessageReceiver {
// TODO(yzshen): consider changing |responder| to
// std::unique_ptr<MessageReceiver>.
virtual bool AcceptWithResponder(Message* message,
- MessageReceiverWithStatus* responder)
+ MessageReceiverWithStatus* responder,
+ Error* error)
WARN_UNUSED_RESULT = 0;
};

Powered by Google App Engine
This is Rietveld 408576698