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

Unified Diff: services/resource_coordinator/resource_coordinator_service.cc

Issue 2710823003: NOCOMMIT prototype: GRC service plumbing and process priority
Patch Set: Buildfixes Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: services/resource_coordinator/resource_coordinator_service.cc
diff --git a/services/resource_coordinator/resource_coordinator_service.cc b/services/resource_coordinator/resource_coordinator_service.cc
new file mode 100644
index 0000000000000000000000000000000000000000..804f580ca9e62cbbadb4c73f516728468c7179a8
--- /dev/null
+++ b/services/resource_coordinator/resource_coordinator_service.cc
@@ -0,0 +1,51 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "services/resource_coordinator/resource_coordinator_service.h"
+
+#include "base/macros.h"
+#include "services/resource_coordinator/coordination_unit_provider.h"
+#include "services/service_manager/public/cpp/interface_registry.h"
+#include "services/service_manager/public/cpp/service_context.h"
+
+namespace resource_coordinator {
+
+namespace {
+
+void OnConnectionLost(std::unique_ptr<service_manager::ServiceContextRef> ref) {
+ // No-op. This merely takes ownership of |ref| so it can be destroyed when
+ // this function is invoked.
+}
+
+} // namespace
+
+std::unique_ptr<service_manager::Service> ResourceCoordinatorService::Create() {
+ return base::MakeUnique<ResourceCoordinatorService>();
+}
+
+ResourceCoordinatorService::ResourceCoordinatorService()
+ : weak_factory_(this) {}
+
+ResourceCoordinatorService::~ResourceCoordinatorService() = default;
+
+void ResourceCoordinatorService::OnStart() {
+ ref_factory_.reset(new service_manager::ServiceContextRefFactory(
+ base::Bind(&service_manager::ServiceContext::RequestQuit,
+ base::Unretained(context()))));
+}
+
+bool ResourceCoordinatorService::OnConnect(
+ const service_manager::ServiceInfo& remote_info,
+ service_manager::InterfaceRegistry* registry) {
+ // Add a reference to the service and tie it to the lifetime of the
+ // InterfaceRegistry's connection.
+ std::unique_ptr<service_manager::ServiceContextRef> connection_ref =
Ken Rockot(use gerrit already) 2017/03/15 22:51:55 So as a preface, the ServiceContextRef stuff is ki
+ ref_factory_->CreateRef();
+ registry->AddConnectionLostClosure(
+ base::Bind(&OnConnectionLost, base::Passed(&connection_ref)));
+ registry->AddInterface(base::Bind(&CoordinationUnitProvider::Create));
+ return true;
+}
+
+} // namespace speed

Powered by Google App Engine
This is Rietveld 408576698