Chromium Code Reviews| 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/ShapeDetector.h" | 5 #include "modules/shapedetection/ShapeDetector.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/dom/Document.h" | 9 #include "core/dom/Document.h" |
| 10 #include "core/fetch/ImageResource.h" | 10 #include "core/fetch/ImageResource.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 } | 42 } |
| 43 | 43 |
| 44 } // anonymous namespace | 44 } // anonymous namespace |
| 45 | 45 |
| 46 ShapeDetector::ShapeDetector(LocalFrame& frame) { | 46 ShapeDetector::ShapeDetector(LocalFrame& frame) { |
| 47 DCHECK(!m_service.is_bound()); | 47 DCHECK(!m_service.is_bound()); |
| 48 DCHECK(frame.interfaceProvider()); | 48 DCHECK(frame.interfaceProvider()); |
| 49 frame.interfaceProvider()->getInterface(mojo::GetProxy(&m_service)); | 49 frame.interfaceProvider()->getInterface(mojo::GetProxy(&m_service)); |
| 50 } | 50 } |
| 51 | 51 |
| 52 ShapeDetector::ShapeDetector(LocalFrame& frame, | |
| 53 const FaceDetectorOptions& options) | |
| 54 : m_options(mojom::blink::FaceDetectorOptions::New()) { | |
| 55 DCHECK(!m_service.is_bound()); | |
| 56 DCHECK(frame.interfaceProvider()); | |
| 57 frame.interfaceProvider()->getInterface(mojo::GetProxy(&m_service)); | |
|
Reilly Grant (use Gerrit)
2016/11/23 01:42:04
You can use delegated constructors to avoid this c
| |
| 58 m_options->max_detected_faces = options.maxDetectedFaces(); | |
| 59 m_options->fast_mode = options.fastMode(); | |
| 60 } | |
| 61 | |
| 52 ScriptPromise ShapeDetector::detectShapes( | 62 ScriptPromise ShapeDetector::detectShapes( |
| 53 ScriptState* scriptState, | 63 ScriptState* scriptState, |
| 54 DetectorType detectorType, | 64 DetectorType detectorType, |
| 55 const CanvasImageSourceUnion& imageSource) { | 65 const CanvasImageSourceUnion& imageSource) { |
| 56 CanvasImageSource* imageSourceInternal = toImageSourceInternal(imageSource); | 66 CanvasImageSource* imageSourceInternal = toImageSourceInternal(imageSource); |
| 57 | 67 |
| 58 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); | 68 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
| 59 ScriptPromise promise = resolver->promise(); | 69 ScriptPromise promise = resolver->promise(); |
| 60 | 70 |
| 61 if (!imageSourceInternal) { | 71 if (!imageSourceInternal) { |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 357 } | 367 } |
| 358 | 368 |
| 359 resolver->resolve(detectedBarcodes); | 369 resolver->resolve(detectedBarcodes); |
| 360 } | 370 } |
| 361 | 371 |
| 362 DEFINE_TRACE(ShapeDetector) { | 372 DEFINE_TRACE(ShapeDetector) { |
| 363 visitor->trace(m_serviceRequests); | 373 visitor->trace(m_serviceRequests); |
| 364 } | 374 } |
| 365 | 375 |
| 366 } // namespace blink | 376 } // namespace blink |
| OLD | NEW |