OLD | NEW |
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 | 12 |
13 namespace mojo { | 13 namespace mojo { |
14 namespace internal { | 14 namespace internal { |
15 | 15 |
16 class Router : public MessageReceiver { | 16 class Router : public MessageReceiver { |
17 public: | 17 public: |
18 // The Router takes ownership of |message_pipe|. | 18 // The Router takes ownership of |message_pipe|. |
19 explicit Router(ScopedMessagePipeHandle message_pipe, | 19 explicit Router(ScopedMessagePipeHandle message_pipe, |
20 MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()); | 20 MojoAsyncWaiter* waiter = GetDefaultAsyncWaiter()); |
21 virtual ~Router(); | 21 virtual ~Router(); |
22 | 22 |
23 // Sets the receiver to handle messages read from the message pipe that do | 23 // Sets the receiver to handle messages read from the message pipe that do |
24 // not have the kMessageIsResponse flag set. | 24 // not have the kMessageIsResponse flag set. |
25 void set_incoming_receiver(MessageReceiver* receiver) { | 25 void set_incoming_receiver(MessageReceiver* receiver) { |
26 incoming_receiver_ = receiver; | 26 incoming_receiver_ = receiver; |
27 } | 27 } |
| 28 MessageReceiver* incoming_receiver() { return incoming_receiver_; } |
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. |
31 void set_error_handler(ErrorHandler* error_handler) { | 32 void set_error_handler(ErrorHandler* error_handler) { |
32 connector_.set_error_handler(error_handler); | 33 connector_.set_error_handler(error_handler); |
33 } | 34 } |
34 | 35 |
35 // Errors from incoming receivers will force the router's connector into an | 36 // Errors from incoming receivers will force the router's connector into an |
36 // error state, where no more messages will be processed. This method is used | 37 // error state, where no more messages will be processed. This method is used |
37 // during testing to prevent that from happening. | 38 // during testing to prevent that from happening. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 MessageReceiver* incoming_receiver_; | 72 MessageReceiver* incoming_receiver_; |
72 HandleIncomingMessageThunk thunk_; | 73 HandleIncomingMessageThunk thunk_; |
73 ResponderMap responders_; | 74 ResponderMap responders_; |
74 uint64_t next_request_id_; | 75 uint64_t next_request_id_; |
75 }; | 76 }; |
76 | 77 |
77 } // namespace internal | 78 } // namespace internal |
78 } // namespace mojo | 79 } // namespace mojo |
79 | 80 |
80 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ROUTER_H_ | 81 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ROUTER_H_ |
OLD | NEW |