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/coordination_unit/coordination_unit_prov
ider_impl.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 9 #include "services/resource_coordinator/coordination_unit/coordination_unit_impl
.h" |
| 10 #include "services/service_manager/public/cpp/connection.h" |
| 11 |
| 12 namespace resource_coordinator { |
| 13 |
| 14 CoordinationUnitProviderImpl::CoordinationUnitProviderImpl( |
| 15 service_manager::ServiceContextRefFactory* service_ref_factory) |
| 16 : service_ref_factory_(service_ref_factory) { |
| 17 if (service_ref_factory) |
| 18 service_ref_ = service_ref_factory->CreateRef(); |
| 19 } |
| 20 |
| 21 CoordinationUnitProviderImpl::~CoordinationUnitProviderImpl() = default; |
| 22 |
| 23 void CoordinationUnitProviderImpl::CreateCoordinationUnit( |
| 24 mojom::CoordinationUnitRequest request, |
| 25 const CoordinationUnitID& id) { |
| 26 // TODO(oysteine): A strong binding here means the first binding set up |
| 27 // to a CoordinationUnit via CoordinationUnitProvider, i.e. the authoritative |
| 28 // one in terms of setting the context, has to outlive all of the other |
| 29 // connections (as the rest are just duplicated and held within |
| 30 // CoordinationUnit). Make sure this assumption is correct, or refactor into |
| 31 // some kind of refcounted thing. |
| 32 |
| 33 std::unique_ptr<service_manager::ServiceContextRef> service_ref; |
| 34 if (service_ref_factory_) |
| 35 service_ref = service_ref_factory_->CreateRef(); |
| 36 |
| 37 mojo::MakeStrongBinding( |
| 38 base::MakeUnique<CoordinationUnitImpl>(id, std::move(service_ref)), |
| 39 std::move(request)); |
| 40 }; |
| 41 |
| 42 } // namespace resource_coordinator |
OLD | NEW |