Skip to content

Commit

Permalink
little better database quota management, increse db size in steps of 1Mb
Browse files Browse the repository at this point in the history
  • Loading branch information
ianic committed Apr 23, 2010
1 parent fd9c8c0 commit f5cd1fe
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions framework/src/com/phonegap/DroidGap.java
Expand Up @@ -220,7 +220,7 @@ public void onClick(DialogInterface dialog, int which) {
public final class EclairClient extends GapClient
{
private String TAG = "PhoneGapLog";
private long MAX_QUOTA = 2000000;
private long MAX_QUOTA = 100 * 1024 * 1024;

public EclairClient(Context ctx) {
super(ctx);
Expand All @@ -230,18 +230,21 @@ public EclairClient(Context ctx) {
public void onExceededDatabaseQuota(String url, String databaseIdentifier, long currentQuota, long estimatedSize,
long totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater)
{

Log.d(TAG, "event raised onExceededDatabaseQuota estimatedSize: " + Long.toString(estimatedSize) + " currentQuota: " + Long.toString(currentQuota) + " totalUsedQuota: " + Long.toString(totalUsedQuota));

if( estimatedSize < MAX_QUOTA)
{
long newQuota = estimatedSize;
{
//increase for 1Mb
long newQuota = currentQuota + 1024*1024;
Log.d(TAG, "calling quotaUpdater.updateQuota newQuota: " + Long.toString(newQuota) );
quotaUpdater.updateQuota(newQuota);
}
else
{
// Set the quota to whatever it is and force an error
// TODO: get docs on how to handle this properly
quotaUpdater.updateQuota(currentQuota);
}
}
}

// This is a test of console.log, because we don't have this in Android 2.01
Expand Down

0 comments on commit f5cd1fe

Please sign in to comment.