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 "services/shell/public/cpp/interface_registry.h" | 5 #include "services/shell/public/cpp/interface_registry.h" |
6 | 6 |
7 #include "services/shell/public/cpp/connection.h" | 7 #include "services/shell/public/cpp/connection.h" |
8 | 8 |
9 namespace shell { | 9 namespace shell { |
10 | 10 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 // mojom::InterfaceProvider: | 57 // mojom::InterfaceProvider: |
58 void InterfaceRegistry::GetInterface(const mojo::String& interface_name, | 58 void InterfaceRegistry::GetInterface(const mojo::String& interface_name, |
59 mojo::ScopedMessagePipeHandle handle) { | 59 mojo::ScopedMessagePipeHandle handle) { |
60 if (is_paused_) { | 60 if (is_paused_) { |
61 pending_interface_requests_.emplace(interface_name, std::move(handle)); | 61 pending_interface_requests_.emplace(interface_name, std::move(handle)); |
62 return; | 62 return; |
63 } | 63 } |
64 | 64 |
65 auto iter = name_to_binder_.find(interface_name); | 65 auto iter = name_to_binder_.find(interface_name); |
66 if (iter != name_to_binder_.end()) { | 66 if (iter != name_to_binder_.end()) { |
67 iter->second->BindInterface(connection_, interface_name, std::move(handle)); | 67 iter->second->BindInterface(connection_->GetRemoteIdentity(), |
Ken Rockot(use gerrit already)
2016/07/26 00:14:46
None of the uses with a null connection need the r
| |
68 interface_name, | |
69 std::move(handle)); | |
68 } else if (connection_ && !connection_->AllowsInterface(interface_name)) { | 70 } else if (connection_ && !connection_->AllowsInterface(interface_name)) { |
69 LOG(ERROR) << "Connection CapabilityFilter prevented binding to " | 71 LOG(ERROR) << "Connection CapabilityFilter prevented binding to " |
70 << "interface: " << interface_name << " connection_name:" | 72 << "interface: " << interface_name << " connection_name:" |
71 << connection_->GetConnectionName() << " remote_name:" | 73 << connection_->GetConnectionName() << " remote_name:" |
72 << connection_->GetRemoteIdentity().name(); | 74 << connection_->GetRemoteIdentity().name(); |
73 } else if (!default_binder_.is_null()) { | 75 } else if (!default_binder_.is_null()) { |
74 default_binder_.Run(interface_name, std::move(handle)); | 76 default_binder_.Run(interface_name, std::move(handle)); |
77 } else { | |
78 LOG(ERROR) << "Failed to locate a binder for interface: " << interface_name; | |
75 } | 79 } |
76 } | 80 } |
77 | 81 |
78 bool InterfaceRegistry::SetInterfaceBinderForName( | 82 bool InterfaceRegistry::SetInterfaceBinderForName( |
79 std::unique_ptr<InterfaceBinder> binder, | 83 std::unique_ptr<InterfaceBinder> binder, |
80 const std::string& interface_name) { | 84 const std::string& interface_name) { |
81 if (!connection_ || | 85 if (!connection_ || |
82 (connection_ && connection_->AllowsInterface(interface_name))) { | 86 (connection_ && connection_->AllowsInterface(interface_name))) { |
83 RemoveInterface(interface_name); | 87 RemoveInterface(interface_name); |
84 name_to_binder_[interface_name] = std::move(binder); | 88 name_to_binder_[interface_name] = std::move(binder); |
85 return true; | 89 return true; |
86 } | 90 } |
87 return false; | 91 return false; |
88 } | 92 } |
89 | 93 |
90 } // namespace shell | 94 } // namespace shell |
OLD | NEW |