summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Toby Sargeant <tobiasjs@google.com> 2017-01-23 16:21:15 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2017-01-23 16:21:18 +0000
commit773deddaf5d5cf358b135cd670d247936d0430d0 (patch)
tree3b2ab4894eee81c128ce33d5ea26d38cde91ca17
parent83d577581bf136def8fe03a31d1c1b71f65dd988 (diff)
parentd10e4af0988b478f57dd90196ee105a94129a93b (diff)
Merge "WebView: Add the definition of the renderer importance API."
-rw-r--r--api/current.txt7
-rw-r--r--api/system-current.txt10
-rw-r--r--api/test-current.txt7
-rw-r--r--core/java/android/webkit/RenderProcessGoneDetail.java11
-rw-r--r--core/java/android/webkit/WebView.java91
-rw-r--r--core/java/android/webkit/WebViewProvider.java6
6 files changed, 132 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt
index a59e2a18e3e5..97019181111d 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -46607,6 +46607,7 @@ package android.webkit {
public abstract class RenderProcessGoneDetail {
ctor public RenderProcessGoneDetail();
method public abstract boolean didCrash();
+ method public abstract int rendererPriorityAtExit();
}
public class ServiceWorkerClient {
@@ -47023,6 +47024,8 @@ package android.webkit {
method public deprecated java.lang.String[] getHttpAuthUsernamePassword(java.lang.String, java.lang.String);
method public java.lang.String getOriginalUrl();
method public int getProgress();
+ method public boolean getRendererPriorityWaivedWhenNotVisible();
+ method public int getRendererRequestedPriority();
method public deprecated float getScale();
method public android.webkit.WebSettings getSettings();
method public java.lang.String getTitle();
@@ -47070,6 +47073,7 @@ package android.webkit {
method public deprecated void setMapTrackballToArrowKeys(boolean);
method public void setNetworkAvailable(boolean);
method public deprecated void setPictureListener(android.webkit.WebView.PictureListener);
+ method public void setRendererPriorityPolicy(int, boolean);
method public deprecated void setVerticalScrollbarOverlay(boolean);
method public void setWebChromeClient(android.webkit.WebChromeClient);
method public static void setWebContentsDebuggingEnabled(boolean);
@@ -47079,6 +47083,9 @@ package android.webkit {
method public void zoomBy(float);
method public boolean zoomIn();
method public boolean zoomOut();
+ field public static final int RENDERER_PRIORITY_BOUND = 1; // 0x1
+ field public static final int RENDERER_PRIORITY_IMPORTANT = 2; // 0x2
+ field public static final int RENDERER_PRIORITY_WAIVED = 0; // 0x0
field public static final java.lang.String SCHEME_GEO = "geo:0,0?q=";
field public static final java.lang.String SCHEME_MAILTO = "mailto:";
field public static final java.lang.String SCHEME_TEL = "tel:";
diff --git a/api/system-current.txt b/api/system-current.txt
index ed52bd1f76e3..4cd63d694dcb 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -49939,6 +49939,7 @@ package android.webkit {
public abstract class RenderProcessGoneDetail {
ctor public RenderProcessGoneDetail();
method public abstract boolean didCrash();
+ method public abstract int rendererPriorityAtExit();
}
public class ServiceWorkerClient {
@@ -50394,6 +50395,8 @@ package android.webkit {
method public deprecated java.lang.String[] getHttpAuthUsernamePassword(java.lang.String, java.lang.String);
method public java.lang.String getOriginalUrl();
method public int getProgress();
+ method public boolean getRendererPriorityWaivedWhenNotVisible();
+ method public int getRendererRequestedPriority();
method public deprecated float getScale();
method public android.webkit.WebSettings getSettings();
method public java.lang.String getTitle();
@@ -50442,6 +50445,7 @@ package android.webkit {
method public deprecated void setMapTrackballToArrowKeys(boolean);
method public void setNetworkAvailable(boolean);
method public deprecated void setPictureListener(android.webkit.WebView.PictureListener);
+ method public void setRendererPriorityPolicy(int, boolean);
method public deprecated void setVerticalScrollbarOverlay(boolean);
method public void setWebChromeClient(android.webkit.WebChromeClient);
method public static void setWebContentsDebuggingEnabled(boolean);
@@ -50452,6 +50456,9 @@ package android.webkit {
method public boolean zoomIn();
method public boolean zoomOut();
field public static final java.lang.String DATA_REDUCTION_PROXY_SETTING_CHANGED = "android.webkit.DATA_REDUCTION_PROXY_SETTING_CHANGED";
+ field public static final int RENDERER_PRIORITY_BOUND = 1; // 0x1
+ field public static final int RENDERER_PRIORITY_IMPORTANT = 2; // 0x2
+ field public static final int RENDERER_PRIORITY_WAIVED = 0; // 0x0
field public static final java.lang.String SCHEME_GEO = "geo:0,0?q=";
field public static final java.lang.String SCHEME_MAILTO = "mailto:";
field public static final java.lang.String SCHEME_TEL = "tel:";
@@ -50673,6 +50680,8 @@ package android.webkit {
method public abstract java.lang.String[] getHttpAuthUsernamePassword(java.lang.String, java.lang.String);
method public abstract java.lang.String getOriginalUrl();
method public abstract int getProgress();
+ method public abstract boolean getRendererPriorityWaivedWhenNotVisible();
+ method public abstract int getRendererRequestedPriority();
method public abstract float getScale();
method public abstract android.webkit.WebViewProvider.ScrollDelegate getScrollDelegate();
method public abstract android.webkit.WebSettings getSettings();
@@ -50727,6 +50736,7 @@ package android.webkit {
method public abstract void setMapTrackballToArrowKeys(boolean);
method public abstract void setNetworkAvailable(boolean);
method public abstract void setPictureListener(android.webkit.WebView.PictureListener);
+ method public abstract void setRendererPriorityPolicy(int, boolean);
method public abstract void setVerticalScrollbarOverlay(boolean);
method public abstract void setWebChromeClient(android.webkit.WebChromeClient);
method public abstract void setWebViewClient(android.webkit.WebViewClient);
diff --git a/api/test-current.txt b/api/test-current.txt
index 3fe04f77ba9f..1aa70ebbb74a 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -46905,6 +46905,7 @@ package android.webkit {
public abstract class RenderProcessGoneDetail {
ctor public RenderProcessGoneDetail();
method public abstract boolean didCrash();
+ method public abstract int rendererPriorityAtExit();
}
public class ServiceWorkerClient {
@@ -47321,6 +47322,8 @@ package android.webkit {
method public deprecated java.lang.String[] getHttpAuthUsernamePassword(java.lang.String, java.lang.String);
method public java.lang.String getOriginalUrl();
method public int getProgress();
+ method public boolean getRendererPriorityWaivedWhenNotVisible();
+ method public int getRendererRequestedPriority();
method public deprecated float getScale();
method public android.webkit.WebSettings getSettings();
method public java.lang.String getTitle();
@@ -47368,6 +47371,7 @@ package android.webkit {
method public deprecated void setMapTrackballToArrowKeys(boolean);
method public void setNetworkAvailable(boolean);
method public deprecated void setPictureListener(android.webkit.WebView.PictureListener);
+ method public void setRendererPriorityPolicy(int, boolean);
method public deprecated void setVerticalScrollbarOverlay(boolean);
method public void setWebChromeClient(android.webkit.WebChromeClient);
method public static void setWebContentsDebuggingEnabled(boolean);
@@ -47377,6 +47381,9 @@ package android.webkit {
method public void zoomBy(float);
method public boolean zoomIn();
method public boolean zoomOut();
+ field public static final int RENDERER_PRIORITY_BOUND = 1; // 0x1
+ field public static final int RENDERER_PRIORITY_IMPORTANT = 2; // 0x2
+ field public static final int RENDERER_PRIORITY_WAIVED = 0; // 0x0
field public static final java.lang.String SCHEME_GEO = "geo:0,0?q=";
field public static final java.lang.String SCHEME_MAILTO = "mailto:";
field public static final java.lang.String SCHEME_TEL = "tel:";
diff --git a/core/java/android/webkit/RenderProcessGoneDetail.java b/core/java/android/webkit/RenderProcessGoneDetail.java
index 77d85963ce2d..1c793993909d 100644
--- a/core/java/android/webkit/RenderProcessGoneDetail.java
+++ b/core/java/android/webkit/RenderProcessGoneDetail.java
@@ -32,4 +32,15 @@ public abstract class RenderProcessGoneDetail {
* system.
**/
public abstract boolean didCrash();
+
+ /**
+ * Returns the renderer priority that was set at the time that the
+ * renderer exited. This may be greater than the priority that
+ * any individual {@link WebView} requested using
+ * {@link WebView#setRendererPriorityPolicy}.
+ *
+ * @return the priority of the renderer at exit.
+ **/
+ @WebView.RendererPriority
+ public abstract int rendererPriorityAtExit();
}
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index f98c099f053f..1e7cddfcda92 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -16,6 +16,7 @@
package android.webkit;
+import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.annotation.Widget;
@@ -60,6 +61,8 @@ import android.widget.AbsoluteLayout;
import java.io.BufferedWriter;
import java.io.File;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.util.Map;
/**
@@ -2151,6 +2154,94 @@ public class WebView extends AbsoluteLayout
return mProvider.findHierarchyView(className, hashCode);
}
+ /** @hide */
+ @IntDef({
+ RENDERER_PRIORITY_WAIVED,
+ RENDERER_PRIORITY_BOUND,
+ RENDERER_PRIORITY_IMPORTANT
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface RendererPriority {}
+
+ /**
+ * The renderer associated with this WebView is bound with
+ * {@link Context#BIND_WAIVE_PRIORITY}. At this priority level
+ * {@link WebView} renderers will be strong targets for out of memory
+ * killing.
+ *
+ * Use with {@link #setRendererPriorityPolicy}.
+ */
+ public static final int RENDERER_PRIORITY_WAIVED = 0;
+ /**
+ * The renderer associated with this WebView is bound with
+ * the default priority for services.
+ *
+ * Use with {@link #setRendererPriorityPolicy}.
+ */
+ public static final int RENDERER_PRIORITY_BOUND = 1;
+ /**
+ * The renderer associated with this WebView is bound with
+ * {@link Context#BIND_IMPORTANT}.
+ *
+ * Use with {@link #setRendererPriorityPolicy}.
+ */
+ public static final int RENDERER_PRIORITY_IMPORTANT = 2;
+
+ /**
+ * Set the renderer priority policy for this {@link WebView}. The
+ * priority policy will be used to determine whether an out of
+ * process renderer should be considered to be a target for OOM
+ * killing.
+ *
+ * Because a renderer can be associated with more than one
+ * WebView, the final priority it is computed as the maximum of
+ * any attached WebViews. When a WebView is destroyed it will
+ * cease to be considerered when calculating the renderer
+ * priority. Once no WebViews remain associated with the renderer,
+ * the priority of the renderer will be reduced to
+ * {@link #RENDERER_PRIORITY_WAIVED}.
+ *
+ * The default policy is to set the priority to
+ * {@link #RENDERER_PRIORITY_IMPORTANT} regardless of visibility,
+ * and this should not be changed unless the caller also handles
+ * renderer crashes with
+ * {@link WebViewClient#onRenderProcessGone}. Any other setting
+ * will result in WebView renderers being killed by the system
+ * more aggressively than the application.
+ *
+ * @param rendererRequestedPriority the minimum priority at which
+ * this WebView desires the renderer process to be bound.
+ * @param waivedWhenNotVisible if true, this flag specifies that
+ * when this WebView is not visible, it will be treated as
+ * if it had requested a priority of
+ * {@link #RENDERER_PRIORITY_WAIVED}.
+ */
+ public void setRendererPriorityPolicy(
+ @RendererPriority int rendererRequestedPriority,
+ boolean waivedWhenNotVisible) {
+ mProvider.setRendererPriorityPolicy(rendererRequestedPriority, waivedWhenNotVisible);
+ }
+
+ /**
+ * Get the requested renderer priority for this WebView.
+ *
+ * @return the requested renderer priority policy.
+ */
+ @RendererPriority
+ public int getRendererRequestedPriority() {
+ return mProvider.getRendererRequestedPriority();
+ }
+
+ /**
+ * Return whether this WebView requests a priority of
+ * {@link #RENDERER_PRIORITY_WAIVED} when not visible.
+ *
+ * @return whether this WebView requests a priority of
+ * {@link #RENDERER_PRIORITY_WAIVED} when not visible.
+ */
+ public boolean getRendererPriorityWaivedWhenNotVisible() {
+ return mProvider.getRendererPriorityWaivedWhenNotVisible();
+ }
//-------------------------------------------------------------------------
// Interface for WebView providers
//-------------------------------------------------------------------------
diff --git a/core/java/android/webkit/WebViewProvider.java b/core/java/android/webkit/WebViewProvider.java
index dd1b0d2d17a4..ffc18b1e9c36 100644
--- a/core/java/android/webkit/WebViewProvider.java
+++ b/core/java/android/webkit/WebViewProvider.java
@@ -269,6 +269,12 @@ public interface WebViewProvider {
public View findHierarchyView(String className, int hashCode);
+ public void setRendererPriorityPolicy(int rendererRequestedPriority, boolean waivedWhenNotVisible);
+
+ public int getRendererRequestedPriority();
+
+ public boolean getRendererPriorityWaivedWhenNotVisible();
+
//-------------------------------------------------------------------------
// Provider internal methods
//-------------------------------------------------------------------------