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

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

Issue 2557513003: ShapeDetection: Eliminate DetectorType enum in ShapeDetector.cpp (Closed)
Patch Set: Remove state info from parent class, add doDetect() pure virtual method. 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
25 ScriptPromise detect(ScriptState*, const CanvasImageSourceUnion&);
33 ScriptPromise detectShapes(ScriptState*, 26 ScriptPromise detectShapes(ScriptState*,
34 DetectorType, 27 ScriptPromiseResolver*,
35 const CanvasImageSourceUnion&); 28 const CanvasImageSourceUnion&);
36 DECLARE_VIRTUAL_TRACE(); 29 DEFINE_INLINE_VIRTUAL_TRACE() {}
37 30
38 private: 31 private:
39 ScriptPromise detectShapesOnImageElement(DetectorType, 32 ScriptPromise detectShapesOnImageElement(ScriptPromiseResolver*,
40 ScriptPromiseResolver*,
41 const HTMLImageElement*); 33 const HTMLImageElement*);
42 ScriptPromise detectShapesOnImageBitmap(DetectorType, 34 ScriptPromise detectShapesOnImageBitmap(ScriptPromiseResolver*, ImageBitmap*);
43 ScriptPromiseResolver*, 35 ScriptPromise detectShapesOnVideoElement(ScriptPromiseResolver*,
44 ImageBitmap*);
45 ScriptPromise detectShapesOnVideoElement(DetectorType,
46 ScriptPromiseResolver*,
47 const HTMLVideoElement*); 36 const HTMLVideoElement*);
48 37
49 ScriptPromise detectShapesOnData(DetectorType, 38 virtual ScriptPromise doDetect(ScriptPromiseResolver*,
50 ScriptPromiseResolver*, 39 mojo::ScopedSharedBufferHandle,
51 uint8_t* data, 40 int,
52 int size, 41 int) = 0;
Reilly Grant (use Gerrit) 2016/12/06 20:40:13 Same comment.
xianglu 2016/12/06 22:31:56 Done.
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 }; 42 };
73 43
74 } // namespace blink 44 } // namespace blink
75 45
76 #endif // ShapeDetector_h 46 #endif // ShapeDetector_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698