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

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

Issue 2696183002: Migrate WTF::HashSet::remove() to ::erase() [part 1] (Closed)
Patch Set: one more platform-specific reference Created 3 years, 10 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 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/FaceDetector.h" 5 #include "modules/shapedetection/FaceDetector.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/html/canvas/CanvasImageSource.h" 9 #include "core/html/canvas/CanvasImageSource.h"
10 #include "modules/shapedetection/DetectedFace.h" 10 #include "modules/shapedetection/DetectedFace.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 convertToBaseCallback(WTF::bind( 51 convertToBaseCallback(WTF::bind(
52 &FaceDetector::onDetectFaces, wrapPersistent(this), 52 &FaceDetector::onDetectFaces, wrapPersistent(this),
53 wrapPersistent(resolver)))); 53 wrapPersistent(resolver))));
54 return promise; 54 return promise;
55 } 55 }
56 56
57 void FaceDetector::onDetectFaces( 57 void FaceDetector::onDetectFaces(
58 ScriptPromiseResolver* resolver, 58 ScriptPromiseResolver* resolver,
59 shape_detection::mojom::blink::FaceDetectionResultPtr faceDetectionResult) { 59 shape_detection::mojom::blink::FaceDetectionResultPtr faceDetectionResult) {
60 DCHECK(m_faceServiceRequests.contains(resolver)); 60 DCHECK(m_faceServiceRequests.contains(resolver));
61 m_faceServiceRequests.remove(resolver); 61 m_faceServiceRequests.erase(resolver);
62 62
63 HeapVector<Member<DetectedFace>> detectedFaces; 63 HeapVector<Member<DetectedFace>> detectedFaces;
64 for (const auto& boundingBox : faceDetectionResult->bounding_boxes) { 64 for (const auto& boundingBox : faceDetectionResult->bounding_boxes) {
65 detectedFaces.push_back(DetectedFace::create( 65 detectedFaces.push_back(DetectedFace::create(
66 DOMRect::create(boundingBox->x, boundingBox->y, boundingBox->width, 66 DOMRect::create(boundingBox->x, boundingBox->y, boundingBox->width,
67 boundingBox->height))); 67 boundingBox->height)));
68 } 68 }
69 69
70 resolver->resolve(detectedFaces); 70 resolver->resolve(detectedFaces);
71 } 71 }
72 72
73 void FaceDetector::onFaceServiceConnectionError() { 73 void FaceDetector::onFaceServiceConnectionError() {
74 for (const auto& request : m_faceServiceRequests) { 74 for (const auto& request : m_faceServiceRequests) {
75 request->reject(DOMException::create(NotSupportedError, 75 request->reject(DOMException::create(NotSupportedError,
76 "Face Detection not implemented.")); 76 "Face Detection not implemented."));
77 } 77 }
78 m_faceServiceRequests.clear(); 78 m_faceServiceRequests.clear();
79 m_faceService.reset(); 79 m_faceService.reset();
80 } 80 }
81 81
82 DEFINE_TRACE(FaceDetector) { 82 DEFINE_TRACE(FaceDetector) {
83 ShapeDetector::trace(visitor); 83 ShapeDetector::trace(visitor);
84 visitor->trace(m_faceServiceRequests); 84 visitor->trace(m_faceServiceRequests);
85 } 85 }
86 86
87 } // namespace blink 87 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698