Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: services/resource_coordinator/coordination_unit/coordination_unit_provider_impl.cc

Issue 2798713002: Global Resource Coordinator: Basic service internals (Closed)
Patch Set: Buildfix after rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 <memory>
8 #include <utility>
9
10 #include "base/logging.h"
11 #include "mojo/public/cpp/bindings/strong_binding.h"
12 #include "services/resource_coordinator/coordination_unit/coordination_unit_impl .h"
13 #include "services/service_manager/public/cpp/service_context_ref.h"
14
15 namespace resource_coordinator {
16
17 CoordinationUnitProviderImpl::CoordinationUnitProviderImpl(
18 service_manager::ServiceContextRefFactory* service_ref_factory)
19 : service_ref_factory_(service_ref_factory) {
20 DCHECK(service_ref_factory);
21 service_ref_ = service_ref_factory->CreateRef();
22 }
23
24 CoordinationUnitProviderImpl::~CoordinationUnitProviderImpl() = default;
25
26 void CoordinationUnitProviderImpl::CreateCoordinationUnit(
27 mojom::CoordinationUnitRequest request,
28 const CoordinationUnitID& id) {
29 // TODO(oysteine): A strong binding here means the first binding set up
30 // to a CoordinationUnit via CoordinationUnitProvider, i.e. the authoritative
31 // one in terms of setting the context, has to outlive all of the other
32 // connections (as the rest are just duplicated and held within
33 // CoordinationUnit). Make sure this assumption is correct, or refactor into
34 // some kind of refcounted thing.
35
36 // Once there's a need for custom code for various types of CUs (tabs,
37 // processes, etc) then this could become a factory function and instantiate
38 // different subclasses of CoordinationUnitImpl based on the id.type.
39 mojo::MakeStrongBinding(base::MakeUnique<CoordinationUnitImpl>(
40 id, service_ref_factory_->CreateRef()),
41 std::move(request));
42 };
43
44 // static
45 void CoordinationUnitProviderImpl::Create(
46 service_manager::ServiceContextRefFactory* service_ref_factory,
47 const service_manager::BindSourceInfo& source_info,
48 resource_coordinator::mojom::CoordinationUnitProviderRequest request) {
49 mojo::MakeStrongBinding(
50 base::MakeUnique<CoordinationUnitProviderImpl>(service_ref_factory),
51 std::move(request));
52 }
53
54 } // namespace resource_coordinator
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698