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

Unified Diff: services/shape_detection/shape_detection_service.cc

Issue 2528743002: Shape Detection: Implement FaceDetection on Mac as out-of-process service (Closed)
Patch Set: Rebase Created 3 years, 11 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
« no previous file with comments | « services/shape_detection/shape_detection_service.h ('k') | third_party/WebKit/LayoutTests/TestExpectations » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/shape_detection/shape_detection_service.cc
diff --git a/services/shape_detection/shape_detection_service.cc b/services/shape_detection/shape_detection_service.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d9210e9ef4888bfe47448e67487ba69f80d4bc47
--- /dev/null
+++ b/services/shape_detection/shape_detection_service.cc
@@ -0,0 +1,53 @@
+// 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/shape_detection/shape_detection_service.h"
+
+#include "base/macros.h"
+#include "services/service_manager/public/cpp/interface_registry.h"
+#include "services/service_manager/public/cpp/service_context.h"
+#include "services/shape_detection/face_detection_provider_impl.h"
+
+namespace shape_detection {
+
+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.
+}
+}
+
+std::unique_ptr<service_manager::Service> ShapeDetectionService::Create() {
+ return base::MakeUnique<ShapeDetectionService>();
+}
+
+ShapeDetectionService::ShapeDetectionService() = default;
+
+ShapeDetectionService::~ShapeDetectionService() = default;
+
+void ShapeDetectionService::OnStart() {
+ ref_factory_.reset(new service_manager::ServiceContextRefFactory(
+ base::Bind(&service_manager::ServiceContext::RequestQuit,
+ base::Unretained(context()))));
+}
+
+bool ShapeDetectionService::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 =
+ ref_factory_->CreateRef();
+ registry->AddConnectionLostClosure(
+ base::Bind(&OnConnectionLost, base::Passed(&connection_ref)));
+ registry->AddInterface(base::Bind(&FaceDetectionProviderImpl::Create));
+ return true;
+}
+
+bool ShapeDetectionService::OnStop() {
+ return true;
+}
+
+} // namespace shape_detection
« no previous file with comments | « services/shape_detection/shape_detection_service.h ('k') | third_party/WebKit/LayoutTests/TestExpectations » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698