OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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/resource_coordinator/resource_coordinator_service.h" | 5 #include "services/resource_coordinator/resource_coordinator_service.h" |
6 | 6 |
7 #include <string> | |
8 #include <utility> | 7 #include <utility> |
9 | 8 |
10 #include "base/macros.h" | 9 #include "services/resource_coordinator/service_callbacks_impl.h" |
11 #include "services/resource_coordinator/coordination_unit/coordination_unit_prov
ider_impl.h" | |
12 #include "services/service_manager/public/cpp/service_context.h" | 10 #include "services/service_manager/public/cpp/service_context.h" |
13 | 11 |
14 namespace resource_coordinator { | 12 namespace resource_coordinator { |
15 | 13 |
16 std::unique_ptr<service_manager::Service> ResourceCoordinatorService::Create() { | 14 std::unique_ptr<service_manager::Service> ResourceCoordinatorService::Create() { |
17 return base::MakeUnique<ResourceCoordinatorService>(); | 15 return base::MakeUnique<ResourceCoordinatorService>(); |
18 } | 16 } |
19 | 17 |
20 ResourceCoordinatorService::ResourceCoordinatorService() | 18 ResourceCoordinatorService::ResourceCoordinatorService() |
21 : weak_factory_(this) {} | 19 : weak_factory_(this) {} |
22 | 20 |
23 ResourceCoordinatorService::~ResourceCoordinatorService() = default; | 21 ResourceCoordinatorService::~ResourceCoordinatorService() = default; |
24 | 22 |
25 void ResourceCoordinatorService::OnStart() { | 23 void ResourceCoordinatorService::OnStart() { |
26 ref_factory_.reset(new service_manager::ServiceContextRefFactory( | 24 ref_factory_.reset(new service_manager::ServiceContextRefFactory( |
27 base::Bind(&service_manager::ServiceContext::RequestQuit, | 25 base::Bind(&service_manager::ServiceContext::RequestQuit, |
28 base::Unretained(context())))); | 26 base::Unretained(context())))); |
29 | 27 |
| 28 registry_.AddInterface(base::Bind(ServiceCallbacksImpl::Create, |
| 29 base::Unretained(ref_factory_.get()), |
| 30 base::Unretained(this))); |
| 31 |
30 coordination_unit_manager_.OnStart(®istry_, ref_factory_.get()); | 32 coordination_unit_manager_.OnStart(®istry_, ref_factory_.get()); |
31 } | 33 } |
32 | 34 |
33 void ResourceCoordinatorService::OnBindInterface( | 35 void ResourceCoordinatorService::OnBindInterface( |
34 const service_manager::BindSourceInfo& source_info, | 36 const service_manager::BindSourceInfo& source_info, |
35 const std::string& interface_name, | 37 const std::string& interface_name, |
36 mojo::ScopedMessagePipeHandle interface_pipe) { | 38 mojo::ScopedMessagePipeHandle interface_pipe) { |
37 registry_.BindInterface(source_info, interface_name, | 39 registry_.BindInterface(source_info, interface_name, |
38 std::move(interface_pipe)); | 40 std::move(interface_pipe)); |
39 } | 41 } |
40 | 42 |
| 43 void ResourceCoordinatorService::SetUkmRecorder( |
| 44 std::unique_ptr<ukm::MojoUkmRecorder> ukm_recorder) { |
| 45 ukm_recorder_ = std::move(ukm_recorder); |
| 46 coordination_unit_manager_.SetUkmRecorder(ukm_recorder_.get()); |
| 47 } |
| 48 |
41 } // namespace resource_coordinator | 49 } // namespace resource_coordinator |
OLD | NEW |