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

Unified Diff: mojo/public/cpp/bindings/lib/interface_endpoint_client.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/lib/interface_endpoint_client.h
diff --git a/mojo/public/cpp/bindings/lib/interface_endpoint_client.h b/mojo/public/cpp/bindings/lib/interface_endpoint_client.h
index 3f820db3c30c66b179e6b2203478f66bb0b19509..abf801312a0ac68882178d2a960d7f4c580bfbb7 100644
--- a/mojo/public/cpp/bindings/lib/interface_endpoint_client.h
+++ b/mojo/public/cpp/bindings/lib/interface_endpoint_client.h
@@ -17,6 +17,7 @@
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_checker.h"
#include "mojo/public/cpp/bindings/callback.h"
+#include "mojo/public/cpp/bindings/error.h"
#include "mojo/public/cpp/bindings/message.h"
#include "mojo/public/cpp/bindings/message_filter.h"
#include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
@@ -67,23 +68,30 @@ class InterfaceEndpointClient : public MessageReceiverWithResponder {
AssociatedGroup* associated_group();
uint32_t interface_id() const;
+ void set_interface_name(const std::string& name) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ interface_name_ = name;
+ }
+
// After this call the object is in an invalid state and shouldn't be reused.
ScopedInterfaceEndpointHandle PassHandle();
// Raises an error on the underlying message pipe. It disconnects the pipe
// and notifies all interfaces running on this pipe.
- void RaiseError();
+ void RaiseError(Error error);
// MessageReceiverWithResponder implementation:
- bool Accept(Message* message) override;
+ bool Accept(Message* message, Error* error) override;
bool AcceptWithResponder(Message* message,
- MessageReceiver* responder) override;
+ MessageReceiver* responder,
+ Error* error) override;
// The following methods are called by the router. They must be called
- // outside of the router's lock.
+ // outside of the router's lock. If this returns false, |*error| contains more
+ // information about the failure reason.
// NOTE: |message| must have passed message header validation.
- bool HandleIncomingMessage(Message* message);
+ bool HandleIncomingMessage(Message* message, Error* error);
void NotifyError();
private:
@@ -116,7 +124,7 @@ class InterfaceEndpointClient : public MessageReceiverWithResponder {
~HandleIncomingMessageThunk() override;
// MessageReceiver implementation:
- bool Accept(Message* message) override;
+ bool Accept(Message* message, Error* error) override;
private:
InterfaceEndpointClient* const owner_;
@@ -124,7 +132,7 @@ class InterfaceEndpointClient : public MessageReceiverWithResponder {
DISALLOW_COPY_AND_ASSIGN(HandleIncomingMessageThunk);
};
- bool HandleValidatedMessage(Message* message);
+ bool HandleValidatedMessage(Message* message, Error* error);
ScopedInterfaceEndpointHandle handle_;
std::unique_ptr<AssociatedGroup> associated_group_;
@@ -142,6 +150,10 @@ class InterfaceEndpointClient : public MessageReceiverWithResponder {
Closure error_handler_;
bool encountered_error_;
+ // The name of the interface which is bound by this client. Used only for
+ // debugging purposes.
+ std::string interface_name_;
+
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
base::ThreadChecker thread_checker_;

Powered by Google App Engine
This is Rietveld 408576698