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

Unified Diff: services/service_manager/service_manager.cc

Issue 2795883002: Eliminate OnConnect usage (Closed)
Patch Set: . Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: services/service_manager/service_manager.cc
diff --git a/services/service_manager/service_manager.cc b/services/service_manager/service_manager.cc
index e3532537ce9f91ef19695cd21b4bedd84e1e4c47..2a0150437eb4d2e4575991f0e6dd78b22f2b58f0 100644
--- a/services/service_manager/service_manager.cc
+++ b/services/service_manager/service_manager.cc
@@ -107,7 +107,6 @@ class ServiceManager::Instance
: public mojom::Connector,
public mojom::PIDReceiver,
public Service,
- public InterfaceFactory<mojom::ServiceManager>,
public mojom::ServiceManager,
public mojom::ServiceControl {
public:
@@ -279,17 +278,19 @@ class ServiceManager::Instance
uint32_t id() const { return id_; }
// Service:
- bool OnConnect(const ServiceInfo& remote_info,
- InterfaceRegistry* registry) override {
+ void OnBindInterface(const ServiceInfo& source_info,
+ const std::string& interface_name,
+ mojo::ScopedMessagePipeHandle interface_pipe) override {
Instance* source =
- service_manager_->GetExistingInstance(remote_info.identity);
+ service_manager_->GetExistingInstance(source_info.identity);
DCHECK(source);
- if (HasCapability(source->GetConnectionSpec(),
+ if (interface_name == mojom::ServiceManager::Name_ &&
+ HasCapability(source->GetConnectionSpec(),
kCapability_ServiceManager)) {
- registry->AddInterface<mojom::ServiceManager>(this);
- return true;
+ mojom::ServiceManagerRequest request =
+ mojo::MakeRequest<mojom::ServiceManager>(std::move(interface_pipe));
+ service_manager_bindings_.AddBinding(this, std::move(request));
}
- return false;
}
private:
@@ -376,12 +377,6 @@ class ServiceManager::Instance
PIDAvailable(pid);
}
- // InterfaceFactory<mojom::ServiceManager>:
- void Create(const Identity& remote_identity,
- mojom::ServiceManagerRequest request) override {
- service_manager_bindings_.AddBinding(this, std::move(request));
- }
-
// mojom::ServiceManager implementation:
void AddListener(mojom::ServiceManagerListenerPtr listener) override {
// TODO(beng): this should only track the instances matching this user, and
@@ -580,22 +575,24 @@ class ServiceManager::ServiceImpl : public Service {
~ServiceImpl() override {}
// Service:
- bool OnConnect(const ServiceInfo& remote_info,
- InterfaceRegistry* registry) override {
+ void OnBindInterface(const ServiceInfo& source_info,
+ const std::string& interface_name,
+ mojo::ScopedMessagePipeHandle interface_pipe) override {
// The only interface ServiceManager exposes is mojom::ServiceManager, and
// access to this interface is brokered by a policy specific to each caller,
// managed by the caller's instance. Here we look to see who's calling,
// and forward to the caller's instance to continue.
Instance* instance = nullptr;
for (const auto& entry : service_manager_->identity_to_instance_) {
- if (entry.first == remote_info.identity) {
+ if (entry.first == source_info.identity) {
instance = entry.second;
break;
}
}
DCHECK(instance);
- return instance->OnConnect(remote_info, registry);
+ instance->OnBindInterface(source_info, interface_name,
+ std::move(interface_pipe));
}
private:
« no previous file with comments | « services/service_manager/service_manager.h ('k') | services/service_manager/tests/connect/connect_test_exe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698