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

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

Issue 273233002: Mojo cpp bindings: add support for validating incoming messages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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/sync_dispatcher.h
diff --git a/mojo/public/cpp/bindings/sync_dispatcher.h b/mojo/public/cpp/bindings/sync_dispatcher.h
index 752118023940799d46c3c9e716f81bd9dfd4cbfb..c91a84e27528432559d3f985dcde3a92c921aeab 100644
--- a/mojo/public/cpp/bindings/sync_dispatcher.h
+++ b/mojo/public/cpp/bindings/sync_dispatcher.h
@@ -5,6 +5,8 @@
#ifndef MOJO_PUBLIC_CPP_BINDINGS_SYNC_DISPATCHER_H_
#define MOJO_PUBLIC_CPP_BINDINGS_SYNC_DISPATCHER_H_
+#include "mojo/public/cpp/bindings/lib/filter_chain.h"
+#include "mojo/public/cpp/bindings/lib/message_header_validator.h"
#include "mojo/public/cpp/system/core.h"
namespace mojo {
@@ -13,6 +15,8 @@ class MessageReceiver;
// Waits for one message to arrive on the message pipe, and dispatch it to the
// receiver. Returns true on success, false on failure.
+//
+// NOTE: The message hasn't been validated and may be malformed!
bool WaitForMessageAndDispatch(MessagePipeHandle handle,
mojo::MessageReceiver* receiver);
@@ -21,15 +25,21 @@ template<typename Interface> class SyncDispatcher {
SyncDispatcher(ScopedMessagePipeHandle message_pipe, Interface* sink)
: message_pipe_(message_pipe.Pass()) {
stub_.set_sink(sink);
+
+ validators_.Append(new internal::MessageHeaderValidator)
darin (slow to review) 2014/05/14 06:51:51 nit: validators_ -> filters_
yzshen1 2014/05/14 08:14:03 Done. (I was thinking validators_ is a more specif
+ .Append(new typename Interface::RequestValidator_);
+ validators_.set_sink(&stub_);
}
bool WaitAndDispatchOneMessage() {
- return WaitForMessageAndDispatch(message_pipe_.get(), &stub_);
+ return WaitForMessageAndDispatch(message_pipe_.get(),
+ validators_.GetHead());
}
private:
ScopedMessagePipeHandle message_pipe_;
typename Interface::Stub_ stub_;
+ internal::FilterChain validators_;
};
} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698