Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "services/shape_detection/shape_detection_service.h" | 5 #include "services/shape_detection/shape_detection_service.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "services/service_manager/public/cpp/interface_registry.h" | 8 #include "services/service_manager/public/cpp/interface_registry.h" |
| 9 #include "services/service_manager/public/cpp/service_context.h" | 9 #include "services/service_manager/public/cpp/service_context.h" |
| 10 #include "services/shape_detection/barcode_detection_impl.h" | |
| 10 #include "services/shape_detection/face_detection_provider_impl.h" | 11 #include "services/shape_detection/face_detection_provider_impl.h" |
| 11 | 12 |
| 12 namespace shape_detection { | 13 namespace shape_detection { |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 void OnConnectionLost(std::unique_ptr<service_manager::ServiceContextRef> ref) { | 17 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 // No-op. This merely takes ownership of |ref| so it can be destroyed when |
| 18 // this function is invoked. | 19 // this function is invoked. |
| 19 } | 20 } |
| 20 } | 21 } |
| 21 | 22 |
| 22 std::unique_ptr<service_manager::Service> ShapeDetectionService::Create() { | 23 std::unique_ptr<service_manager::Service> ShapeDetectionService::Create() { |
| 23 return base::MakeUnique<ShapeDetectionService>(); | 24 return base::MakeUnique<ShapeDetectionService>(); |
| 24 } | 25 } |
| 25 | 26 |
| 26 ShapeDetectionService::ShapeDetectionService() = default; | 27 ShapeDetectionService::ShapeDetectionService() = default; |
| 27 | 28 |
| 28 ShapeDetectionService::~ShapeDetectionService() = default; | 29 ShapeDetectionService::~ShapeDetectionService() = default; |
| 29 | 30 |
| 30 void ShapeDetectionService::OnStart() { | 31 void ShapeDetectionService::OnStart() { |
| 31 ref_factory_.reset(new service_manager::ServiceContextRefFactory( | 32 ref_factory_.reset(new service_manager::ServiceContextRefFactory( |
| 32 base::Bind(&service_manager::ServiceContext::RequestQuit, | 33 base::Bind(&service_manager::ServiceContext::RequestQuit, |
| 33 base::Unretained(context())))); | 34 base::Unretained(context())))); |
| 34 } | 35 } |
| 35 | 36 |
| 36 bool ShapeDetectionService::OnConnect( | 37 bool ShapeDetectionService::OnConnect( |
| 37 const service_manager::ServiceInfo& remote_info, | 38 const service_manager::ServiceInfo& remote_info, |
| 38 service_manager::InterfaceRegistry* registry) { | 39 service_manager::InterfaceRegistry* registry) { |
| 40 DVLOG(1) << __func__; | |
|
Robert Sesek
2017/02/01 19:34:11
Remove?
mcasas
2017/02/01 20:40:21
Oops, done.
| |
| 39 // Add a reference to the service and tie it to the lifetime of the | 41 // Add a reference to the service and tie it to the lifetime of the |
| 40 // InterfaceRegistry's connection. | 42 // InterfaceRegistry's connection. |
| 41 std::unique_ptr<service_manager::ServiceContextRef> connection_ref = | 43 std::unique_ptr<service_manager::ServiceContextRef> connection_ref = |
| 42 ref_factory_->CreateRef(); | 44 ref_factory_->CreateRef(); |
| 43 registry->AddConnectionLostClosure( | 45 registry->AddConnectionLostClosure( |
| 44 base::Bind(&OnConnectionLost, base::Passed(&connection_ref))); | 46 base::Bind(&OnConnectionLost, base::Passed(&connection_ref))); |
| 47 registry->AddInterface(base::Bind(&BarcodeDetectionImpl::Create)); | |
| 45 registry->AddInterface(base::Bind(&FaceDetectionProviderImpl::Create)); | 48 registry->AddInterface(base::Bind(&FaceDetectionProviderImpl::Create)); |
| 46 return true; | 49 return true; |
| 47 } | 50 } |
| 48 | 51 |
| 49 bool ShapeDetectionService::OnStop() { | 52 bool ShapeDetectionService::OnStop() { |
| 50 return true; | 53 return true; |
| 51 } | 54 } |
| 52 | 55 |
| 53 } // namespace shape_detection | 56 } // namespace shape_detection |
| OLD | NEW |