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

Side by Side Diff: third_party/WebKit/Source/modules/shapedetection/ShapeDetector.h

Issue 2557513003: ShapeDetection: Eliminate DetectorType enum in ShapeDetector.cpp (Closed)
Patch Set: Move tainting logic into detect() 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 unified diff | Download patch
OLDNEW
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 #ifndef ShapeDetector_h 5 #ifndef ShapeDetector_h
6 #define ShapeDetector_h 6 #define ShapeDetector_h
7 7
8 #include "bindings/core/v8/ScriptPromise.h" 8 #include "bindings/core/v8/ScriptPromise.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "modules/ModulesExport.h" 10 #include "modules/ModulesExport.h"
11 #include "modules/canvas2d/CanvasRenderingContext2D.h" 11 #include "modules/canvas2d/CanvasRenderingContext2D.h"
12 #include "modules/shapedetection/FaceDetectorOptions.h"
13 #include "public/platform/modules/shapedetection/barcodedetection.mojom-blink.h"
14 #include "public/platform/modules/shapedetection/facedetection.mojom-blink.h"
15 12
16 namespace blink { 13 namespace blink {
17 14
18 class LocalFrame; 15 class LocalFrame;
19 16
20 class MODULES_EXPORT ShapeDetector 17 class MODULES_EXPORT ShapeDetector
21 : public GarbageCollectedFinalized<ShapeDetector> { 18 : public GarbageCollectedFinalized<ShapeDetector> {
22 public: 19 public:
23 enum class DetectorType { 20 // TODO(mcasas): Implement TextDetector after
24 Face, 21 // https://github.com/WICG/shape-detection-api/issues/6
25 Barcode
26 // TODO(mcasas): Implement TextDetector after
27 // https://github.com/WICG/shape-detection-api/issues/6
28 };
29 explicit ShapeDetector(LocalFrame&); 22 explicit ShapeDetector(LocalFrame&);
30 ShapeDetector(LocalFrame&, const FaceDetectorOptions&);
31 virtual ~ShapeDetector() = default; 23 virtual ~ShapeDetector() = default;
32 24
33 ScriptPromise detectShapes(ScriptState*, 25 ScriptPromise detect(ScriptState*, const CanvasImageSourceUnion&);
34 DetectorType, 26 DEFINE_INLINE_VIRTUAL_TRACE() {}
35 const CanvasImageSourceUnion&);
36 DECLARE_VIRTUAL_TRACE();
37 27
38 private: 28 private:
39 ScriptPromise detectShapesOnImageElement(DetectorType, 29 ScriptPromise detectShapesOnImageElement(ScriptPromiseResolver*,
40 ScriptPromiseResolver*,
41 const HTMLImageElement*); 30 const HTMLImageElement*);
42 ScriptPromise detectShapesOnImageBitmap(DetectorType, 31 ScriptPromise detectShapesOnImageBitmap(ScriptPromiseResolver*, ImageBitmap*);
43 ScriptPromiseResolver*, 32 ScriptPromise detectShapesOnVideoElement(ScriptPromiseResolver*,
44 ImageBitmap*);
45 ScriptPromise detectShapesOnVideoElement(DetectorType,
46 ScriptPromiseResolver*,
47 const HTMLVideoElement*); 33 const HTMLVideoElement*);
48 34
49 ScriptPromise detectShapesOnData(DetectorType, 35 virtual ScriptPromise doDetect(ScriptPromiseResolver*,
50 ScriptPromiseResolver*, 36 mojo::ScopedSharedBufferHandle,
51 uint8_t* data, 37 int imageWidth,
52 int size, 38 int imageHeight) = 0;
53 int width,
54 int height);
55 void onDetectFaces(ScriptPromiseResolver*,
56 mojom::blink::FaceDetectionResultPtr);
57 void onDetectBarcodes(ScriptPromiseResolver*,
58 Vector<mojom::blink::BarcodeDetectionResultPtr>);
59
60 // Error handlers for use if mojo service doesn't connect.
61 void onFaceServiceConnectionError();
62 void onBarcodeServiceConnectionError();
63
64 mojom::blink::FaceDetectionPtr m_faceService;
65 mojom::blink::BarcodeDetectionPtr m_barcodeService;
66
67 HeapHashSet<Member<ScriptPromiseResolver>> m_faceServiceRequests;
68 HeapHashSet<Member<ScriptPromiseResolver>> m_barcodeServiceRequests;
69
70 protected:
71 mojom::blink::FaceDetectorOptionsPtr m_faceDetectorOptions;
72 }; 39 };
73 40
74 } // namespace blink 41 } // namespace blink
75 42
76 #endif // ShapeDetector_h 43 #endif // ShapeDetector_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698