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

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

Issue 2528743002: Shape Detection: Implement FaceDetection on Mac as out-of-process service (Closed)
Patch Set: rockot@ comments Created 4 years 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 abfa2e3ddf937b308d08632890be87dd3294b2fc..fbb01c80aa1fc43042ae0f2284b93eb1479f349c 100644
--- a/third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp
+++ b/third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp
@@ -15,8 +15,10 @@
#include "core/html/HTMLVideoElement.h"
#include "core/html/canvas/CanvasImageSource.h"
#include "modules/shapedetection/DetectedBarcode.h"
+#include "platform/ServiceConnector.h"
#include "platform/graphics/Image.h"
#include "public/platform/InterfaceProvider.h"
+#include "services/shape_detection/public/interfaces/constants.mojom-blink.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkImageInfo.h"
#include "wtf/CheckedNumeric.h"
@@ -43,14 +45,18 @@ static CanvasImageSource* toImageSourceInternal(
} // anonymous namespace
+// TODO(xianglu): We don't need a service per frame. Remove this argument.
ShapeDetector::ShapeDetector(LocalFrame& frame) {
- DCHECK(!m_faceService.is_bound());
DCHECK(!m_barcodeService.is_bound());
+#if OS(MACOSX)
+ ServiceConnector::instance().ConnectToInterface(
+ shape_detection::mojom::blink::kServiceName,
+ mojo::GetProxy(&m_barcodeService));
+#else
+ // TODO(xianglu): Move Android implementation to service/ as well.
DCHECK(frame.interfaceProvider());
- frame.interfaceProvider()->getInterface(mojo::GetProxy(&m_faceService));
frame.interfaceProvider()->getInterface(mojo::GetProxy(&m_barcodeService));
- m_faceService.set_connection_error_handler(convertToBaseCallback(WTF::bind(
- &ShapeDetector::onFaceServiceConnectionError, wrapWeakPersistent(this))));
+#endif
m_barcodeService.set_connection_error_handler(convertToBaseCallback(
WTF::bind(&ShapeDetector::onBarcodeServiceConnectionError,
wrapWeakPersistent(this))));
@@ -58,8 +64,20 @@ ShapeDetector::ShapeDetector(LocalFrame& frame) {
ShapeDetector::ShapeDetector(LocalFrame& frame,
const FaceDetectorOptions& options)
- : ShapeDetector(frame) {
- m_faceDetectorOptions = mojom::blink::FaceDetectorOptions::New();
+ : m_faceDetectorOptions(mojom::blink::FaceDetectorOptions::New()) {
+ DCHECK(!m_faceService.is_bound());
+#if OS(MACOSX)
+ ServiceConnector::instance().ConnectToInterface(
+ shape_detection::mojom::blink::kServiceName,
+ mojo::GetProxy(&m_faceService));
+#else
+ // TODO(xianglu): Move Android implementation to service/ as well.
+ DCHECK(frame.interfaceProvider());
+ frame.interfaceProvider()->getInterface(mojo::GetProxy(&m_faceService));
+#endif
+ m_faceService.set_connection_error_handler(convertToBaseCallback(WTF::bind(
+ &ShapeDetector::onFaceServiceConnectionError, wrapWeakPersistent(this))));
+
m_faceDetectorOptions->max_detected_faces = options.maxDetectedFaces();
m_faceDetectorOptions->fast_mode = options.fastMode();
}

Powered by Google App Engine
This is Rietveld 408576698