diff options
Diffstat (limited to 'WebCore/platform')
-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 |