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

Side by Side Diff: third_party/WebKit/Source/modules/shapedetection/TextDetector.cpp

Issue 2629433003: ShapeDetection: use mojom::Bitmap for mojo interface. (Closed)
Patch Set: ShapeDetection: use mojom::Bitmap for mojo interface. Created 3 years, 11 months 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/TextDetector.h" 5 #include "modules/shapedetection/TextDetector.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/frame/LocalFrame.h" 9 #include "core/frame/LocalFrame.h"
10 #include "core/html/canvas/CanvasImageSource.h" 10 #include "core/html/canvas/CanvasImageSource.h"
11 #include "modules/shapedetection/DetectedText.h" 11 #include "modules/shapedetection/DetectedText.h"
12 #include "public/platform/InterfaceProvider.h" 12 #include "public/platform/InterfaceProvider.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 TextDetector* TextDetector::create(Document& document) { 16 TextDetector* TextDetector::create(Document& document) {
17 return new TextDetector(*document.frame()); 17 return new TextDetector(*document.frame());
18 } 18 }
19 19
20 TextDetector::TextDetector(LocalFrame& frame) : ShapeDetector(frame) { 20 TextDetector::TextDetector(LocalFrame& frame) : ShapeDetector(frame) {
21 frame.interfaceProvider()->getInterface(mojo::MakeRequest(&m_textService)); 21 frame.interfaceProvider()->getInterface(mojo::MakeRequest(&m_textService));
22 m_textService.set_connection_error_handler(convertToBaseCallback(WTF::bind( 22 m_textService.set_connection_error_handler(convertToBaseCallback(WTF::bind(
23 &TextDetector::onTextServiceConnectionError, wrapWeakPersistent(this)))); 23 &TextDetector::onTextServiceConnectionError, wrapWeakPersistent(this))));
24 } 24 }
25 25
26 ScriptPromise TextDetector::doDetect( 26 ScriptPromise TextDetector::doDetect(ScriptPromiseResolver* resolver,
27 ScriptPromiseResolver* resolver, 27 skia::mojom::blink::BitmapPtr bitmap) {
28 mojo::ScopedSharedBufferHandle sharedBufferHandle,
29 int imageWidth,
30 int imageHeight) {
31 ScriptPromise promise = resolver->promise(); 28 ScriptPromise promise = resolver->promise();
32 if (!m_textService) { 29 if (!m_textService) {
33 resolver->reject(DOMException::create( 30 resolver->reject(DOMException::create(
34 NotSupportedError, "Text detection service unavailable.")); 31 NotSupportedError, "Text detection service unavailable."));
35 return promise; 32 return promise;
36 } 33 }
37 m_textServiceRequests.add(resolver); 34 m_textServiceRequests.add(resolver);
38 m_textService->Detect(std::move(sharedBufferHandle), imageWidth, imageHeight, 35 m_textService->Detect(std::move(bitmap),
39 convertToBaseCallback(WTF::bind( 36 convertToBaseCallback(WTF::bind(
40 &TextDetector::onDetectText, wrapPersistent(this), 37 &TextDetector::onDetectText, wrapPersistent(this),
41 wrapPersistent(resolver)))); 38 wrapPersistent(resolver))));
42 return promise; 39 return promise;
43 } 40 }
44 41
45 void TextDetector::onDetectText( 42 void TextDetector::onDetectText(
46 ScriptPromiseResolver* resolver, 43 ScriptPromiseResolver* resolver,
47 Vector<shape_detection::mojom::blink::TextDetectionResultPtr> 44 Vector<shape_detection::mojom::blink::TextDetectionResultPtr>
48 textDetectionResults) { 45 textDetectionResults) {
(...skipping 20 matching lines...) Expand all
69 m_textServiceRequests.clear(); 66 m_textServiceRequests.clear();
70 m_textService.reset(); 67 m_textService.reset();
71 } 68 }
72 69
73 DEFINE_TRACE(TextDetector) { 70 DEFINE_TRACE(TextDetector) {
74 ShapeDetector::trace(visitor); 71 ShapeDetector::trace(visitor);
75 visitor->trace(m_textServiceRequests); 72 visitor->trace(m_textServiceRequests);
76 } 73 }
77 74
78 } // namespace blink 75 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698