Vector<SecurityOriginData> LocalStorageDatabaseTracker::deleteDatabasesModifiedSince(std::chrono::system_clock::time_point time) { Vector<String> originIdentifiersToDelete; for (const String& origin : m_origins) { String filePath = pathForDatabaseWithOriginIdentifier(origin); auto modificationTime = fileModificationTime(filePath); if (!modificationTime) continue; if (modificationTime.value() >= std::chrono::system_clock::to_time_t(time)) originIdentifiersToDelete.append(origin); } Vector<SecurityOriginData> deletedDatabaseOrigins; deletedDatabaseOrigins.reserveInitialCapacity(originIdentifiersToDelete.size()); for (const auto& originIdentifier : originIdentifiersToDelete) { removeDatabaseWithOriginIdentifier(originIdentifier); if (auto origin = SecurityOriginData::fromDatabaseIdentifier(originIdentifier)) deletedDatabaseOrigins.uncheckedAppend(*origin); else ASSERT_NOT_REACHED(); } return deletedDatabaseOrigins; }
void LocalStorageDatabaseTracker::updateTrackerDatabaseFromLocalStorageDatabaseFiles() { Vector<String> paths = listDirectory(m_localStorageDirectory, "*.localstorage"); HashSet<String> origins(m_origins); HashSet<String> originsFromLocalStorageDatabaseFiles; for (size_t i = 0; i < paths.size(); ++i) { const String& path = paths[i]; if (!path.endsWith(".localstorage")) continue; String filename = pathGetFileName(path); String originIdentifier = filename.substring(0, filename.length() - strlen(".localstorage")); if (!m_origins.contains(originIdentifier)) addDatabaseWithOriginIdentifier(originIdentifier, path); originsFromLocalStorageDatabaseFiles.add(originIdentifier); } for (auto it = origins.begin(), end = origins.end(); it != end; ++it) { const String& originIdentifier = *it; if (origins.contains(originIdentifier)) continue; removeDatabaseWithOriginIdentifier(originIdentifier); } }
void LocalStorageDatabaseTracker::deleteDatabaseWithOrigin(const SecurityOriginData& securityOrigin) { removeDatabaseWithOriginIdentifier(securityOrigin.databaseIdentifier()); }
void LocalStorageDatabaseTracker::deleteDatabaseWithOrigin(SecurityOrigin* securityOrigin) { removeDatabaseWithOriginIdentifier(securityOrigin->databaseIdentifier()); }