| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 "modules/shapedetection/FaceDetector.h" | 5 #include "modules/shapedetection/FaceDetector.h" |
| 6 | 6 |
| 7 #include "core/dom/DOMException.h" | 7 #include "core/dom/DOMException.h" |
| 8 #include "core/dom/DOMRect.h" | 8 #include "core/dom/DOMRect.h" |
| 9 #include "core/html/canvas/CanvasImageSource.h" | 9 #include "core/html/canvas/CanvasImageSource.h" |
| 10 #include "modules/shapedetection/DetectedFace.h" | 10 #include "modules/shapedetection/DetectedFace.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 ScriptPromiseResolver* resolver, | 39 ScriptPromiseResolver* resolver, |
| 40 mojo::ScopedSharedBufferHandle sharedBufferHandle, | 40 mojo::ScopedSharedBufferHandle sharedBufferHandle, |
| 41 int imageWidth, | 41 int imageWidth, |
| 42 int imageHeight) { | 42 int imageHeight) { |
| 43 ScriptPromise promise = resolver->promise(); | 43 ScriptPromise promise = resolver->promise(); |
| 44 if (!m_faceService) { | 44 if (!m_faceService) { |
| 45 resolver->reject(DOMException::create( | 45 resolver->reject(DOMException::create( |
| 46 NotSupportedError, "Face detection service unavailable.")); | 46 NotSupportedError, "Face detection service unavailable.")); |
| 47 return promise; | 47 return promise; |
| 48 } | 48 } |
| 49 m_faceServiceRequests.add(resolver); | 49 m_faceServiceRequests.insert(resolver); |
| 50 m_faceService->Detect(std::move(sharedBufferHandle), imageWidth, imageHeight, | 50 m_faceService->Detect(std::move(sharedBufferHandle), imageWidth, imageHeight, |
| 51 convertToBaseCallback(WTF::bind( | 51 convertToBaseCallback(WTF::bind( |
| 52 &FaceDetector::onDetectFaces, wrapPersistent(this), | 52 &FaceDetector::onDetectFaces, wrapPersistent(this), |
| 53 wrapPersistent(resolver)))); | 53 wrapPersistent(resolver)))); |
| 54 return promise; | 54 return promise; |
| 55 } | 55 } |
| 56 | 56 |
| 57 void FaceDetector::onDetectFaces( | 57 void FaceDetector::onDetectFaces( |
| 58 ScriptPromiseResolver* resolver, | 58 ScriptPromiseResolver* resolver, |
| 59 shape_detection::mojom::blink::FaceDetectionResultPtr faceDetectionResult) { | 59 shape_detection::mojom::blink::FaceDetectionResultPtr faceDetectionResult) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 78 m_faceServiceRequests.clear(); | 78 m_faceServiceRequests.clear(); |
| 79 m_faceService.reset(); | 79 m_faceService.reset(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 DEFINE_TRACE(FaceDetector) { | 82 DEFINE_TRACE(FaceDetector) { |
| 83 ShapeDetector::trace(visitor); | 83 ShapeDetector::trace(visitor); |
| 84 visitor->trace(m_faceServiceRequests); | 84 visitor->trace(m_faceServiceRequests); |
| 85 } | 85 } |
| 86 | 86 |
| 87 } // namespace blink | 87 } // namespace blink |
| OLD | NEW |