GeolocationPermissions::OriginSet GeolocationPermissions::getOrigins() { maybeLoadPermanentPermissions(); OriginSet origins; PermissionsMap::const_iterator end = s_permanentPermissions.end(); for (PermissionsMap::const_iterator iter = s_permanentPermissions.begin(); iter != end; ++iter) origins.add(iter->first); return origins; }
void StorageTracker::syncFileSystemAndTrackerDatabase() { ASSERT(!isMainThread()); SQLiteTransactionInProgressAutoCounter transactionCounter; ASSERT(m_isActive); Vector<String> paths; { MutexLocker locker(m_databaseMutex); paths = listDirectory(m_storageDirectoryPath, "*.localstorage"); } // Use a copy of m_originSet to find expired entries and to schedule their // deletions from disk and from m_originSet. OriginSet originSetCopy; { MutexLocker locker(m_originSetMutex); for (OriginSet::const_iterator it = m_originSet.begin(), end = m_originSet.end(); it != end; ++it) originSetCopy.add((*it).isolatedCopy()); } // Add missing StorageTracker records. OriginSet foundOrigins; String fileExtension = ASCIILiteral(".localstorage"); for (Vector<String>::const_iterator it = paths.begin(), end = paths.end(); it != end; ++it) { const String& path = *it; if (path.length() > fileExtension.length() && path.endsWith(fileExtension, true)) { String file = pathGetFileName(path); String originIdentifier = file.substring(0, file.length() - fileExtension.length()); if (!originSetCopy.contains(originIdentifier)) syncSetOriginDetails(originIdentifier, path); foundOrigins.add(originIdentifier); } } // Delete stale StorageTracker records. for (OriginSet::const_iterator it = originSetCopy.begin(), end = originSetCopy.end(); it != end; ++it) { const String& originIdentifier = *it; if (foundOrigins.contains(originIdentifier)) continue; String originIdentifierCopy = originIdentifier.isolatedCopy(); callOnMainThread([this, originIdentifierCopy] { deleteOriginWithIdentifier(originIdentifierCopy); }); } }
void StorageTracker::syncFileSystemAndTrackerDatabase() { ASSERT(!isMainThread()); ASSERT(m_isActive); m_databaseGuard.lock(); DEFINE_STATIC_LOCAL(const String, fileMatchPattern, ("*.localstorage")); DEFINE_STATIC_LOCAL(const String, fileExt, (".localstorage")); DEFINE_STATIC_LOCAL(const unsigned, fileExtLength, (fileExt.length())); m_databaseGuard.unlock(); Vector<String> paths; { MutexLocker lock(m_databaseGuard); paths = listDirectory(m_storageDirectoryPath, fileMatchPattern); } // Use a copy of m_originSet to find expired entries and to schedule their // deletions from disk and from m_originSet. OriginSet originSetCopy; { MutexLocker lock(m_originSetGuard); OriginSet::const_iterator end = m_originSet.end(); for (OriginSet::const_iterator it = m_originSet.begin(); it != end; ++it) originSetCopy.add((*it).threadsafeCopy()); } // Add missing StorageTracker records. OriginSet foundOrigins; Vector<String>::const_iterator end = paths.end(); for (Vector<String>::const_iterator it = paths.begin(); it != end; ++it) { String path = *it; if (path.endsWith(fileExt, true) && path.length() > fileExtLength) { String file = pathGetFileName(path); String originIdentifier = file.substring(0, file.length() - fileExtLength); if (!originSetCopy.contains(originIdentifier)) syncSetOriginDetails(originIdentifier, path); foundOrigins.add(originIdentifier); } } // Delete stale StorageTracker records. OriginSet::const_iterator setEnd = originSetCopy.end(); for (OriginSet::const_iterator it = originSetCopy.begin(); it != setEnd; ++it) { if (!foundOrigins.contains(*it)) { RefPtr<StringImpl> originIdentifier = (*it).threadsafeCopy().impl(); callOnMainThread(deleteOriginOnMainThread, originIdentifier.release().leakRef()); } } }