OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "mojo/public/cpp/bindings/lib/binding_state.h" | 5 #include "mojo/public/cpp/bindings/lib/binding_state.h" |
6 | 6 |
7 namespace mojo { | 7 namespace mojo { |
8 namespace internal { | 8 namespace internal { |
9 | 9 |
10 SimpleBindingState::SimpleBindingState() = default; | 10 SimpleBindingState::SimpleBindingState() = default; |
11 | 11 |
12 SimpleBindingState::~SimpleBindingState() = default; | 12 SimpleBindingState::~SimpleBindingState() = default; |
13 | 13 |
| 14 void SimpleBindingState::AddFilter(std::unique_ptr<MessageReceiver> filter) { |
| 15 DCHECK(router_); |
| 16 router_->AddFilter(std::move(filter)); |
| 17 } |
| 18 |
14 void SimpleBindingState::PauseIncomingMethodCallProcessing() { | 19 void SimpleBindingState::PauseIncomingMethodCallProcessing() { |
15 DCHECK(router_); | 20 DCHECK(router_); |
16 router_->PauseIncomingMethodCallProcessing(); | 21 router_->PauseIncomingMethodCallProcessing(); |
17 } | 22 } |
18 void SimpleBindingState::ResumeIncomingMethodCallProcessing() { | 23 void SimpleBindingState::ResumeIncomingMethodCallProcessing() { |
19 DCHECK(router_); | 24 DCHECK(router_); |
20 router_->ResumeIncomingMethodCallProcessing(); | 25 router_->ResumeIncomingMethodCallProcessing(); |
21 } | 26 } |
22 | 27 |
23 bool SimpleBindingState::WaitForIncomingMethodCall(MojoDeadline deadline) { | 28 bool SimpleBindingState::WaitForIncomingMethodCall(MojoDeadline deadline) { |
(...skipping 11 matching lines...) Expand all Loading... |
35 | 40 |
36 void SimpleBindingState::EnableTestingMode() { | 41 void SimpleBindingState::EnableTestingMode() { |
37 DCHECK(is_bound()); | 42 DCHECK(is_bound()); |
38 router_->EnableTestingMode(); | 43 router_->EnableTestingMode(); |
39 } | 44 } |
40 | 45 |
41 void SimpleBindingState::BindInternal( | 46 void SimpleBindingState::BindInternal( |
42 ScopedMessagePipeHandle handle, | 47 ScopedMessagePipeHandle handle, |
43 scoped_refptr<base::SingleThreadTaskRunner> runner, | 48 scoped_refptr<base::SingleThreadTaskRunner> runner, |
44 const char* interface_name, | 49 const char* interface_name, |
45 MessageFilter* request_validator, | 50 std::unique_ptr<MessageReceiver> request_validator, |
46 bool has_sync_methods, | 51 bool has_sync_methods, |
47 MessageReceiverWithResponderStatus* stub) { | 52 MessageReceiverWithResponderStatus* stub) { |
48 internal::FilterChain filters; | 53 FilterChain filters; |
49 filters.Append<MessageHeaderValidator>(interface_name); | 54 filters.Append<MessageHeaderValidator>(interface_name); |
50 filters.Append(request_validator); | 55 filters.Append(std::move(request_validator)); |
51 | 56 |
52 router_ = new internal::Router(std::move(handle), std::move(filters), | 57 router_ = new internal::Router(std::move(handle), std::move(filters), |
53 has_sync_methods, std::move(runner)); | 58 has_sync_methods, std::move(runner)); |
54 router_->set_incoming_receiver(stub); | 59 router_->set_incoming_receiver(stub); |
55 router_->set_connection_error_handler(base::Bind( | 60 router_->set_connection_error_handler(base::Bind( |
56 &SimpleBindingState::RunConnectionErrorHandler, base::Unretained(this))); | 61 &SimpleBindingState::RunConnectionErrorHandler, base::Unretained(this))); |
57 } | 62 } |
58 | 63 |
59 void SimpleBindingState::DestroyRouter() { | 64 void SimpleBindingState::DestroyRouter() { |
60 router_->set_connection_error_handler(base::Closure()); | 65 router_->set_connection_error_handler(base::Closure()); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 109 |
105 void MultiplexedBindingState::EnableTestingMode() { | 110 void MultiplexedBindingState::EnableTestingMode() { |
106 DCHECK(is_bound()); | 111 DCHECK(is_bound()); |
107 router_->EnableTestingMode(); | 112 router_->EnableTestingMode(); |
108 } | 113 } |
109 | 114 |
110 void MultiplexedBindingState::BindInternal( | 115 void MultiplexedBindingState::BindInternal( |
111 ScopedMessagePipeHandle handle, | 116 ScopedMessagePipeHandle handle, |
112 scoped_refptr<base::SingleThreadTaskRunner> runner, | 117 scoped_refptr<base::SingleThreadTaskRunner> runner, |
113 const char* interface_name, | 118 const char* interface_name, |
114 std::unique_ptr<MessageFilter> request_validator, | 119 std::unique_ptr<MessageReceiver> request_validator, |
115 bool has_sync_methods, | 120 bool has_sync_methods, |
116 MessageReceiverWithResponderStatus* stub) { | 121 MessageReceiverWithResponderStatus* stub) { |
117 DCHECK(!router_); | 122 DCHECK(!router_); |
118 | 123 |
119 router_ = new internal::MultiplexRouter(false, std::move(handle), runner); | 124 router_ = new internal::MultiplexRouter(false, std::move(handle), runner); |
120 router_->SetMasterInterfaceName(interface_name); | 125 router_->SetMasterInterfaceName(interface_name); |
121 | 126 |
122 endpoint_client_.reset(new InterfaceEndpointClient( | 127 endpoint_client_.reset(new InterfaceEndpointClient( |
123 router_->CreateLocalEndpointHandle(kMasterInterfaceId), stub, | 128 router_->CreateLocalEndpointHandle(kMasterInterfaceId), stub, |
124 std::move(request_validator), has_sync_methods, std::move(runner))); | 129 std::move(request_validator), has_sync_methods, std::move(runner))); |
125 | 130 |
126 endpoint_client_->set_connection_error_handler( | 131 endpoint_client_->set_connection_error_handler( |
127 base::Bind(&MultiplexedBindingState::RunConnectionErrorHandler, | 132 base::Bind(&MultiplexedBindingState::RunConnectionErrorHandler, |
128 base::Unretained(this))); | 133 base::Unretained(this))); |
129 } | 134 } |
130 | 135 |
131 void MultiplexedBindingState::RunConnectionErrorHandler() { | 136 void MultiplexedBindingState::RunConnectionErrorHandler() { |
132 if (!connection_error_handler_.is_null()) | 137 if (!connection_error_handler_.is_null()) |
133 connection_error_handler_.Run(); | 138 connection_error_handler_.Run(); |
134 } | 139 } |
135 | 140 |
136 } // namesapce internal | 141 } // namesapce internal |
137 } // namespace mojo | 142 } // namespace mojo |
OLD | NEW |