Skip to content

Commit 285ddfc

Browse files
author
Steve Block
committed
Clean up JavaDoc for WebStorage
Bug: 5461416 Change-Id: Ice7a2ca1e346ae80f53b477d236ff8c20032cf2f
1 parent b187d52 commit 285ddfc

File tree

4 files changed

+160
-100
lines changed

4 files changed

+160
-100
lines changed

core/java/android/webkit/CallbackProxy.java

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -479,34 +479,34 @@ public void handleMessage(Message msg) {
479479
String databaseIdentifier =
480480
(String) map.get("databaseIdentifier");
481481
String url = (String) map.get("url");
482-
long currentQuota =
483-
((Long) map.get("currentQuota")).longValue();
484-
long totalUsedQuota =
485-
((Long) map.get("totalUsedQuota")).longValue();
486-
long estimatedSize =
487-
((Long) map.get("estimatedSize")).longValue();
482+
long quota =
483+
((Long) map.get("quota")).longValue();
484+
long totalQuota =
485+
((Long) map.get("totalQuota")).longValue();
486+
long estimatedDatabaseSize =
487+
((Long) map.get("estimatedDatabaseSize")).longValue();
488488
WebStorage.QuotaUpdater quotaUpdater =
489489
(WebStorage.QuotaUpdater) map.get("quotaUpdater");
490490

491491
mWebChromeClient.onExceededDatabaseQuota(url,
492-
databaseIdentifier, currentQuota, estimatedSize,
493-
totalUsedQuota, quotaUpdater);
492+
databaseIdentifier, quota, estimatedDatabaseSize,
493+
totalQuota, quotaUpdater);
494494
}
495495
break;
496496

497497
case REACHED_APPCACHE_MAXSIZE:
498498
if (mWebChromeClient != null) {
499499
HashMap<String, Object> map =
500500
(HashMap<String, Object>) msg.obj;
501-
long spaceNeeded =
502-
((Long) map.get("spaceNeeded")).longValue();
503-
long totalUsedQuota =
504-
((Long) map.get("totalUsedQuota")).longValue();
501+
long requiredStorage =
502+
((Long) map.get("requiredStorage")).longValue();
503+
long quota =
504+
((Long) map.get("quota")).longValue();
505505
WebStorage.QuotaUpdater quotaUpdater =
506506
(WebStorage.QuotaUpdater) map.get("quotaUpdater");
507507

508-
mWebChromeClient.onReachedMaxAppCacheSize(spaceNeeded,
509-
totalUsedQuota, quotaUpdater);
508+
mWebChromeClient.onReachedMaxAppCacheSize(requiredStorage,
509+
quota, quotaUpdater);
510510
}
511511
break;
512512

