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

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

Issue 11971007: Pass ScopedJavaGlobalRef to bind() by value (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: avi comments Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « android_webview/native/aw_contents.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/android/content_view_core_impl.cc
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc
index eabee0312939f9582e0d7a9d9bea3b57b0329609..f7b0428098a00be38c0ca6304bdd79081ce273b0 100644
--- a/content/browser/android/content_view_core_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -1257,17 +1257,15 @@ void ContentViewCoreImpl::UndoScrollFocusedEditableNodeIntoView(
}
namespace {
-void JavaScriptResultCallback(ScopedJavaGlobalRef<jobject>* callback,
+void JavaScriptResultCallback(const ScopedJavaGlobalRef<jobject>& callback,
const base::Value* result) {
- // |callback| is passed as base::Owned, so it will automatically be deleted
- // when this base::Callback goes out of scope.
JNIEnv* env = base::android::AttachCurrentThread();
std::string json;
base::JSONWriter::Write(result, &json);
ScopedJavaLocalRef<jstring> j_json = ConvertUTF8ToJavaString(env, json);
Java_ContentViewCore_onEvaluateJavaScriptResult(env,
j_json.obj(),
- callback->obj());
+ callback.obj());
}
} // namespace
@@ -1287,10 +1285,10 @@ void ContentViewCoreImpl::EvaluateJavaScript(JNIEnv* env,
// Secure the Java callback in a scoped object and give ownership of it to the
// base::Callback.
- ScopedJavaGlobalRef<jobject>* j_callback = new ScopedJavaGlobalRef<jobject>();
- j_callback->Reset(env, callback);
+ ScopedJavaGlobalRef<jobject> j_callback;
+ j_callback.Reset(env, callback);
content::RenderViewHost::JavascriptResultCallback c_callback =
- base::Bind(&JavaScriptResultCallback, base::Owned(j_callback));
+ base::Bind(&JavaScriptResultCallback, j_callback);
host->ExecuteJavascriptInWebFrameCallbackResult(
string16(), // frame_xpath
« no previous file with comments | « android_webview/native/aw_contents.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698