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/callback.h" |
10 #include "mojo/public/cpp/bindings/lib/connector.h" | 11 #include "mojo/public/cpp/bindings/lib/connector.h" |
11 #include "mojo/public/cpp/bindings/lib/filter_chain.h" | 12 #include "mojo/public/cpp/bindings/lib/filter_chain.h" |
12 #include "mojo/public/cpp/bindings/lib/shared_data.h" | 13 #include "mojo/public/cpp/bindings/lib/shared_data.h" |
13 #include "mojo/public/cpp/environment/environment.h" | 14 #include "mojo/public/cpp/environment/environment.h" |
14 | 15 |
15 namespace mojo { | 16 namespace mojo { |
16 namespace internal { | 17 namespace internal { |
17 | 18 |
18 class Router : public MessageReceiverWithResponder { | 19 class Router : public MessageReceiverWithResponder { |
19 public: | 20 public: |
20 Router(ScopedMessagePipeHandle message_pipe, | 21 Router(ScopedMessagePipeHandle message_pipe, |
21 FilterChain filters, | 22 FilterChain filters, |
22 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()); | 23 const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter()); |
23 ~Router() override; | 24 ~Router() override; |
24 | 25 |
25 // Sets the receiver to handle messages read from the message pipe that do | 26 // Sets the receiver to handle messages read from the message pipe that do |
26 // not have the kMessageIsResponse flag set. | 27 // not have the kMessageIsResponse flag set. |
27 void set_incoming_receiver(MessageReceiverWithResponderStatus* receiver) { | 28 void set_incoming_receiver(MessageReceiverWithResponderStatus* receiver) { |
28 incoming_receiver_ = receiver; | 29 incoming_receiver_ = receiver; |
29 } | 30 } |
30 | 31 |
31 // Sets the error handler to receive notifications when an error is | 32 // Sets the error handler to receive notifications when an error is |
32 // encountered while reading from the pipe or waiting to read from the pipe. | 33 // encountered while reading from the pipe or waiting to read from the pipe. |
33 void set_error_handler(ErrorHandler* error_handler) { | 34 void set_connection_error_handler(const Closure& error_handler) { |
34 connector_.set_error_handler(error_handler); | 35 connector_.set_connection_error_handler(error_handler); |
35 } | 36 } |
36 | 37 |
37 // Returns true if an error was encountered while reading from the pipe or | 38 // Returns true if an error was encountered while reading from the pipe or |
38 // waiting to read from the pipe. | 39 // waiting to read from the pipe. |
39 bool encountered_error() const { return connector_.encountered_error(); } | 40 bool encountered_error() const { return connector_.encountered_error(); } |
40 | 41 |
41 // Is the router bound to a MessagePipe handle? | 42 // Is the router bound to a MessagePipe handle? |
42 bool is_valid() const { return connector_.is_valid(); } | 43 bool is_valid() const { return connector_.is_valid(); } |
43 | 44 |
44 void CloseMessagePipe() { connector_.CloseMessagePipe(); } | 45 void CloseMessagePipe() { connector_.CloseMessagePipe(); } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 MessageReceiverWithResponderStatus* incoming_receiver_; | 92 MessageReceiverWithResponderStatus* incoming_receiver_; |
92 ResponderMap responders_; | 93 ResponderMap responders_; |
93 uint64_t next_request_id_; | 94 uint64_t next_request_id_; |
94 bool testing_mode_; | 95 bool testing_mode_; |
95 }; | 96 }; |
96 | 97 |
97 } // namespace internal | 98 } // namespace internal |
98 } // namespace mojo | 99 } // namespace mojo |
99 | 100 |
100 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ROUTER_H_ | 101 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ROUTER_H_ |
OLD | NEW |