| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_MULTIPLEX_ROUTER_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_MULTIPLEX_ROUTER_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_MULTIPLEX_ROUTER_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_MULTIPLEX_ROUTER_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/ref_counted_delete_on_message_loop.h" | 14 #include "base/memory/ref_counted_delete_on_message_loop.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
| 18 #include "base/threading/thread_checker.h" | 18 #include "base/threading/thread_checker.h" |
| 19 #include "mojo/public/cpp/bindings/callback.h" | 19 #include "mojo/public/cpp/bindings/callback.h" |
| 20 #include "mojo/public/cpp/bindings/lib/connector.h" | 20 #include "mojo/public/cpp/bindings/lib/connector.h" |
| 21 #include "mojo/public/cpp/bindings/lib/interface_id.h" | 21 #include "mojo/public/cpp/bindings/lib/interface_id.h" |
| 22 #include "mojo/public/cpp/bindings/lib/message_header_validator.h" | 22 #include "mojo/public/cpp/bindings/lib/message_header_validator.h" |
| 23 #include "mojo/public/cpp/bindings/lib/pipe_control_message_handler.h" | 23 #include "mojo/public/cpp/bindings/lib/pipe_control_message_handler.h" |
| 24 #include "mojo/public/cpp/bindings/lib/pipe_control_message_handler_delegate.h" | 24 #include "mojo/public/cpp/bindings/lib/pipe_control_message_handler_delegate.h" |
| 25 #include "mojo/public/cpp/bindings/lib/pipe_control_message_proxy.h" | 25 #include "mojo/public/cpp/bindings/lib/pipe_control_message_proxy.h" |
| 26 #include "mojo/public/cpp/bindings/lib/scoped_interface_endpoint_handle.h" | 26 #include "mojo/public/cpp/bindings/lib/scoped_interface_endpoint_handle.h" |
| 27 #include "mojo/public/cpp/environment/environment.h" | 27 #include "mojo/public/cpp/environment/environment.h" |
| 28 | 28 |
| 29 namespace mojo { | 29 namespace mojo { |
| 30 |
| 31 class AssociatedGroup; |
| 32 |
| 30 namespace internal { | 33 namespace internal { |
| 31 | 34 |
| 32 class InterfaceEndpointClient; | 35 class InterfaceEndpointClient; |
| 33 | 36 |
| 34 // MultiplexRouter supports routing messages for multiple interfaces over a | 37 // MultiplexRouter supports routing messages for multiple interfaces over a |
| 35 // single message pipe. | 38 // single message pipe. |
| 36 // | 39 // |
| 37 // It is created on the thread where the master interface of the message pipe | 40 // It is created on the thread where the master interface of the message pipe |
| 38 // lives. Although it is ref-counted, it is guarateed to be destructed on the | 41 // lives. Although it is ref-counted, it is guarateed to be destructed on the |
| 39 // same thread. | 42 // same thread. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // on the same thread as the corresponding AttachEndpointClient() call. | 81 // on the same thread as the corresponding AttachEndpointClient() call. |
| 79 void DetachEndpointClient(const ScopedInterfaceEndpointHandle& handle); | 82 void DetachEndpointClient(const ScopedInterfaceEndpointHandle& handle); |
| 80 | 83 |
| 81 bool SendMessage(const ScopedInterfaceEndpointHandle& handle, | 84 bool SendMessage(const ScopedInterfaceEndpointHandle& handle, |
| 82 Message* message); | 85 Message* message); |
| 83 | 86 |
| 84 // Raises an error on the underlying message pipe. It disconnects the pipe | 87 // Raises an error on the underlying message pipe. It disconnects the pipe |
| 85 // and notifies all interfaces running on this pipe. | 88 // and notifies all interfaces running on this pipe. |
| 86 void RaiseError(); | 89 void RaiseError(); |
| 87 | 90 |
| 91 scoped_ptr<AssociatedGroup> CreateAssociatedGroup(); |
| 92 |
| 93 static MultiplexRouter* GetRouter(AssociatedGroup* associated_group); |
| 94 |
| 88 // --------------------------------------------------------------------------- | 95 // --------------------------------------------------------------------------- |
| 89 // The following public methods are called on the creating thread. | 96 // The following public methods are called on the creating thread. |
| 90 | 97 |
| 91 // Please note that this method shouldn't be called unless it results from an | 98 // Please note that this method shouldn't be called unless it results from an |
| 92 // explicit request of the user of bindings (e.g., the user sets an | 99 // explicit request of the user of bindings (e.g., the user sets an |
| 93 // InterfacePtr to null or closes a Binding). | 100 // InterfacePtr to null or closes a Binding). |
| 94 void CloseMessagePipe() { | 101 void CloseMessagePipe() { |
| 95 DCHECK(thread_checker_.CalledOnValidThread()); | 102 DCHECK(thread_checker_.CalledOnValidThread()); |
| 96 connector_.CloseMessagePipe(); | 103 connector_.CloseMessagePipe(); |
| 97 } | 104 } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 205 |
| 199 bool testing_mode_; | 206 bool testing_mode_; |
| 200 | 207 |
| 201 DISALLOW_COPY_AND_ASSIGN(MultiplexRouter); | 208 DISALLOW_COPY_AND_ASSIGN(MultiplexRouter); |
| 202 }; | 209 }; |
| 203 | 210 |
| 204 } // namespace internal | 211 } // namespace internal |
| 205 } // namespace mojo | 212 } // namespace mojo |
| 206 | 213 |
| 207 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MULTIPLEX_ROUTER_H_ | 214 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MULTIPLEX_ROUTER_H_ |
| OLD | NEW |