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

Unified Diff: android_webview/native/aw_contents.cc

Issue 2538463002: android: Don't pass ScopedJavaGlobalRef pointers. (Closed)
Patch Set: timeouts are very annoying Created 4 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
« no previous file with comments | « no previous file | android_webview/native/aw_contents_statics.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/native/aw_contents.cc
diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc
index 688d55ef4aec276daeac73b92f9f33fdab4c2002..71e7c620f9b79b534d430424fb04f2e79554da29 100644
--- a/android_webview/native/aw_contents.cc
+++ b/android_webview/native/aw_contents.cc
@@ -400,13 +400,13 @@ void AwContents::DocumentHasImages(JNIEnv* env,
}
namespace {
-void GenerateMHTMLCallback(ScopedJavaGlobalRef<jobject>* callback,
+void GenerateMHTMLCallback(const JavaRef<jobject>& callback,
const base::FilePath& path,
int64_t size) {
JNIEnv* env = AttachCurrentThread();
// Android files are UTF8, so the path conversion below is safe.
Java_AwContents_generateMHTMLCallback(
- env, ConvertUTF8ToJavaString(env, path.AsUTF8Unsafe()), size, *callback);
+ env, ConvertUTF8ToJavaString(env, path.AsUTF8Unsafe()), size, callback);
}
} // namespace
@@ -415,12 +415,11 @@ void AwContents::GenerateMHTML(JNIEnv* env,
const JavaParamRef<jstring>& jpath,
const JavaParamRef<jobject>& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- ScopedJavaGlobalRef<jobject>* j_callback = new ScopedJavaGlobalRef<jobject>();
- j_callback->Reset(env, callback);
base::FilePath target_path(ConvertJavaStringToUTF8(env, jpath));
web_contents_->GenerateMHTML(
content::MHTMLGenerationParams(target_path),
- base::Bind(&GenerateMHTMLCallback, base::Owned(j_callback), target_path));
+ base::Bind(&GenerateMHTMLCallback,
+ ScopedJavaGlobalRef<jobject>(env, callback), target_path));
}
void AwContents::CreatePdfExporter(JNIEnv* env,
@@ -1137,13 +1136,13 @@ void AwContents::EnableOnNewPicture(JNIEnv* env,
namespace {
void InvokeVisualStateCallback(const JavaObjectWeakGlobalRef& java_ref,
jlong request_id,
- ScopedJavaGlobalRef<jobject>* callback,
+ const JavaRef<jobject>& callback,
bool result) {
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> obj = java_ref.get(env);
if (obj.is_null())
return;
- Java_AwContents_invokeVisualStateCallback(env, obj, *callback, request_id);
+ Java_AwContents_invokeVisualStateCallback(env, obj, callback, request_id);
}
} // namespace
@@ -1153,11 +1152,9 @@ void AwContents::InsertVisualStateCallback(
jlong request_id,
const JavaParamRef<jobject>& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- ScopedJavaGlobalRef<jobject>* j_callback = new ScopedJavaGlobalRef<jobject>();
- j_callback->Reset(env, callback);
web_contents_->GetMainFrame()->InsertVisualStateCallback(
base::Bind(&InvokeVisualStateCallback, java_ref_, request_id,
- base::Owned(j_callback)));
+ ScopedJavaGlobalRef<jobject>(env, callback)));
}
void AwContents::ClearView(JNIEnv* env, const JavaParamRef<jobject>& obj) {
« no previous file with comments | « no previous file | android_webview/native/aw_contents_statics.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698