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

Side by Side Diff: services/shell/public/cpp/lib/interface_registry.cc

Issue 2417703002: Fix an issue running mash in chrome: (Closed)
Patch Set: Created 4 years, 2 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 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 "services/shell/public/cpp/interface_registry.h" 5 #include "services/shell/public/cpp/interface_registry.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "mojo/public/cpp/bindings/message.h" 9 #include "mojo/public/cpp/bindings/message.h"
10 #include "services/shell/public/cpp/connection.h" 10 #include "services/shell/public/cpp/connection.h"
11 11
12 namespace shell { 12 namespace shell {
13 13
14 InterfaceRegistry::InterfaceRegistry() 14 InterfaceRegistry::InterfaceRegistry()
15 : binding_(this), allow_all_interfaces_(true), weak_factory_(this) {} 15 : binding_(this), allow_all_interfaces_(true), weak_factory_(this) {}
16 16
17 InterfaceRegistry::InterfaceRegistry( 17 InterfaceRegistry::InterfaceRegistry(
18 const Identity& local_identity,
18 const Identity& remote_identity, 19 const Identity& remote_identity,
19 const CapabilityRequest& capability_request) 20 const CapabilityRequest& capability_request)
20 : binding_(this), 21 : binding_(this),
22 local_identity_(local_identity),
21 remote_identity_(remote_identity), 23 remote_identity_(remote_identity),
22 capability_request_(capability_request), 24 capability_request_(capability_request),
23 allow_all_interfaces_(capability_request.interfaces.size() == 1 && 25 allow_all_interfaces_(capability_request.interfaces.size() == 1 &&
24 capability_request.interfaces.count("*") == 1), 26 capability_request.interfaces.count("*") == 1),
25 weak_factory_(this) {} 27 weak_factory_(this) {}
26 28
27 InterfaceRegistry::~InterfaceRegistry() {} 29 InterfaceRegistry::~InterfaceRegistry() {}
28 30
29 void InterfaceRegistry::Bind( 31 void InterfaceRegistry::Bind(
30 mojom::InterfaceProviderRequest local_interfaces_request) { 32 mojom::InterfaceProviderRequest local_interfaces_request) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 90 }
89 91
90 auto iter = name_to_binder_.find(interface_name); 92 auto iter = name_to_binder_.find(interface_name);
91 if (iter != name_to_binder_.end()) { 93 if (iter != name_to_binder_.end()) {
92 iter->second->BindInterface(remote_identity_, 94 iter->second->BindInterface(remote_identity_,
93 interface_name, 95 interface_name,
94 std::move(handle)); 96 std::move(handle));
95 } else if (!CanBindRequestForInterface(interface_name)) { 97 } else if (!CanBindRequestForInterface(interface_name)) {
96 std::stringstream ss; 98 std::stringstream ss;
97 ss << "Capability spec prevented service " << remote_identity_.name() 99 ss << "Capability spec prevented service " << remote_identity_.name()
98 << " from binding interface: " << interface_name; 100 << " from binding interface: " << interface_name
101 << " exposed by: " << local_identity_.name();
99 LOG(ERROR) << ss.str(); 102 LOG(ERROR) << ss.str();
100 mojo::ReportBadMessage(ss.str()); 103 mojo::ReportBadMessage(ss.str());
101 } else if (!default_binder_.is_null()) { 104 } else if (!default_binder_.is_null()) {
102 default_binder_.Run(interface_name, std::move(handle)); 105 default_binder_.Run(interface_name, std::move(handle));
103 } else { 106 } else {
104 LOG(ERROR) << "Failed to locate a binder for interface: " << interface_name; 107 LOG(ERROR) << "Failed to locate a binder for interface: " << interface_name
108 << " requested by: " << remote_identity_.name()
109 << " exposed by: " << local_identity_.name();
105 } 110 }
106 } 111 }
107 112
108 bool InterfaceRegistry::SetInterfaceBinderForName( 113 bool InterfaceRegistry::SetInterfaceBinderForName(
109 std::unique_ptr<InterfaceBinder> binder, 114 std::unique_ptr<InterfaceBinder> binder,
110 const std::string& interface_name) { 115 const std::string& interface_name) {
111 if (CanBindRequestForInterface(interface_name)) { 116 if (CanBindRequestForInterface(interface_name)) {
112 RemoveInterface(interface_name); 117 RemoveInterface(interface_name);
113 name_to_binder_[interface_name] = std::move(binder); 118 name_to_binder_[interface_name] = std::move(binder);
114 return true; 119 return true;
115 } 120 }
116 return false; 121 return false;
117 } 122 }
118 123
119 bool InterfaceRegistry::CanBindRequestForInterface( 124 bool InterfaceRegistry::CanBindRequestForInterface(
120 const std::string& interface_name) const { 125 const std::string& interface_name) const {
121 return allow_all_interfaces_ || 126 return allow_all_interfaces_ ||
122 capability_request_.interfaces.count(interface_name); 127 capability_request_.interfaces.count(interface_name);
123 } 128 }
124 129
125 } // namespace shell 130 } // namespace shell
OLDNEW
« no previous file with comments | « services/shell/public/cpp/interface_registry.h ('k') | services/shell/public/cpp/lib/service_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698