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

Unified Diff: content/browser/android/content_readback_handler.cc

Issue 593503003: Support error handling for Surface readbacks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Formatted code and fixed build issue in test. Created 6 years, 1 month 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
Index: content/browser/android/content_readback_handler.cc
diff --git a/content/browser/android/content_readback_handler.cc b/content/browser/android/content_readback_handler.cc
index 414bf0abe677adda2c262527c0cc477dcc6ef41e..d118acdafcba28c7fa4581c2e061e509b0768540 100644
--- a/content/browser/android/content_readback_handler.cc
+++ b/content/browser/android/content_readback_handler.cc
@@ -20,18 +20,16 @@ namespace content {
namespace {
-typedef base::Callback<void(bool, const SkBitmap&)> ResultCallback;
-
void OnFinishCopyOutputRequest(
- const ResultCallback& result_callback,
+ const ReadbackRequestCallback& result_callback,
scoped_ptr<cc::CopyOutputResult> copy_output_result) {
if (!copy_output_result->HasBitmap()) {
- result_callback.Run(false, SkBitmap());
+ result_callback.Run(SkBitmap(), READBACK_FAILED);
return;
}
scoped_ptr<SkBitmap> bitmap = copy_output_result->TakeBitmap();
- result_callback.Run(true, *bitmap);
+ result_callback.Run(*bitmap, READBACK_SUCCESS);
}
} // anonymous namespace
@@ -64,7 +62,7 @@ void ContentReadbackHandler::GetContentBitmap(JNIEnv* env,
ContentViewCore::GetNativeContentViewCore(env, content_view_core);
DCHECK(view);
- ResultCallback result_callback =
+ ReadbackRequestCallback result_callback =
base::Bind(&ContentReadbackHandler::OnFinishReadback,
weak_factory_.GetWeakPtr(),
readback_id);
@@ -82,7 +80,7 @@ void ContentReadbackHandler::GetCompositorBitmap(JNIEnv* env,
reinterpret_cast<ui::WindowAndroid*>(native_window_android);
DCHECK(window_android);
- ResultCallback result_callback =
+ ReadbackRequestCallback result_callback =
base::Bind(&ContentReadbackHandler::OnFinishReadback,
weak_factory_.GetWeakPtr(),
readback_id);
@@ -105,11 +103,11 @@ void ContentReadbackHandler::GetCompositorBitmap(JNIEnv* env,
ContentReadbackHandler::~ContentReadbackHandler() {}
void ContentReadbackHandler::OnFinishReadback(int readback_id,
- bool success,
- const SkBitmap& bitmap) {
+ const SkBitmap& bitmap,
+ ReadbackResponse response) {
JNIEnv* env = base::android::AttachCurrentThread();
ScopedJavaLocalRef<jobject> java_bitmap;
- if (success)
+ if (response == READBACK_SUCCESS)
java_bitmap = gfx::ConvertToJavaBitmap(&bitmap);
Java_ContentReadbackHandler_notifyGetBitmapFinished(

Powered by Google App Engine
This is Rietveld 408576698