Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d10e4af0 authored by Tobias Sargeant's avatar Tobias Sargeant
Browse files

WebView: Add the definition of the renderer importance API.

The renderer importance API is used to specify how important
out-of-process WebView renderer services are for the purposes of OOM
killing and scheduling with respect to the binding application.

This allows an application to - for example - specify that renderers can
be killed while the application is not in the foreground, thus cleaning
up additional resources.

Bug: 30824898
Test: Tests await Chromium change.
Change-Id: I6dca3d427d6cdb5cb7e0be6f7fb8ece64bd24af9
parent daca8ee6
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -46575,6 +46575,7 @@ package android.webkit {
  public abstract class RenderProcessGoneDetail {
    ctor public RenderProcessGoneDetail();
    method public abstract boolean didCrash();
    method public abstract int rendererPriorityAtExit();
  }
  public class ServiceWorkerClient {
@@ -46991,6 +46992,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();
@@ -47038,6 +47041,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);
@@ -47047,6 +47051,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:";
+10 −0
Original line number Diff line number Diff line
@@ -49907,6 +49907,7 @@ package android.webkit {
  public abstract class RenderProcessGoneDetail {
    ctor public RenderProcessGoneDetail();
    method public abstract boolean didCrash();
    method public abstract int rendererPriorityAtExit();
  }
  public class ServiceWorkerClient {
@@ -50362,6 +50363,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();
@@ -50410,6 +50413,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);
@@ -50420,6 +50424,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:";
@@ -50641,6 +50648,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();
@@ -50695,6 +50704,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);
+7 −0
Original line number Diff line number Diff line
@@ -46873,6 +46873,7 @@ package android.webkit {
  public abstract class RenderProcessGoneDetail {
    ctor public RenderProcessGoneDetail();
    method public abstract boolean didCrash();
    method public abstract int rendererPriorityAtExit();
  }
  public class ServiceWorkerClient {
@@ -47289,6 +47290,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();
@@ -47336,6 +47339,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);
@@ -47345,6 +47349,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:";
+11 −0
Original line number Diff line number Diff line
@@ -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();
}
+91 −0
Original line number Diff line number Diff line
@@ -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
    //-------------------------------------------------------------------------
Loading