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" |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 void CloseMessagePipe() { | 41 void CloseMessagePipe() { |
42 connector_.CloseMessagePipe(); | 42 connector_.CloseMessagePipe(); |
43 } | 43 } |
44 | 44 |
45 ScopedMessagePipeHandle PassMessagePipe() { | 45 ScopedMessagePipeHandle PassMessagePipe() { |
46 return connector_.PassMessagePipe(); | 46 return connector_.PassMessagePipe(); |
47 } | 47 } |
48 | 48 |
49 // MessageReceiver implementation: | 49 // MessageReceiver implementation: |
50 virtual bool Accept(Message* message) MOJO_OVERRIDE; | 50 virtual bool Accept(Message* message) override; |
51 virtual bool AcceptWithResponder(Message* message, MessageReceiver* responder) | 51 virtual bool AcceptWithResponder(Message* message, |
52 MOJO_OVERRIDE; | 52 MessageReceiver* responder) override; |
53 | 53 |
54 // Blocks the current thread for the first incoming method call, i.e., either | 54 // Blocks the current thread for the first incoming method call, i.e., either |
55 // a call to a client method or a callback method. | 55 // a call to a client method or a callback method. |
56 bool WaitForIncomingMessage() { | 56 bool WaitForIncomingMessage() { |
57 return connector_.WaitForIncomingMessage(); | 57 return connector_.WaitForIncomingMessage(); |
58 } | 58 } |
59 | 59 |
60 // Sets this object to testing mode. | 60 // Sets this object to testing mode. |
61 // In testing mode: | 61 // In testing mode: |
62 // - the object is more tolerant of unrecognized response messages; | 62 // - the object is more tolerant of unrecognized response messages; |
63 // - the connector continues working after seeing errors from its incoming | 63 // - the connector continues working after seeing errors from its incoming |
64 // receiver. | 64 // receiver. |
65 void EnableTestingMode(); | 65 void EnableTestingMode(); |
66 | 66 |
67 private: | 67 private: |
68 typedef std::map<uint64_t, MessageReceiver*> ResponderMap; | 68 typedef std::map<uint64_t, MessageReceiver*> ResponderMap; |
69 | 69 |
70 class HandleIncomingMessageThunk : public MessageReceiver { | 70 class HandleIncomingMessageThunk : public MessageReceiver { |
71 public: | 71 public: |
72 HandleIncomingMessageThunk(Router* router); | 72 HandleIncomingMessageThunk(Router* router); |
73 virtual ~HandleIncomingMessageThunk(); | 73 virtual ~HandleIncomingMessageThunk(); |
74 | 74 |
75 // MessageReceiver implementation: | 75 // MessageReceiver implementation: |
76 virtual bool Accept(Message* message) MOJO_OVERRIDE; | 76 virtual bool Accept(Message* message) override; |
77 | 77 |
78 private: | 78 private: |
79 Router* router_; | 79 Router* router_; |
80 }; | 80 }; |
81 | 81 |
82 bool HandleIncomingMessage(Message* message); | 82 bool HandleIncomingMessage(Message* message); |
83 | 83 |
84 HandleIncomingMessageThunk thunk_; | 84 HandleIncomingMessageThunk thunk_; |
85 FilterChain filters_; | 85 FilterChain filters_; |
86 Connector connector_; | 86 Connector connector_; |
87 SharedData<Router*> weak_self_; | 87 SharedData<Router*> weak_self_; |
88 MessageReceiverWithResponder* incoming_receiver_; | 88 MessageReceiverWithResponder* incoming_receiver_; |
89 ResponderMap responders_; | 89 ResponderMap responders_; |
90 uint64_t next_request_id_; | 90 uint64_t next_request_id_; |
91 bool testing_mode_; | 91 bool testing_mode_; |
92 }; | 92 }; |
93 | 93 |
94 } // namespace internal | 94 } // namespace internal |
95 } // namespace mojo | 95 } // namespace mojo |
96 | 96 |
97 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ROUTER_H_ | 97 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ROUTER_H_ |
OLD | NEW |