Chromium Code Reviews| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 45 | 45 |
| 46 ScopedMessagePipeHandle PassMessagePipe() { | 46 ScopedMessagePipeHandle PassMessagePipe() { |
| 47 return connector_.PassMessagePipe(); | 47 return connector_.PassMessagePipe(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 // MessageReceiver implementation: | 50 // MessageReceiver implementation: |
| 51 bool Accept(Message* message) override; | 51 bool Accept(Message* message) override; |
| 52 bool AcceptWithResponder(Message* message, | 52 bool AcceptWithResponder(Message* message, |
| 53 MessageReceiver* responder) override; | 53 MessageReceiver* responder) override; |
| 54 | 54 |
| 55 // Blocks the current thread for the first incoming method call, i.e., either | 55 // Blocks the current thread for the first incoming method call, i.e., either |
|
viettrungluu
2015/04/02 19:54:13
nit: update comment?
| |
| 56 // a call to a client method or a callback method. | 56 // a call to a client method or a callback method. |
| 57 bool WaitForIncomingMessage() { return connector_.WaitForIncomingMessage(); } | 57 bool WaitForIncomingMessage(MojoDeadline deadline) { |
| 58 return connector_.WaitForIncomingMessage(deadline); | |
| 59 } | |
| 58 | 60 |
| 59 // Sets this object to testing mode. | 61 // Sets this object to testing mode. |
| 60 // In testing mode: | 62 // In testing mode: |
| 61 // - the object is more tolerant of unrecognized response messages; | 63 // - the object is more tolerant of unrecognized response messages; |
| 62 // - the connector continues working after seeing errors from its incoming | 64 // - the connector continues working after seeing errors from its incoming |
| 63 // receiver. | 65 // receiver. |
| 64 void EnableTestingMode(); | 66 void EnableTestingMode(); |
| 65 | 67 |
| 68 MessagePipeHandle handle() const { return connector_.handle(); } | |
| 69 | |
| 66 private: | 70 private: |
| 67 typedef std::map<uint64_t, MessageReceiver*> ResponderMap; | 71 typedef std::map<uint64_t, MessageReceiver*> ResponderMap; |
| 68 | 72 |
| 69 class HandleIncomingMessageThunk : public MessageReceiver { | 73 class HandleIncomingMessageThunk : public MessageReceiver { |
| 70 public: | 74 public: |
| 71 HandleIncomingMessageThunk(Router* router); | 75 HandleIncomingMessageThunk(Router* router); |
| 72 ~HandleIncomingMessageThunk() override; | 76 ~HandleIncomingMessageThunk() override; |
| 73 | 77 |
| 74 // MessageReceiver implementation: | 78 // MessageReceiver implementation: |
| 75 bool Accept(Message* message) override; | 79 bool Accept(Message* message) override; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 87 MessageReceiverWithResponderStatus* incoming_receiver_; | 91 MessageReceiverWithResponderStatus* incoming_receiver_; |
| 88 ResponderMap responders_; | 92 ResponderMap responders_; |
| 89 uint64_t next_request_id_; | 93 uint64_t next_request_id_; |
| 90 bool testing_mode_; | 94 bool testing_mode_; |
| 91 }; | 95 }; |
| 92 | 96 |
| 93 } // namespace internal | 97 } // namespace internal |
| 94 } // namespace mojo | 98 } // namespace mojo |
| 95 | 99 |
| 96 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ROUTER_H_ | 100 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ROUTER_H_ |
| OLD | NEW |