| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <queue> | 12 #include <queue> |
| 13 | 13 |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
| 19 #include "base/threading/thread_checker.h" | 19 #include "base/threading/thread_checker.h" |
| 20 #include "mojo/public/cpp/bindings/connector.h" | 20 #include "mojo/public/cpp/bindings/connector.h" |
| 21 #include "mojo/public/cpp/bindings/lib/filter_chain.h" | 21 #include "mojo/public/cpp/bindings/filter_chain.h" |
| 22 #include "mojo/public/cpp/bindings/message.h" |
| 22 | 23 |
| 23 namespace mojo { | 24 namespace mojo { |
| 24 namespace internal { | 25 namespace internal { |
| 25 | 26 |
| 26 // TODO(yzshen): Consider removing this class and use MultiplexRouter in all | 27 // TODO(yzshen): Consider removing this class and use MultiplexRouter in all |
| 27 // cases. crbug.com/594244 | 28 // cases. crbug.com/594244 |
| 28 class Router : public MessageReceiverWithResponder { | 29 class Router : public MessageReceiverWithResponder { |
| 29 public: | 30 public: |
| 30 Router(ScopedMessagePipeHandle message_pipe, | 31 Router(ScopedMessagePipeHandle message_pipe, |
| 31 FilterChain filters, | 32 FilterChain filters, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 51 DCHECK(thread_checker_.CalledOnValidThread()); | 52 DCHECK(thread_checker_.CalledOnValidThread()); |
| 52 return encountered_error_; | 53 return encountered_error_; |
| 53 } | 54 } |
| 54 | 55 |
| 55 // Is the router bound to a MessagePipe handle? | 56 // Is the router bound to a MessagePipe handle? |
| 56 bool is_valid() const { | 57 bool is_valid() const { |
| 57 DCHECK(thread_checker_.CalledOnValidThread()); | 58 DCHECK(thread_checker_.CalledOnValidThread()); |
| 58 return connector_.is_valid(); | 59 return connector_.is_valid(); |
| 59 } | 60 } |
| 60 | 61 |
| 62 void AddFilter(std::unique_ptr<MessageReceiver> filter); |
| 63 |
| 61 // Please note that this method shouldn't be called unless it results from an | 64 // Please note that this method shouldn't be called unless it results from an |
| 62 // explicit request of the user of bindings (e.g., the user sets an | 65 // explicit request of the user of bindings (e.g., the user sets an |
| 63 // InterfacePtr to null or closes a Binding). | 66 // InterfacePtr to null or closes a Binding). |
| 64 void CloseMessagePipe() { | 67 void CloseMessagePipe() { |
| 65 DCHECK(thread_checker_.CalledOnValidThread()); | 68 DCHECK(thread_checker_.CalledOnValidThread()); |
| 66 connector_.CloseMessagePipe(); | 69 connector_.CloseMessagePipe(); |
| 67 } | 70 } |
| 68 | 71 |
| 69 ScopedMessagePipeHandle PassMessagePipe() { | 72 ScopedMessagePipeHandle PassMessagePipe() { |
| 70 DCHECK(thread_checker_.CalledOnValidThread()); | 73 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 bool encountered_error_; | 173 bool encountered_error_; |
| 171 base::Closure error_handler_; | 174 base::Closure error_handler_; |
| 172 base::ThreadChecker thread_checker_; | 175 base::ThreadChecker thread_checker_; |
| 173 base::WeakPtrFactory<Router> weak_factory_; | 176 base::WeakPtrFactory<Router> weak_factory_; |
| 174 }; | 177 }; |
| 175 | 178 |
| 176 } // namespace internal | 179 } // namespace internal |
| 177 } // namespace mojo | 180 } // namespace mojo |
| 178 | 181 |
| 179 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ROUTER_H_ | 182 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ROUTER_H_ |
| OLD | NEW |