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

Side by Side Diff: services/resource_coordinator/resource_coordinator_service.cc

Issue 2798713002: Global Resource Coordinator: Basic service internals (Closed)
Patch Set: Review fixes 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/resource_coordinator_service.h"
6
7 #include "base/macros.h"
8 #include "services/resource_coordinator/coordination_unit/coordination_unit_prov ider_impl.h"
9 #include "services/service_manager/public/cpp/interface_registry.h"
10 #include "services/service_manager/public/cpp/service_context.h"
11
12 namespace resource_coordinator {
13
14 namespace {
15
16 void OnConnectionLost(std::unique_ptr<service_manager::ServiceContextRef> ref) {
17 // No-op. This merely takes ownership of |ref| so it can be destroyed when
18 // this function is invoked.
19 }
20
21 } // namespace
22
23 std::unique_ptr<service_manager::Service> ResourceCoordinatorService::Create() {
24 return base::MakeUnique<ResourceCoordinatorService>();
25 }
26
27 ResourceCoordinatorService::ResourceCoordinatorService()
28 : weak_factory_(this) {}
29
30 ResourceCoordinatorService::~ResourceCoordinatorService() = default;
31
32 void ResourceCoordinatorService::OnStart() {
33 ref_factory_.reset(new service_manager::ServiceContextRefFactory(
34 base::Bind(&service_manager::ServiceContext::RequestQuit,
35 base::Unretained(context()))));
36 }
37
38 bool ResourceCoordinatorService::OnConnect(
Ken Rockot(use gerrit already) 2017/04/10 23:58:00 Please just implement OnBindInterface instead of O
oystein (OOO til 10th of July) 2017/04/12 19:15:31 Done.
39 const service_manager::ServiceInfo& remote_info,
40 service_manager::InterfaceRegistry* registry) {
41 // Add a reference to the service and tie it to the lifetime of the
42 // InterfaceRegistry's connection.
43 std::unique_ptr<service_manager::ServiceContextRef> connection_ref =
44 ref_factory_->CreateRef();
45 registry->AddConnectionLostClosure(
46 base::Bind(&OnConnectionLost, base::Passed(&connection_ref)));
47 registry->AddInterface(base::Bind(&CoordinationUnitProviderImpl::Create,
48 base::Unretained(ref_factory_.get())));
49 return true;
50 }
51
52 } // namespace speed
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698