Chromium Code Reviews| 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/service_callbacks_impl.h" | |
| 6 | |
| 7 #include <utility> | |
| 8 | |
| 9 #include "base/memory/ptr_util.h" | |
| 10 #include "components/ukm/public/mojo_ukm_recorder.h" | |
| 11 #include "services/resource_coordinator/resource_coordinator_service.h" | |
| 12 #include "services/service_manager/public/cpp/service_context_ref.h" | |
| 13 | |
| 14 namespace resource_coordinator { | |
| 15 | |
| 16 ServiceCallbacksImpl::ServiceCallbacksImpl( | |
| 17 service_manager::ServiceContextRefFactory* service_ref_factory, | |
| 18 ResourceCoordinatorService* resource_coordinator_service) | |
| 19 : 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
 
 | |
| 20 resource_coordinator_service_(resource_coordinator_service) { | |
| 21 DCHECK(service_ref_factory); | |
| 22 service_ref_ = service_ref_factory_->CreateRef(); | |
| 23 } | |
| 24 | |
| 25 ServiceCallbacksImpl::~ServiceCallbacksImpl() = default; | |
| 26 | |
| 27 // static | |
| 28 void ServiceCallbacksImpl::Create( | |
| 29 service_manager::ServiceContextRefFactory* service_ref_factory, | |
| 30 ResourceCoordinatorService* resource_coordinator_service, | |
| 31 const service_manager::BindSourceInfo& source_info, | |
| 32 resource_coordinator::mojom::ServiceCallbacksRequest request) { | |
| 33 mojo::MakeStrongBinding( | |
| 34 base::MakeUnique<ServiceCallbacksImpl>(service_ref_factory, | |
| 35 resource_coordinator_service), | |
| 36 std::move(request)); | |
| 37 } | |
| 38 | |
| 39 void ServiceCallbacksImpl::SetUkmRecorderInterface( | |
| 40 ukm::mojom::UkmRecorderInterfacePtr ukm_recorder_interface) { | |
| 41 resource_coordinator_service_->SetUkmRecorder( | |
| 42 base::MakeUnique<ukm::MojoUkmRecorder>( | |
| 43 std::move(ukm_recorder_interface))); | |
| 44 } | |
| 45 | |
| 46 void ServiceCallbacksImpl::IsUkmRecorderInterfaceInitialized( | |
| 47 const IsUkmRecorderInterfaceInitializedCallback& callback) { | |
| 48 callback.Run(resource_coordinator_service_->ukm_recorder() != nullptr); | |
| 49 } | |
| 50 | |
| 51 } // namespace resource_coordinator | |
| OLD | NEW |