Chromium Code Reviews| Index: services/resource_coordinator/service_callbacks_impl.cc |
| diff --git a/services/resource_coordinator/service_callbacks_impl.cc b/services/resource_coordinator/service_callbacks_impl.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..80d070507fb169c441e3be4ab6f2bcd56e0dd28e |
| --- /dev/null |
| +++ b/services/resource_coordinator/service_callbacks_impl.cc |
| @@ -0,0 +1,51 @@ |
| +// 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/service_callbacks_impl.h" |
| + |
| +#include <utility> |
| + |
| +#include "base/memory/ptr_util.h" |
| +#include "components/ukm/public/mojo_ukm_recorder.h" |
| +#include "services/resource_coordinator/resource_coordinator_service.h" |
| +#include "services/service_manager/public/cpp/service_context_ref.h" |
| + |
| +namespace resource_coordinator { |
| + |
| +ServiceCallbacksImpl::ServiceCallbacksImpl( |
| + service_manager::ServiceContextRefFactory* service_ref_factory, |
| + ResourceCoordinatorService* resource_coordinator_service) |
| + : service_ref_factory_(service_ref_factory), |
|
dcheng
2017/06/23 16:10:35
What's the reason we need to hang on to a pointer
matthalp
2017/06/23 16:36:28
The service is ref-counted, so holding a reference
dcheng
2017/06/23 21:32:32
Right, but isn't the ref created and held below on
matthalp
2017/06/23 21:56:13
Yes, you are correct. Sorry for the confusion. I'v
|
| + resource_coordinator_service_(resource_coordinator_service) { |
| + DCHECK(service_ref_factory); |
| + service_ref_ = service_ref_factory_->CreateRef(); |
| +} |
| + |
| +ServiceCallbacksImpl::~ServiceCallbacksImpl() = default; |
| + |
| +// static |
| +void ServiceCallbacksImpl::Create( |
| + service_manager::ServiceContextRefFactory* service_ref_factory, |
| + ResourceCoordinatorService* resource_coordinator_service, |
| + const service_manager::BindSourceInfo& source_info, |
| + resource_coordinator::mojom::ServiceCallbacksRequest request) { |
| + mojo::MakeStrongBinding( |
| + base::MakeUnique<ServiceCallbacksImpl>(service_ref_factory, |
| + resource_coordinator_service), |
| + std::move(request)); |
| +} |
| + |
| +void ServiceCallbacksImpl::SetUkmRecorderInterface( |
| + ukm::mojom::UkmRecorderInterfacePtr ukm_recorder_interface) { |
| + resource_coordinator_service_->SetUkmRecorder( |
| + base::MakeUnique<ukm::MojoUkmRecorder>( |
| + std::move(ukm_recorder_interface))); |
| +} |
| + |
| +void ServiceCallbacksImpl::IsUkmRecorderInterfaceInitialized( |
| + const IsUkmRecorderInterfaceInitializedCallback& callback) { |
| + callback.Run(resource_coordinator_service_->ukm_recorder() != nullptr); |
| +} |
| + |
| +} // namespace resource_coordinator |