diff options
author | Andrei Popescu <andreip@google.com> | 2009-07-21 13:10:06 +0100 |
---|---|---|
committer | Andrei Popescu <andreip@google.com> | 2009-07-21 13:31:30 +0100 |
commit | c60802dd50f86c37e0596d41c3ef6fc2c8804da4 (patch) | |
tree | ef54137cbf064976e5f146c125691c40fb1136d3 /WebCore/platform/sql | |
parent | ce39e03a248f9bee3e746c15e7961b3e40a871ed (diff) | |
download | external_webkit-c60802dd50f86c37e0596d41c3ef6fc2c8804da4.zip external_webkit-c60802dd50f86c37e0596d41c3ef6fc2c8804da4.tar.gz external_webkit-c60802dd50f86c37e0596d41c3ef6fc2c8804da4.tar.bz2 |
Implements a mechanism that limit the growth of the application cache
Diffstat (limited to 'WebCore/platform/sql')
-rw-r--r-- | WebCore/platform/sql/SQLiteDatabase.cpp | 12 | ||||
-rw-r--r-- | WebCore/platform/sql/SQLiteDatabase.h | 3 |
2 files changed, 15 insertions, 0 deletions
diff --git a/WebCore/platform/sql/SQLiteDatabase.cpp b/WebCore/platform/sql/SQLiteDatabase.cpp index 702cf02..e16b04e 100644 --- a/WebCore/platform/sql/SQLiteDatabase.cpp +++ b/WebCore/platform/sql/SQLiteDatabase.cpp @@ -151,6 +151,18 @@ int SQLiteDatabase::pageSize() return m_pageSize; } +int64_t SQLiteDatabase::freeSpaceSize() +{ + MutexLocker locker(m_authorizerLock); + enableAuthorizer(false); + // Note: freelist_count was added in SQLite 3.4.1. + SQLiteStatement statement(*this, "PRAGMA freelist_count"); + int64_t size = statement.getColumnInt64(0) * pageSize(); + + enableAuthorizer(true); + return size; +} + void SQLiteDatabase::setSynchronous(SynchronousPragma sync) { executeCommand(String::format("PRAGMA synchronous = %i", sync)); diff --git a/WebCore/platform/sql/SQLiteDatabase.h b/WebCore/platform/sql/SQLiteDatabase.h index 76700dc..d313435 100644 --- a/WebCore/platform/sql/SQLiteDatabase.h +++ b/WebCore/platform/sql/SQLiteDatabase.h @@ -83,6 +83,9 @@ public: int64_t maximumSize(); void setMaximumSize(int64_t); + // Gets the number of unused bytes in the database file. + int64_t freeSpaceSize(); + // The SQLite SYNCHRONOUS pragma can be either FULL, NORMAL, or OFF // FULL - Any writing calls to the DB block until the data is actually on the disk surface // NORMAL - SQLite pauses at some critical moments when writing, but much less than FULL |