OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "services/resource_coordinator/resource_coordinator_service.h" | |
6 | |
7 #include "base/macros.h" | |
8 #include "services/resource_coordinator/coordination_unit_provider.h" | |
9 #include "services/service_manager/public/cpp/interface_registry.h" | |
10 #include "services/service_manager/public/cpp/service_context.h" | |
11 | |
12 namespace resource_coordinator { | |
13 | |
14 namespace { | |
15 | |
16 void OnConnectionLost(std::unique_ptr<service_manager::ServiceContextRef> ref) { | |
17 // No-op. This merely takes ownership of |ref| so it can be destroyed when | |
18 // this function is invoked. | |
19 } | |
20 | |
21 } // namespace | |
22 | |
23 std::unique_ptr<service_manager::Service> ResourceCoordinatorService::Create() { | |
24 return base::MakeUnique<ResourceCoordinatorService>(); | |
25 } | |
26 | |
27 ResourceCoordinatorService::ResourceCoordinatorService() | |
28 : weak_factory_(this) {} | |
29 | |
30 ResourceCoordinatorService::~ResourceCoordinatorService() = default; | |
31 | |
32 void ResourceCoordinatorService::OnStart() { | |
33 ref_factory_.reset(new service_manager::ServiceContextRefFactory( | |
34 base::Bind(&service_manager::ServiceContext::RequestQuit, | |
35 base::Unretained(context())))); | |
36 } | |
37 | |
38 bool ResourceCoordinatorService::OnConnect( | |
39 const service_manager::ServiceInfo& remote_info, | |
40 service_manager::InterfaceRegistry* registry) { | |
41 // Add a reference to the service and tie it to the lifetime of the | |
42 // InterfaceRegistry's connection. | |
43 std::unique_ptr<service_manager::ServiceContextRef> connection_ref = | |
Ken Rockot(use gerrit already)
2017/03/15 22:51:55
So as a preface, the ServiceContextRef stuff is ki
| |
44 ref_factory_->CreateRef(); | |
45 registry->AddConnectionLostClosure( | |
46 base::Bind(&OnConnectionLost, base::Passed(&connection_ref))); | |
47 registry->AddInterface(base::Bind(&CoordinationUnitProvider::Create)); | |
48 return true; | |
49 } | |
50 | |
51 } // namespace speed | |
OLD | NEW |