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 |