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

Unified Diff: third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp

Issue 2522143002: ShapeDetection: split mojom into face and barcode interfaces (Closed)
Patch Set: Created 4 years, 1 month 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
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),

Powered by Google App Engine
This is Rietveld 408576698