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

Unified Diff: third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp

Issue 2399593005: ShapeDetectionImpl: Android implementation of detectFace() (Closed)
Patch Set: Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/shapedetection/ShapeDetectionImpl.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp
diff --git a/third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp b/third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp
index b11f55638d8b1e3364ea5afcf026968fdbbb5442..bb969d71c63d44b04e7969fcfa5c55999071a146 100644
--- a/third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp
+++ b/third_party/WebKit/Source/modules/shapedetection/FaceDetector.cpp
@@ -47,11 +47,18 @@ mojo::ScopedSharedBufferHandle getSharedBufferHandle(
SkImageInfo::MakeN32(image->width(), image->height(), image->alphaType());
const uint32_t allocationSize = skiaInfo.getSafeSize(skiaInfo.minRowBytes());
+
mojo::ScopedSharedBufferHandle sharedBufferHandle =
mojo::SharedBufferHandle::Create(allocationSize);
+ if (!sharedBufferHandle.is_valid()) {
+ // TODO(xianglu): Do something when the image is too large.
+ DLOG(ERROR) << "Failed to create a sharedBufferHandle. allocationSize = "
+ << allocationSize << "bytes. limit = 16777216";
+ return mojo::ScopedSharedBufferHandle();
+ }
+
const mojo::ScopedSharedBufferMapping mappedBuffer =
sharedBufferHandle->Map(allocationSize);
- DCHECK(mappedBuffer);
const SkPixmap pixmap(skiaInfo, mappedBuffer.get(), skiaInfo.minRowBytes());
if (!image->readPixels(pixmap, 0, 0)) {
@@ -96,8 +103,8 @@ ScriptPromise FaceDetector::detect(ScriptState* scriptState,
mojo::ScopedSharedBufferHandle sharedBufferHandle =
getSharedBufferHandle(img);
if (!sharedBufferHandle->is_valid()) {
- resolver->reject(
- DOMException::create(SyntaxError, "Failed to get sharedBufferHandle."));
+ resolver->reject(DOMException::create(
+ SyntaxError, "Request for sharedBufferHandle failed."));
return promise;
}
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/shapedetection/ShapeDetectionImpl.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698