Commit 9013fc89 authored by jdduke's avatar jdduke Committed by Commit bot

Fix Tab.getWebContents for downstream instrumentation tests

Tab.getWebContents() was using JNI to fetch the WebContents object. This
is undesirable for several reasons, including performance impact and
thread access consistency. Remove this and prefer redirecting the query
to ContentViewcore.getWebContents() instead.

This fix is a temporary workaround until all downstream test sites can
be patched.

BUG=398263,414445
TBR=tedchoc@chromium.org
NOTRY=true

Review URL: https://codereview.chromium.org/571813003

Cr-Commit-Position: refs/heads/master@{#294918}
parent 8f3f93de
......@@ -569,8 +569,7 @@ public class Tab implements NavigationClient {
* @return The web contents associated with this tab.
*/
public WebContents getWebContents() {
if (mNativeTabAndroid == 0) return null;
return nativeGetWebContents(mNativeTabAndroid);
return mContentViewCore != null ? mContentViewCore.getWebContents() : null;
}
/**
......@@ -1200,7 +1199,6 @@ public class Tab implements NavigationClient {
ContentViewCore contentViewCore, ChromeWebContentsDelegateAndroid delegate,
ContextMenuPopulator contextMenuPopulator);
private native void nativeDestroyWebContents(long nativeTabAndroid, boolean deleteNative);
private native WebContents nativeGetWebContents(long nativeTabAndroid);
private native Profile nativeGetProfileAndroid(long nativeTabAndroid);
private native int nativeLoadUrl(long nativeTabAndroid, String url, String extraHeaders,
byte[] postData, int transition, String referrerUrl, int referrerPolicy,
......
......@@ -440,14 +440,6 @@ void TabAndroid::DestroyWebContents(JNIEnv* env,
}
}
base::android::ScopedJavaLocalRef<jobject> TabAndroid::GetWebContents(
JNIEnv* env,
jobject obj) {
if (!web_contents_.get())
return base::android::ScopedJavaLocalRef<jobject>();
return web_contents_->GetJavaWebContents();
}
base::android::ScopedJavaLocalRef<jobject> TabAndroid::GetProfileAndroid(
JNIEnv* env,
jobject obj) {
......
......@@ -134,8 +134,6 @@ class TabAndroid : public CoreTabHelperDelegate,
virtual void DestroyWebContents(JNIEnv* env,
jobject obj,
jboolean delete_native);
base::android::ScopedJavaLocalRef<jobject> GetWebContents(JNIEnv* env,
jobject obj);
base::android::ScopedJavaLocalRef<jobject> GetProfileAndroid(JNIEnv* env,
jobject obj);
virtual TabLoadStatus LoadUrl(JNIEnv* env,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment