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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: services/resource_coordinator/coordination_unit/coordination_unit_provider_impl.cc
diff --git a/services/resource_coordinator/coordination_unit/coordination_unit_provider_impl.cc b/services/resource_coordinator/coordination_unit/coordination_unit_provider_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e6a6ae05668cb7646353a6414e7dc3524dedd318
--- /dev/null
+++ b/services/resource_coordinator/coordination_unit/coordination_unit_provider_impl.cc
@@ -0,0 +1,54 @@
+// 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/coordination_unit/coordination_unit_provider_impl.h"
+
+#include "base/logging.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
+#include "services/resource_coordinator/coordination_unit/coordination_unit_impl.h"
+#include "services/service_manager/public/cpp/service_context_ref.h"
+
+namespace resource_coordinator {
+
+CoordinationUnitProviderImpl::CoordinationUnitProviderImpl(
+ service_manager::ServiceContextRefFactory* service_ref_factory)
+ : service_ref_factory_(service_ref_factory) {
+ 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.
+ service_ref_ = service_ref_factory->CreateRef();
+}
+
+CoordinationUnitProviderImpl::~CoordinationUnitProviderImpl() = default;
+
+void CoordinationUnitProviderImpl::CreateCoordinationUnit(
+ mojom::CoordinationUnitRequest request,
+ const CoordinationUnitID& id) {
+ // TODO(oysteine): A strong binding here means the first binding set up
+ // to a CoordinationUnit via CoordinationUnitProvider, i.e. the authoritative
+ // one in terms of setting the context, has to outlive all of the other
+ // connections (as the rest are just duplicated and held within
+ // CoordinationUnit). Make sure this assumption is correct, or refactor into
+ // some kind of refcounted thing.
+
+ 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.
+ if (service_ref_factory_)
+ service_ref = service_ref_factory_->CreateRef();
+
+ // Once there's a need for custom code for various types of CUs (tabs,
+ // processes, etc) then this could become a factory function and instantiate
+ // different subclasses of CoordinationUnitImpl based on the id.type.
+ mojo::MakeStrongBinding(
+ base::MakeUnique<CoordinationUnitImpl>(id, std::move(service_ref)),
+ std::move(request));
+};
+
+// static
+void CoordinationUnitProviderImpl::Create(
+ service_manager::ServiceContextRefFactory* service_ref_factory,
+ resource_coordinator::mojom::CoordinationUnitProviderRequest request) {
+ mojo::MakeStrongBinding(
+ base::MakeUnique<CoordinationUnitProviderImpl>(service_ref_factory),
+ std::move(request));
+}
+
+} // namespace resource_coordinator

Powered by Google App Engine
This is Rietveld 408576698