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

Commit 3b2fb7b2 authored by Selim Gurun's avatar Selim Gurun Committed by Android (Google) Code Review
Browse files

Merge "Fix onReachedMaxAppCacheSize callback"

parents b632adfa c86bec97
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -245,8 +245,8 @@ public class WebChromeClient {
    }
    }


   /**
   /**
    * Tell the client that the quota has been reached for the Application Cache
    * Notify the host application that the Application Cache has reached the
    * API and request a new quota. The client must respond by invoking the
    * maximum size. The client must respond by invoking the
    * {@link WebStorage.QuotaUpdater#updateQuota(long) updateQuota(long)}
    * {@link WebStorage.QuotaUpdater#updateQuota(long) updateQuota(long)}
    * method of the supplied {@link WebStorage.QuotaUpdater} instance. The
    * method of the supplied {@link WebStorage.QuotaUpdater} instance. The
    * minimum value that can be set for the new quota is the current quota. The
    * minimum value that can be set for the new quota is the current quota. The
@@ -255,7 +255,7 @@ public class WebChromeClient {
    * @param requiredStorage The amount of storage required by the Application
    * @param requiredStorage The amount of storage required by the Application
    *                        Cache operation that triggered this notification,
    *                        Cache operation that triggered this notification,
    *                        in bytes.
    *                        in bytes.
    * @param quota The quota, in bytes
    * @param quota the current maximum Application Cache size, in bytes
    * @param quotaUpdater An instance of {@link WebStorage.QuotaUpdater} which
    * @param quotaUpdater An instance of {@link WebStorage.QuotaUpdater} which
    *                     must be used to inform the WebView of the new quota.
    *                     must be used to inform the WebView of the new quota.
    */
    */
+9 −6
Original line number Original line Diff line number Diff line
@@ -443,7 +443,7 @@ public final class WebViewCore {
    }
    }


    /**
    /**
     * Notify the browser that the origin has exceeded it's database quota.
     * Notify the embedding application that the origin has exceeded it's database quota.
     * @param url The URL that caused the overflow.
     * @param url The URL that caused the overflow.
     * @param databaseIdentifier The identifier of the database.
     * @param databaseIdentifier The identifier of the database.
     * @param quota The current quota for the origin.
     * @param quota The current quota for the origin.
@@ -468,12 +468,15 @@ public final class WebViewCore {
    }
    }


    /**
    /**
     * Notify the browser that the appcache has exceeded its max size.
     * Notify the embedding application that the appcache has reached or exceeded its maximum
     * allowed storage size.
     *
     * @param requiredStorage is the amount of storage, in bytes, that would be
     * @param requiredStorage is the amount of storage, in bytes, that would be
     * needed in order for the last appcache operation to succeed.
     * needed in order for the last appcache operation to succeed.
     * @param maxSize maximum allowed Application Cache database size, in bytes.
     */
     */
    protected void reachedMaxAppCacheSize(long requiredStorage) {
    protected void reachedMaxAppCacheSize(long requiredStorage, long maxSize) {
        mCallbackProxy.onReachedMaxAppCacheSize(requiredStorage, getUsedQuota(),
        mCallbackProxy.onReachedMaxAppCacheSize(requiredStorage, maxSize,
                new WebStorage.QuotaUpdater() {
                new WebStorage.QuotaUpdater() {
                    @Override
                    @Override
                    public void updateQuota(long newQuota) {
                    public void updateQuota(long newQuota) {
@@ -2117,8 +2120,8 @@ public final class WebViewCore {
        return width;
        return width;
    }
    }


    // Utility method for exceededDatabaseQuota and reachedMaxAppCacheSize
    // Utility method for exceededDatabaseQuota callback. Computes the sum
    // callbacks. Computes the sum of database quota for all origins.
    // of WebSQL database quota for all origins.
    private long getUsedQuota() {
    private long getUsedQuota() {
        WebStorageClassic webStorage = WebStorageClassic.getInstance();
        WebStorageClassic webStorage = WebStorageClassic.getInstance();
        Collection<WebStorage.Origin> origins = webStorage.getOriginsSync();
        Collection<WebStorage.Origin> origins = webStorage.getOriginsSync();