Chromium Code Reviews| Index: services/resource_coordinator/resource_coordinator_service.cc |
| diff --git a/services/resource_coordinator/resource_coordinator_service.cc b/services/resource_coordinator/resource_coordinator_service.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..fa424984357f04dab49f43b097e1872fa355f521 |
| --- /dev/null |
| +++ b/services/resource_coordinator/resource_coordinator_service.cc |
| @@ -0,0 +1,52 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "services/resource_coordinator/resource_coordinator_service.h" |
| + |
| +#include "base/macros.h" |
| +#include "services/resource_coordinator/coordination_unit/coordination_unit_provider_impl.h" |
| +#include "services/service_manager/public/cpp/interface_registry.h" |
| +#include "services/service_manager/public/cpp/service_context.h" |
| + |
| +namespace resource_coordinator { |
| + |
| +namespace { |
| + |
| +void OnConnectionLost(std::unique_ptr<service_manager::ServiceContextRef> ref) { |
| + // No-op. This merely takes ownership of |ref| so it can be destroyed when |
| + // this function is invoked. |
| +} |
| + |
| +} // namespace |
| + |
| +std::unique_ptr<service_manager::Service> ResourceCoordinatorService::Create() { |
| + return base::MakeUnique<ResourceCoordinatorService>(); |
| +} |
| + |
| +ResourceCoordinatorService::ResourceCoordinatorService() |
| + : weak_factory_(this) {} |
| + |
| +ResourceCoordinatorService::~ResourceCoordinatorService() = default; |
| + |
| +void ResourceCoordinatorService::OnStart() { |
| + ref_factory_.reset(new service_manager::ServiceContextRefFactory( |
| + base::Bind(&service_manager::ServiceContext::RequestQuit, |
| + base::Unretained(context())))); |
| +} |
| + |
| +bool ResourceCoordinatorService::OnConnect( |
|
Ken Rockot(use gerrit already)
2017/04/10 23:58:00
Please just implement OnBindInterface instead of O
oystein (OOO til 10th of July)
2017/04/12 19:15:31
Done.
|
| + const service_manager::ServiceInfo& remote_info, |
| + service_manager::InterfaceRegistry* registry) { |
| + // Add a reference to the service and tie it to the lifetime of the |
| + // InterfaceRegistry's connection. |
| + std::unique_ptr<service_manager::ServiceContextRef> connection_ref = |
| + ref_factory_->CreateRef(); |
| + registry->AddConnectionLostClosure( |
| + base::Bind(&OnConnectionLost, base::Passed(&connection_ref))); |
| + registry->AddInterface(base::Bind(&CoordinationUnitProviderImpl::Create, |
| + base::Unretained(ref_factory_.get()))); |
| + return true; |
| +} |
| + |
| +} // namespace speed |