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

Commit c86bec97 authored by Selim Gurun's avatar Selim Gurun
Browse files

Fix onReachedMaxAppCacheSize callback

Bug: 5869022

When appcache reached max size, a callback is triggered. The
second parameter of this callback was returning the used Web SQL
quota, which is a rather different concept then AppCache. Fix this
to return max database size.

Change-Id: Iee11f40aa9635eaa22e237d4ddfb98792c977497
parent e446e6c9
Loading
Loading
Loading
Loading
+3 −3
Original line number 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
    * API and request a new quota. The client must respond by invoking the
    * Notify the host application that the Application Cache has reached the
    * maximum size. The client must respond by invoking the
    * {@link WebStorage.QuotaUpdater#updateQuota(long) updateQuota(long)}
    * method of the supplied {@link WebStorage.QuotaUpdater} instance. 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
    *                        Cache operation that triggered this notification,
    *                        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
    *                     must be used to inform the WebView of the new quota.
    */
+9 −6
Original line number 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 databaseIdentifier The identifier of the database.
     * @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
     * 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) {
        mCallbackProxy.onReachedMaxAppCacheSize(requiredStorage, getUsedQuota(),
    protected void reachedMaxAppCacheSize(long requiredStorage, long maxSize) {
        mCallbackProxy.onReachedMaxAppCacheSize(requiredStorage, maxSize,
                new WebStorage.QuotaUpdater() {
                    @Override
                    public void updateQuota(long newQuota) {
@@ -2137,8 +2140,8 @@ public final class WebViewCore {
        return width;
    }

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