Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: mojo/public/cpp/bindings/lib/binding_state.h

Issue 2064903002: Mojo: Report bindings validation errors via MojoNotifyBadMessage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_BINDING_STATE_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDING_STATE_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDING_STATE_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDING_STATE_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 explicit BindingState(Interface* impl) : impl_(impl) { 43 explicit BindingState(Interface* impl) : impl_(impl) {
44 stub_.set_sink(impl_); 44 stub_.set_sink(impl_);
45 } 45 }
46 46
47 ~BindingState() { Close(); } 47 ~BindingState() { Close(); }
48 48
49 void Bind(ScopedMessagePipeHandle handle, 49 void Bind(ScopedMessagePipeHandle handle,
50 scoped_refptr<base::SingleThreadTaskRunner> runner) { 50 scoped_refptr<base::SingleThreadTaskRunner> runner) {
51 DCHECK(!router_); 51 DCHECK(!router_);
52 internal::FilterChain filters; 52 internal::FilterChain filters;
53 filters.Append<internal::MessageHeaderValidator>(); 53 filters.Append<internal::MessageHeaderValidator>(Interface::Name_);
54 filters.Append<typename Interface::RequestValidator_>(); 54 filters.Append<typename Interface::RequestValidator_>();
55 55
56 router_ = 56 router_ =
57 new internal::Router(std::move(handle), std::move(filters), 57 new internal::Router(std::move(handle), std::move(filters),
58 Interface::HasSyncMethods_, std::move(runner)); 58 Interface::HasSyncMethods_, std::move(runner));
59 router_->set_incoming_receiver(&stub_); 59 router_->set_incoming_receiver(&stub_);
60 router_->set_interface_name(Interface::Name_);
60 router_->set_connection_error_handler( 61 router_->set_connection_error_handler(
61 [this]() { connection_error_handler_.Run(); }); 62 [this]() { connection_error_handler_.Run(); });
62 } 63 }
63 64
64 bool HasAssociatedInterfaces() const { return false; } 65 bool HasAssociatedInterfaces() const { return false; }
65 66
66 void PauseIncomingMethodCallProcessing() { 67 void PauseIncomingMethodCallProcessing() {
67 DCHECK(router_); 68 DCHECK(router_);
68 router_->PauseIncomingMethodCallProcessing(); 69 router_->PauseIncomingMethodCallProcessing();
69 } 70 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 stub_.set_sink(impl_); 140 stub_.set_sink(impl_);
140 } 141 }
141 142
142 ~BindingState() { Close(); } 143 ~BindingState() { Close(); }
143 144
144 void Bind(ScopedMessagePipeHandle handle, 145 void Bind(ScopedMessagePipeHandle handle,
145 scoped_refptr<base::SingleThreadTaskRunner> runner) { 146 scoped_refptr<base::SingleThreadTaskRunner> runner) {
146 DCHECK(!router_); 147 DCHECK(!router_);
147 148
148 router_ = new internal::MultiplexRouter(false, std::move(handle), runner); 149 router_ = new internal::MultiplexRouter(false, std::move(handle), runner);
150 router_->SetMasterInterfaceName(Interface::Name_);
149 stub_.serialization_context()->router = router_; 151 stub_.serialization_context()->router = router_;
150 152
151 endpoint_client_.reset(new internal::InterfaceEndpointClient( 153 endpoint_client_.reset(new internal::InterfaceEndpointClient(
152 router_->CreateLocalEndpointHandle(internal::kMasterInterfaceId), 154 router_->CreateLocalEndpointHandle(internal::kMasterInterfaceId),
153 &stub_, base::WrapUnique(new typename Interface::RequestValidator_()), 155 &stub_, base::WrapUnique(new typename Interface::RequestValidator_()),
154 Interface::HasSyncMethods_, std::move(runner))); 156 Interface::HasSyncMethods_, std::move(runner)));
155 157
156 endpoint_client_->set_connection_error_handler( 158 endpoint_client_->set_connection_error_handler(
157 [this]() { connection_error_handler_.Run(); }); 159 [this]() { connection_error_handler_.Run(); });
160 endpoint_client_->set_interface_name(Interface::Name_);
158 } 161 }
159 162
160 bool HasAssociatedInterfaces() const { 163 bool HasAssociatedInterfaces() const {
161 return router_ ? router_->HasAssociatedEndpoints() : false; 164 return router_ ? router_->HasAssociatedEndpoints() : false;
162 } 165 }
163 166
164 void PauseIncomingMethodCallProcessing() { 167 void PauseIncomingMethodCallProcessing() {
165 DCHECK(router_); 168 DCHECK(router_);
166 router_->PauseIncomingMethodCallProcessing(); 169 router_->PauseIncomingMethodCallProcessing();
167 } 170 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 Interface* impl_; 229 Interface* impl_;
227 Closure connection_error_handler_; 230 Closure connection_error_handler_;
228 231
229 DISALLOW_COPY_AND_ASSIGN(BindingState); 232 DISALLOW_COPY_AND_ASSIGN(BindingState);
230 }; 233 };
231 234
232 } // namesapce internal 235 } // namesapce internal
233 } // namespace mojo 236 } // namespace mojo
234 237
235 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDING_STATE_H_ 238 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_BINDING_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698