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

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: sync and rebase 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
« no previous file with comments | « mojo/public/cpp/bindings/no_interface.h ('k') | mojo/public/cpp/bindings/tests/router_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..695f4399cd5eadf5caf35625478c5cb5a51fba1f 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);
+
+ filters_.Append(new internal::MessageHeaderValidator)
+ .Append(new typename Interface::RequestValidator_);
+ filters_.set_sink(&stub_);
}
bool WaitAndDispatchOneMessage() {
- return WaitForMessageAndDispatch(message_pipe_.get(), &stub_);
+ return WaitForMessageAndDispatch(message_pipe_.get(),
+ filters_.GetHead());
}
private:
ScopedMessagePipeHandle message_pipe_;
typename Interface::Stub_ stub_;
+ internal::FilterChain filters_;
};
} // namespace mojo
« no previous file with comments | « mojo/public/cpp/bindings/no_interface.h ('k') | mojo/public/cpp/bindings/tests/router_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698