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

Unified Diff: mojo/public/cpp/bindings/lib/interface_ptr_internal.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
Index: mojo/public/cpp/bindings/lib/interface_ptr_internal.h
diff --git a/mojo/public/cpp/bindings/lib/interface_ptr_internal.h b/mojo/public/cpp/bindings/lib/interface_ptr_internal.h
index 08da0d138968e7263c2e8754d38b07e6bcd47988..52151a9a9433ed2d8d5c3d9ee032bf63527e7736 100644
--- a/mojo/public/cpp/bindings/lib/interface_ptr_internal.h
+++ b/mojo/public/cpp/bindings/lib/interface_ptr_internal.h
@@ -7,6 +7,8 @@
#include <stdio.h>
+#include "mojo/public/cpp/bindings/lib/filter_chain.h"
+#include "mojo/public/cpp/bindings/lib/message_header_validator.h"
#include "mojo/public/cpp/bindings/lib/router.h"
namespace mojo {
@@ -15,7 +17,7 @@ namespace internal {
template <typename Interface>
class InterfacePtrState {
public:
- InterfacePtrState() : instance_(NULL), client_(NULL), router_(NULL) {}
+ InterfacePtrState() : instance_(NULL), router_(NULL) {}
~InterfacePtrState() {
// Destruction order matters here. We delete |instance_| first, even though
@@ -23,22 +25,14 @@ class InterfacePtrState {
// shot at generating new outbound messages (ie, invoking client methods).
delete instance_;
delete router_;
- delete client_;
}
Interface* instance() const { return instance_; }
- void set_instance(Interface* instance) { instance_ = instance; }
Router* router() const { return router_; }
- bool is_configured_as_proxy() const {
- // This question only makes sense if we have a bound pipe.
- return router_ && !client_;
- }
-
void Swap(InterfacePtrState* other) {
std::swap(other->instance_, instance_);
- std::swap(other->client_, client_);
std::swap(other->router_, router_);
}
@@ -47,30 +41,18 @@ class InterfacePtrState {
assert(!instance_);
assert(!router_);
- router_ = new Router(handle.Pass(), waiter);
+ FilterChain filters;
+ filters.Append(new MessageHeaderValidator)
+ .Append(new typename Interface::Client::RequestValidator_)
+ .Append(new typename Interface::ResponseValidator_);
+
+ router_ = new Router(handle.Pass(), filters.Pass(), waiter);
ProxyWithStub* proxy = new ProxyWithStub(router_);
router_->set_incoming_receiver(&proxy->stub);
instance_ = proxy;
}
- void ConfigureStub(ScopedMessagePipeHandle handle,
- MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()) {
- assert(instance_); // Should have already been set!
- assert(!router_);
-
- // Stub for binding to state_.instance
- // Proxy for communicating to the client on the other end of the pipe.
-
- router_ = new Router(handle.Pass(), waiter);
- ClientProxyWithStub* proxy = new ClientProxyWithStub(router_);
- proxy->stub.set_sink(instance_);
- router_->set_incoming_receiver(&proxy->stub);
-
- instance_->SetClient(proxy);
- client_ = proxy;
- }
-
private:
class ProxyWithStub : public Interface::Proxy_ {
public:
@@ -85,18 +67,7 @@ class InterfacePtrState {
MOJO_DISALLOW_COPY_AND_ASSIGN(ProxyWithStub);
};
- class ClientProxyWithStub : public Interface::Client::Proxy_ {
- public:
- explicit ClientProxyWithStub(MessageReceiver* receiver)
- : Interface::Client::Proxy_(receiver) {
- }
- typename Interface::Stub_ stub;
- private:
- MOJO_DISALLOW_COPY_AND_ASSIGN(ClientProxyWithStub);
- };
-
Interface* instance_;
- typename Interface::Client* client_;
Router* router_;
MOJO_DISALLOW_COPY_AND_ASSIGN(InterfacePtrState);
« no previous file with comments | « mojo/public/cpp/bindings/lib/interface_impl_internal.h ('k') | mojo/public/cpp/bindings/lib/message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698