| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 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/shape_detection/shape_detection_service.h" |
| 6 |
| 7 #include "base/macros.h" |
| 8 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 9 #include "services/service_manager/public/cpp/interface_registry.h" |
| 10 #include "services/service_manager/public/cpp/service_context.h" |
| 11 #include "services/shape_detection/face_detection_impl.h" |
| 12 |
| 13 namespace shape_detection { |
| 14 |
| 15 namespace { |
| 16 |
| 17 void OnConnectionLost(std::unique_ptr<service_manager::ServiceContextRef> ref) { |
| 18 // No-op. This merely takes ownership of |ref| so it can be destroyed when |
| 19 // this function is invoked. |
| 20 } |
| 21 |
| 22 } |
| 23 |
| 24 std::unique_ptr<service_manager::Service> ShapeDetectionService::Create() { |
| 25 return base::MakeUnique<ShapeDetectionService>(); |
| 26 } |
| 27 |
| 28 ShapeDetectionService::ShapeDetectionService() = default; |
| 29 |
| 30 ShapeDetectionService::~ShapeDetectionService() = default; |
| 31 |
| 32 void ShapeDetectionService::OnStart() { |
| 33 ref_factory_.reset(new service_manager::ServiceContextRefFactory( |
| 34 base::Bind(&service_manager::ServiceContext::RequestQuit, |
| 35 base::Unretained(context())))); |
| 36 } |
| 37 |
| 38 bool ShapeDetectionService::OnConnect( |
| 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(&FaceDetectionImpl::Create)); |
| 48 return true; |
| 49 } |
| 50 |
| 51 bool ShapeDetectionService::OnStop() { |
| 52 return true; |
| 53 } |
| 54 |
| 55 } // namespace shape_detection |
| OLD | NEW |