Changeset 278651 in webkit
- Timestamp:
- Jun 9, 2021, 12:02:40 AM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 5 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/platform/sql/SQLiteDatabase.h (modified) (1 diff)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.cpp (modified) (5 diffs)
-
WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r278649 r278651 1 2021-06-09 Chris Dumez <cdumez@apple.com> 2 3 Rely on SQLiteDatabase::setMaximumSize() for quota management in LocalStorageDatabase 4 https://bugs.webkit.org/show_bug.cgi?id=226788 5 6 Reviewed by Sihui Liu. 7 8 Export SQLiteDatabase::setMaximumSize() so it can be used from WebKit2. 9 10 * platform/sql/SQLiteDatabase.h: 11 1 12 2021-06-08 Alex Christensen <achristensen@webkit.org> 2 13 -
trunk/Source/WebCore/platform/sql/SQLiteDatabase.h
r278150 r278651 104 104 // setMaximumSize() will round the size down to the next smallest chunk if the passed size doesn't align. 105 105 int64_t maximumSize(); 106 void setMaximumSize(int64_t);106 WEBCORE_EXPORT void setMaximumSize(int64_t); 107 107 108 108 // Gets the number of unused bytes in the database file. -
trunk/Source/WebKit/ChangeLog
r278649 r278651 1 2021-06-09 Chris Dumez <cdumez@apple.com> 2 3 Rely on SQLiteDatabase::setMaximumSize() for quota management in LocalStorageDatabase 4 https://bugs.webkit.org/show_bug.cgi?id=226788 5 6 Reviewed by Sihui Liu. 7 8 Rely on SQLiteDatabase::setMaximumSize() for quota management in LocalStorageDatabase. 9 It simplifies the code a bit. 10 11 No new test, covered by storage/domstorage/quota.html that is still passing. 12 13 * NetworkProcess/WebStorage/LocalStorageDatabase.cpp: 14 (WebKit::LocalStorageDatabase::openDatabase): 15 (WebKit::LocalStorageDatabase::removeItem): 16 (WebKit::LocalStorageDatabase::setItem): 17 (WebKit::LocalStorageDatabase::clear): 18 * NetworkProcess/WebStorage/LocalStorageDatabase.h: 19 1 20 2021-06-08 Alex Christensen <achristensen@webkit.org> 2 21 -
trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.cpp
r278338 r278651 91 91 } 92 92 93 if (m_quotaInBytes != WebCore::StorageMap::noQuota) 94 m_database.setMaximumSize(m_quotaInBytes); 95 93 96 return true; 94 97 } … … 182 185 return; 183 186 } 184 185 if (m_databaseSize) {186 auto sizeDecrease = key.sizeInBytes() + oldValue.sizeInBytes();187 if (sizeDecrease >= *m_databaseSize)188 *m_databaseSize = 0;189 else190 *m_databaseSize -= sizeDecrease;191 }192 187 } 193 188 … … 223 218 oldValue = item(key); 224 219 225 if (m_quotaInBytes != WebCore::StorageMap::noQuota) {226 if (!m_databaseSize)227 m_databaseSize = SQLiteFileSystem::databaseFileSize(m_databasePath);228 CheckedUint64 newDatabaseSize = *m_databaseSize;229 newDatabaseSize -= oldValue.sizeInBytes();230 newDatabaseSize += value.sizeInBytes();231 if (oldValue.isNull())232 newDatabaseSize += key.sizeInBytes();233 if (newDatabaseSize.hasOverflowed() || newDatabaseSize > m_quotaInBytes) {234 quotaException = true;235 return;236 }237 m_databaseSize = newDatabaseSize;238 }239 240 220 auto insertStatement = scopedStatement(m_insertStatement, "INSERT INTO ItemTable VALUES (?, ?)"_s); 241 221 if (!insertStatement) { … … 248 228 249 229 int result = insertStatement->step(); 250 if (result != SQLITE_DONE) 230 if (result != SQLITE_DONE) { 251 231 LOG_ERROR("Failed to update item in the local storage database - %i", result); 232 if (result == SQLITE_FULL) 233 quotaException = true; 234 } 252 235 } 253 236 … … 269 252 return false; 270 253 } 271 272 m_databaseSize = 0;273 254 274 255 return m_database.lastChanges() > 0; -
trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.h
r278253 r278651 69 69 const unsigned m_quotaInBytes { 0 }; 70 70 bool m_isClosed { false }; 71 std::optional<uint64_t> m_databaseSize;72 71 73 72 mutable std::unique_ptr<WebCore::SQLiteStatement> m_clearStatement;
Note:
See TracChangeset
for help on using the changeset viewer.