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

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: Wrap EventType directly in resource_coordinator namespace when using helper Created 3 years, 8 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 "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/service_context_ref.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)
dcheng 2017/04/18 05:40:46 I'm assuming this is one of those null for testing
oystein (OOO til 10th of July) 2017/04/18 20:55:33 Done.
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;
dcheng 2017/04/18 05:40:46 #include <memory> (and <utility>) here and elsewhe
oystein (OOO til 10th of July) 2017/04/18 20:55:33 Done.
34 if (service_ref_factory_)
35 service_ref = service_ref_factory_->CreateRef();
36
37 // Once there's a need for custom code for various types of CUs (tabs,
38 // processes, etc) then this could become a factory function and instantiate
39 // different subclasses of CoordinationUnitImpl based on the id.type.
40 mojo::MakeStrongBinding(
41 base::MakeUnique<CoordinationUnitImpl>(id, std::move(service_ref)),
42 std::move(request));
43 };
44
45 // static
46 void CoordinationUnitProviderImpl::Create(
47 service_manager::ServiceContextRefFactory* service_ref_factory,
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