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

Side by Side Diff: mojo/public/cpp/bindings/lib/router.h

Issue 273233002: Mojo cpp bindings: add support for validating incoming messages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase onto the InterfacePtr change 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_ROUTER_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_ROUTER_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ROUTER_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ROUTER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "mojo/public/cpp/bindings/lib/connector.h" 10 #include "mojo/public/cpp/bindings/lib/connector.h"
11 #include "mojo/public/cpp/bindings/lib/shared_data.h" 11 #include "mojo/public/cpp/bindings/lib/shared_data.h"
12 #include "mojo/public/cpp/bindings/lib/validator_chain.h"
12 13
13 namespace mojo { 14 namespace mojo {
14 namespace internal { 15 namespace internal {
15 16
16 class Router : public MessageReceiver { 17 class Router : public MessageReceiver {
17 public: 18 public:
18 // The Router takes ownership of |message_pipe|. 19 Router(ScopedMessagePipeHandle message_pipe,
19 explicit Router(ScopedMessagePipeHandle message_pipe, 20 ValidatorChain validators,
darin (slow to review) 2014/05/12 17:28:26 hmm, instead of passing the validator chain to Rou
yzshen1 2014/05/12 21:59:58 We not only need to validate messages received by
20 MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()); 21 MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter());
21 virtual ~Router(); 22 virtual ~Router();
22 23
23 // Sets the receiver to handle messages read from the message pipe that do 24 // Sets the receiver to handle messages read from the message pipe that do
24 // not have the kMessageIsResponse flag set. 25 // not have the kMessageIsResponse flag set.
25 void set_incoming_receiver(MessageReceiver* receiver) { 26 void set_incoming_receiver(MessageReceiver* receiver) {
26 incoming_receiver_ = receiver; 27 incoming_receiver_ = receiver;
27 } 28 }
28 29
29 // Sets the error handler to receive notifications when an error is 30 // Sets the error handler to receive notifications when an error is
30 // encountered while reading from the pipe or waiting to read from the pipe. 31 // encountered while reading from the pipe or waiting to read from the pipe.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // MessageReceiver implementation: 68 // MessageReceiver implementation:
68 virtual bool Accept(Message* message) MOJO_OVERRIDE; 69 virtual bool Accept(Message* message) MOJO_OVERRIDE;
69 virtual bool AcceptWithResponder(Message* message, 70 virtual bool AcceptWithResponder(Message* message,
70 MessageReceiver* responder) MOJO_OVERRIDE; 71 MessageReceiver* responder) MOJO_OVERRIDE;
71 private: 72 private:
72 Router* router_; 73 Router* router_;
73 }; 74 };
74 75
75 bool HandleIncomingMessage(Message* message); 76 bool HandleIncomingMessage(Message* message);
76 77
78 HandleIncomingMessageThunk thunk_;
79 ValidatorChain validators_;
77 Connector connector_; 80 Connector connector_;
78 SharedData<Router*> weak_self_; 81 SharedData<Router*> weak_self_;
79 MessageReceiver* incoming_receiver_; 82 MessageReceiver* incoming_receiver_;
80 HandleIncomingMessageThunk thunk_;
81 ResponderMap responders_; 83 ResponderMap responders_;
82 uint64_t next_request_id_; 84 uint64_t next_request_id_;
83 }; 85 };
84 86
85 } // namespace internal 87 } // namespace internal
86 } // namespace mojo 88 } // namespace mojo
87 89
88 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ROUTER_H_ 90 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ROUTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698