Chromium Code Reviews| Index: third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp |
| diff --git a/third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp b/third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp |
| index d5b57cdffc33fcc85ec2548b8ba971a09598a782..fe8cfd617d6271c666f50d2cf0d1db07a4742795 100644 |
| --- a/third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp |
| +++ b/third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp |
| @@ -44,9 +44,9 @@ static CanvasImageSource* toImageSourceInternal( |
| } // anonymous namespace |
| ShapeDetector::ShapeDetector(LocalFrame& frame) { |
| - DCHECK(!m_service.is_bound()); |
| + DCHECK(!m_faceService.is_bound()); |
| DCHECK(frame.interfaceProvider()); |
| - frame.interfaceProvider()->getInterface(mojo::GetProxy(&m_service)); |
| + frame.interfaceProvider()->getInterface(mojo::GetProxy(&m_faceService)); |
| } |
| ScriptPromise ShapeDetector::detectShapes( |
| @@ -58,6 +58,11 @@ ScriptPromise ShapeDetector::detectShapes( |
| ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
| ScriptPromise promise = resolver->promise(); |
| + if (!m_barcodeService.is_bound()) { |
| + scriptState->domWindow()->frame()->interfaceProvider()->getInterface( |
| + mojo::GetProxy(&m_barcodeService)); |
| + } |
| + |
| if (!imageSourceInternal) { |
| // TODO(mcasas): Implement more CanvasImageSources, https://crbug.com/659138 |
| NOTIMPLEMENTED() << "Unsupported CanvasImageSource"; |
| @@ -155,23 +160,21 @@ ScriptPromise ShapeDetector::detectShapesOnImageElement( |
| return promise; |
| } |
| - if (!m_service) { |
| + if (!m_faceService) { |
| resolver->reject(DOMException::create( |
| NotSupportedError, "Shape detection service unavailable.")); |
| return promise; |
| } |
| m_serviceRequests.add(resolver); |
| - DCHECK(m_service.is_bound()); |
| if (detectorType == DetectorType::Face) { |
| - m_service->DetectFaces( |
| - std::move(sharedBufferHandle), img->naturalWidth(), |
| - img->naturalHeight(), m_options.Clone(), |
| - convertToBaseCallback(WTF::bind(&ShapeDetector::onDetectFaces, |
| - wrapPersistent(this), |
| - wrapPersistent(resolver)))); |
| + m_faceService->Detect(std::move(sharedBufferHandle), img->naturalWidth(), |
| + img->naturalHeight(), m_options.Clone(), |
| + convertToBaseCallback(WTF::bind( |
| + &ShapeDetector::onDetectFaces, |
| + wrapPersistent(this), wrapPersistent(resolver)))); |
| } else if (detectorType == DetectorType::Barcode) { |
| - m_service->DetectBarcodes( |
| + m_barcodeService->Detect( |
| std::move(sharedBufferHandle), img->naturalWidth(), |
| img->naturalHeight(), |
| convertToBaseCallback(WTF::bind(&ShapeDetector::onDetectBarcodes, |
| @@ -290,7 +293,7 @@ ScriptPromise ShapeDetector::detectShapesOnData(DetectorType detectorType, |
| return promise; |
| } |
| - if (!m_service) { |
| + if (!m_faceService) { |
| resolver->reject(DOMException::create( |
| NotSupportedError, "Shape detection service unavailable.")); |
| return promise; |
| @@ -303,15 +306,15 @@ ScriptPromise ShapeDetector::detectShapesOnData(DetectorType detectorType, |
| memcpy(mappedBuffer.get(), data, size); |
| m_serviceRequests.add(resolver); |
| - DCHECK(m_service.is_bound()); |
| + DCHECK(m_faceService.is_bound()); |
|
xianglu
2016/11/23 02:53:37
nit: Remove this DCHECK too?
mcasas
2016/11/23 14:49:38
Yeah, this was paranoia, removed.
|
| if (detectorType == DetectorType::Face) { |
| - m_service->DetectFaces( |
| + m_faceService->Detect( |
| std::move(sharedBufferHandle), width, height, m_options.Clone(), |
| convertToBaseCallback(WTF::bind(&ShapeDetector::onDetectFaces, |
| wrapPersistent(this), |
| wrapPersistent(resolver)))); |
| } else if (detectorType == DetectorType::Barcode) { |
| - m_service->DetectBarcodes( |
| + m_barcodeService->Detect( |
| std::move(sharedBufferHandle), width, height, |
| convertToBaseCallback(WTF::bind(&ShapeDetector::onDetectBarcodes, |
| wrapPersistent(this), |