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 { ...@@ -569,8 +569,7 @@ public class Tab implements NavigationClient {
* @return The web contents associated with this tab. * @return The web contents associated with this tab.
*/ */
public WebContents getWebContents() { public WebContents getWebContents() {
if (mNativeTabAndroid == 0) return null; return mContentViewCore != null ? mContentViewCore.getWebContents() : null;
return nativeGetWebContents(mNativeTabAndroid);
} }
/** /**
...@@ -1200,7 +1199,6 @@ public class Tab implements NavigationClient { ...@@ -1200,7 +1199,6 @@ public class Tab implements NavigationClient {
ContentViewCore contentViewCore, ChromeWebContentsDelegateAndroid delegate, ContentViewCore contentViewCore, ChromeWebContentsDelegateAndroid delegate,
ContextMenuPopulator contextMenuPopulator); ContextMenuPopulator contextMenuPopulator);
private native void nativeDestroyWebContents(long nativeTabAndroid, boolean deleteNative); private native void nativeDestroyWebContents(long nativeTabAndroid, boolean deleteNative);
private native WebContents nativeGetWebContents(long nativeTabAndroid);
private native Profile nativeGetProfileAndroid(long nativeTabAndroid); private native Profile nativeGetProfileAndroid(long nativeTabAndroid);
private native int nativeLoadUrl(long nativeTabAndroid, String url, String extraHeaders, private native int nativeLoadUrl(long nativeTabAndroid, String url, String extraHeaders,
byte[] postData, int transition, String referrerUrl, int referrerPolicy, byte[] postData, int transition, String referrerUrl, int referrerPolicy,
......
...@@ -440,14 +440,6 @@ void TabAndroid::DestroyWebContents(JNIEnv* env, ...@@ -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( base::android::ScopedJavaLocalRef<jobject> TabAndroid::GetProfileAndroid(
JNIEnv* env, JNIEnv* env,
jobject obj) { jobject obj) {
......
...@@ -134,8 +134,6 @@ class TabAndroid : public CoreTabHelperDelegate, ...@@ -134,8 +134,6 @@ class TabAndroid : public CoreTabHelperDelegate,
virtual void DestroyWebContents(JNIEnv* env, virtual void DestroyWebContents(JNIEnv* env,
jobject obj, jobject obj,
jboolean delete_native); jboolean delete_native);
base::android::ScopedJavaLocalRef<jobject> GetWebContents(JNIEnv* env,
jobject obj);
base::android::ScopedJavaLocalRef<jobject> GetProfileAndroid(JNIEnv* env, base::android::ScopedJavaLocalRef<jobject> GetProfileAndroid(JNIEnv* env,
jobject obj); jobject obj);
virtual TabLoadStatus LoadUrl(JNIEnv* env, 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