@@ -1422,29 +1422,31 @@ public boolean onJsBeforeUnload(String url, String message) {
14221422
* @param url The URL that caused the quota overflow.
14231423
* @param databaseIdentifier The identifier of the database that the
14241424
* transaction that caused the overflow was running on.
1425-
* @param currentQuota The current quota the origin is allowed.
1426-
* @param estimatedSize The estimated size of the database.
1427-
* @param totalUsedQuota is the sum of all origins' quota.
1425+
* @param quota The current quota the origin is allowed.
1426+
* @param estimatedDatabaseSize The estimated size of the database.
1427+
* @param totalQuota is the sum of all origins' quota.
14281428
* @param quotaUpdater An instance of a class encapsulating a callback
14291429
* to WebViewCore to run when the decision to allow or deny more
14301430
* quota has been made.
14311431
*/
14321432
public void onExceededDatabaseQuota(
1433-
String url, String databaseIdentifier, long currentQuota,
1434-
long estimatedSize, long totalUsedQuota,
1433+
String url, String databaseIdentifier, long quota,
1434+
long estimatedDatabaseSize, long totalQuota,
14351435
WebStorage.QuotaUpdater quotaUpdater) {
14361436
if (mWebChromeClient == null) {
1437-
quotaUpdater.updateQuota(currentQuota);
1437+
// Native-side logic prevents the quota being updated to a smaller
1438+
// value.
1439+
quotaUpdater.updateQuota(quota);
14381440
return;
14391441
}
14401442

14411443
Message exceededQuota = obtainMessage(EXCEEDED_DATABASE_QUOTA);
14421444
HashMap<String, Object> map = new HashMap();
14431445
map.put("databaseIdentifier", databaseIdentifier);
14441446
map.put("url", url);
1445-
map.put("currentQuota", currentQuota);
1446-
map.put("estimatedSize", estimatedSize);
1447-
map.put("totalUsedQuota", totalUsedQuota);
1447+
map.put("quota", quota);
1448+
map.put("estimatedDatabaseSize", estimatedDatabaseSize);
1449+
map.put("totalQuota", totalQuota);
14481450
map.put("quotaUpdater", quotaUpdater);
14491451
exceededQuota.obj = map;
14501452
sendMessage(exceededQuota);
@@ -1453,24 +1455,26 @@ public void onExceededDatabaseQuota(
14531455
/**
14541456
* Called by WebViewCore to inform the Java side that the appcache has
14551457
* exceeded its max size.
1456-
* @param spaceNeeded is the amount of disk space that would be needed
1457-
* in order for the last appcache operation to succeed.
1458-
* @param totalUsedQuota is the sum of all origins' quota.
1458+
* @param requiredStorage is the amount of storage, in bytes, that would be
1459+
* needed in order for the last appcache operation to succeed.
1460+
* @param quota is the current quota (for all origins).
14591461
* @param quotaUpdater An instance of a class encapsulating a callback
14601462
* to WebViewCore to run when the decision to allow or deny a bigger
14611463
* app cache size has been made.
14621464
*/
1463-
public void onReachedMaxAppCacheSize(long spaceNeeded,
1464-
long totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater) {
1465+
public void onReachedMaxAppCacheSize(long requiredStorage,
1466+
long quota, WebStorage.QuotaUpdater quotaUpdater) {
14651467
if (mWebChromeClient == null) {
1466-
quotaUpdater.updateQuota(0);
1468+
// Native-side logic prevents the quota being updated to a smaller
1469+
// value.
1470+
quotaUpdater.updateQuota(quota);
14671471
return;
14681472
}
14691473

14701474
Message msg = obtainMessage(REACHED_APPCACHE_MAXSIZE);
14711475
HashMap<String, Object> map = new HashMap();
1472-
map.put("spaceNeeded", spaceNeeded);
1473-
map.put("totalUsedQuota", totalUsedQuota);
1476+
map.put("requiredStorage", requiredStorage);
1477+
map.put("quota", quota);
14741478
map.put("quotaUpdater", quotaUpdater);
14751479
msg.obj = map;
14761480
sendMessage(msg);

core/java/android/webkit/WebChromeClient.java

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -216,37 +216,54 @@ public boolean onJsBeforeUnload(WebView view, String url, String message,
216216
}
217217

218218
/**
219-
* Tell the client that the database quota for the origin has been exceeded.
220-
* @param url The URL that triggered the notification
221-
* @param databaseIdentifier The identifier of the database that caused the
222-
* quota overflow.
223-
* @param currentQuota The current quota for the origin.
224-
* @param estimatedSize The estimated size of the database.
225-
* @param totalUsedQuota is the sum of all origins' quota.
226-
* @param quotaUpdater A callback to inform the WebCore thread that a new
227-
* quota is available. This callback must always be executed at some
228-
* point to ensure that the sleeping WebCore thread is woken up.
219+
* Tell the client that the quota has been exceeded for the Web SQL Database
220+
* API for a particular origin and request a new quota. The client must
221+
* respond by invoking the
222+
* {@link WebStorage.QuotaUpdater#updateQuota(long) updateQuota(long)}
223+
* method of the supplied {@link WebStorage.QuotaUpdater} instance. The
224+
* minimum value that can be set for the new quota is the current quota. The
225+
* default implementation responds with the current quota, so the quota will
226+
* not be increased.
227+
* @param url The URL of the page that triggered the notification
228+
* @param databaseIdentifier The identifier of the database where the quota
229+
* was exceeded.
230+
* @param quota The quota for the origin, in bytes
231+
* @param estimatedDatabaseSize The estimated size of the offending
232+
* database, in bytes
233+
* @param totalQuota The total quota for all origins, in bytes
234+
* @param quotaUpdater An instance of {@link WebStorage.QuotaUpdater} which
235+
* must be used to inform the WebView of the new quota.
229236
*/
237+
// Note that the callback must always be executed at some point to ensure
238+
// that the sleeping WebCore thread is woken up.
230239
public void onExceededDatabaseQuota(String url, String databaseIdentifier,
231-
long currentQuota, long estimatedSize, long totalUsedQuota,
232-
WebStorage.QuotaUpdater quotaUpdater) {
240+
long quota, long estimatedDatabaseSize, long totalQuota,
241+
WebStorage.QuotaUpdater quotaUpdater) {
233242
// This default implementation passes the current quota back to WebCore.
234243
// WebCore will interpret this that new quota was declined.
235-
quotaUpdater.updateQuota(currentQuota);
244+
quotaUpdater.updateQuota(quota);
236245
}
237246

238247
/**
239-
* Tell the client that the Application Cache has exceeded its max size.
240-
* @param spaceNeeded is the amount of disk space that would be needed
241-
* in order for the last appcache operation to succeed.
242-
* @param totalUsedQuota is the sum of all origins' quota.
243-
* @param quotaUpdater A callback to inform the WebCore thread that a new
244-
* app cache size is available. This callback must always be executed at
245-
* some point to ensure that the sleeping WebCore thread is woken up.
248+
* Tell the client that the quota has been reached for the Application Cache
249+
* API and request a new quota. The client must respond by invoking the
250+
* {@link WebStorage.QuotaUpdater#updateQuota(long) updateQuota(long)}
251+
* method of the supplied {@link WebStorage.QuotaUpdater} instance. The
252+
* minimum value that can be set for the new quota is the current quota. The
253+
* default implementation responds with the current quota, so the quota will
254+
* not be increased.
255+
* @param requiredStorage The amount of storage required by the Application
256+
* Cache operation that triggered this notification,
257+
* in bytes.
258+
* @param quota The quota, in bytes
259+
* @param quotaUpdater An instance of {@link WebStorage.QuotaUpdater} which
260+
* must be used to inform the WebView of the new quota.
246261
*/
247-
public void onReachedMaxAppCacheSize(long spaceNeeded, long totalUsedQuota,
262+
// Note that the callback must always be executed at some point to ensure
263+
// that the sleeping WebCore thread is woken up.
264+
public void onReachedMaxAppCacheSize(long requiredStorage, long quota,
248265
WebStorage.QuotaUpdater quotaUpdater) {
249-
quotaUpdater.updateQuota(0);
266+
quotaUpdater.updateQuota(quota);
250267
}
251268

252269
/**

0 commit comments

Comments
 (0)