void StorageAreaImpl::setItem(const String& key, const String& value, ExceptionCode& ec, Frame* frame) { ASSERT(!m_isShutdown); ASSERT(!value.isNull()); blockUntilImportComplete(); if (privateBrowsingEnabled(frame)) { ec = QUOTA_EXCEEDED_ERR; return; } String oldValue; bool quotaException; RefPtr<StorageMap> newMap = m_storageMap->setItem(key, value, oldValue, quotaException); if (quotaException) { ec = QUOTA_EXCEEDED_ERR; return; } if (newMap) m_storageMap = newMap.release(); // Only notify the client if an item was actually changed if (oldValue != value) { if (m_storageAreaSync) m_storageAreaSync->scheduleItemForSync(key, value); StorageEventDispatcher::dispatch(key, oldValue, value, m_storageType, m_securityOrigin.get(), frame); } }
unsigned StorageAreaImpl::length() { ASSERT(!m_isShutdown); blockUntilImportComplete(); return m_storageMap->length(); }
String StorageAreaImpl::key(unsigned index) { ASSERT(!m_isShutdown); blockUntilImportComplete(); return m_storageMap->key(index); }
void StorageAreaImpl::removeItem(const String& key, ExceptionCode& ec, Frame* frame) { ec = 0; if (!canAccessStorage(frame)) { ec = SECURITY_ERR; return; } ASSERT(!m_isShutdown); blockUntilImportComplete(); if (disabledByPrivateBrowsingInFrame(frame)) return; String oldValue; RefPtr<StorageMap> newMap = m_storageMap->removeItem(key, oldValue); if (newMap) m_storageMap = newMap.release(); if (oldValue.isNull()) return; if (m_storageAreaSync) m_storageAreaSync->scheduleItemForSync(key, String()); StorageEventDispatcher::dispatch(key, oldValue, String(), m_storageType, m_securityOrigin.get(), frame); }
String StorageAreaImpl::getItem(const String& key) const { ASSERT(!m_isShutdown); blockUntilImportComplete(); return m_storageMap->getItem(key); }
bool StorageAreaImpl::contains(const String& key) const { ASSERT(!m_isShutdown); blockUntilImportComplete(); return m_storageMap->contains(key); }
void StorageAreaImpl::sync() { ASSERT(!m_isShutdown); blockUntilImportComplete(); if (m_storageAreaSync) m_storageAreaSync->scheduleSync(); }
void StorageAreaImpl::clearForOriginDeletion() { ASSERT(!m_isShutdown); blockUntilImportComplete(); if (m_storageMap->length()) { unsigned quota = m_storageMap->quota(); m_storageMap = StorageMap::create(quota); } if (m_storageAreaSync) { m_storageAreaSync->scheduleClear(); m_storageAreaSync->scheduleCloseDatabase(); } }
bool StorageAreaImpl::contains(const String& key, ExceptionCode& ec, Frame* frame) const { ec = 0; if (!canAccessStorage(frame)) { ec = SECURITY_ERR; return false; } if (disabledByPrivateBrowsingInFrame(frame)) return false; ASSERT(!m_isShutdown); blockUntilImportComplete(); return m_storageMap->contains(key); }
void StorageAreaImpl::clear(Frame* frame) { ASSERT(!m_isShutdown); blockUntilImportComplete(); if (privateBrowsingEnabled(frame)) return; unsigned quota = m_storageMap->quota(); m_storageMap = StorageMap::create(quota); if (m_storageAreaSync) m_storageAreaSync->scheduleClear(); StorageEventDispatcher::dispatch(String(), String(), String(), m_storageType, m_securityOrigin.get(), frame); }
String StorageAreaImpl::key(unsigned index, ExceptionCode& ec, Frame* frame) const { ec = 0; if (!canAccessStorage(frame)) { ec = SECURITY_ERR; return String(); } if (disabledByPrivateBrowsingInFrame(frame)) return String(); ASSERT(!m_isShutdown); blockUntilImportComplete(); return m_storageMap->key(index); }
unsigned StorageAreaImpl::length(ExceptionCode& ec, Frame* frame) const { ec = 0; if (!canAccessStorage(frame)) { ec = SECURITY_ERR; return 0; } if (disabledByPrivateBrowsingInFrame(frame)) return 0; ASSERT(!m_isShutdown); blockUntilImportComplete(); return m_storageMap->length(); }
void StorageAreaImpl::clear(Frame* sourceFrame) { ASSERT(!m_isShutdown); blockUntilImportComplete(); if (!m_storageMap->length()) return; unsigned quota = m_storageMap->quota(); m_storageMap = StorageMap::create(quota); if (m_storageAreaSync) m_storageAreaSync->scheduleClear(); dispatchStorageEvent(String(), String(), String(), sourceFrame); }
void StorageAreaSync::scheduleFinalSync() { ASSERT(isMainThread()); // FIXME: We do this to avoid races, but it'd be better to make things safe without blocking. blockUntilImportComplete(); if (m_syncTimer.isActive()) m_syncTimer.stop(); else { // The following is balanced by the call to enableSuddenTermination in the // syncTimerFired function. disableSuddenTermination(); } // FIXME: This is synchronous. We should do it on the background process, but // we should do it safely. syncTimerFired(&m_syncTimer); m_finalSyncScheduled = true; }
void StorageAreaImpl::removeItem(Frame* sourceFrame, const String& key) { ASSERT(!m_isShutdown); blockUntilImportComplete(); String oldValue; auto newMap = m_storageMap->removeItem(key, oldValue); if (newMap) m_storageMap = WTFMove(newMap); if (oldValue.isNull()) return; if (m_storageAreaSync) m_storageAreaSync->scheduleItemForSync(key, String()); dispatchStorageEvent(key, oldValue, String(), sourceFrame); }
void StorageAreaSync::scheduleFinalSync() { ASSERT(isMainThread()); // FIXME: We do this to avoid races, but it'd be better to make things safe without blocking. blockUntilImportComplete(); m_storageArea = 0; // This is done in blockUntilImportComplete() but this is here as a form of documentation that we must be absolutely sure the ref count cycle is broken. if (m_syncTimer.isActive()) m_syncTimer.stop(); else { // The following is balanced by the call to enableSuddenTermination in the // syncTimerFired function. disableSuddenTermination(); } // FIXME: This is synchronous. We should do it on the background process, but // we should do it safely. m_finalSyncScheduled = true; syncTimerFired(&m_syncTimer); m_syncManager->scheduleDeleteEmptyDatabase(this); }
void StorageAreaImpl::removeItem(const String& key, Frame* frame) { ASSERT(!m_isShutdown); blockUntilImportComplete(); if (privateBrowsingEnabled(frame)) return; String oldValue; RefPtr<StorageMap> newMap = m_storageMap->removeItem(key, oldValue); if (newMap) m_storageMap = newMap.release(); // Only notify the client if an item was actually removed if (!oldValue.isNull()) { if (m_storageAreaSync) m_storageAreaSync->scheduleItemForSync(key, String()); StorageEventDispatcher::dispatch(key, oldValue, String(), m_storageType, m_securityOrigin.get(), frame); } }
void StorageAreaImpl::setItem(Frame* sourceFrame, const String& key, const String& value, bool& quotaException) { ASSERT(!m_isShutdown); ASSERT(!value.isNull()); blockUntilImportComplete(); String oldValue; auto newMap = m_storageMap->setItem(key, value, oldValue, quotaException); if (newMap) m_storageMap = WTFMove(newMap); if (quotaException) return; if (oldValue == value) return; if (m_storageAreaSync) m_storageAreaSync->scheduleItemForSync(key, value); dispatchStorageEvent(key, oldValue, value, sourceFrame); }
void StorageAreaImpl::clear(ExceptionCode& ec, Frame* frame) { ec = 0; if (!canAccessStorage(frame)) { ec = SECURITY_ERR; return; } ASSERT(!m_isShutdown); blockUntilImportComplete(); if (disabledByPrivateBrowsingInFrame(frame)) return; if (!m_storageMap->length()) return; unsigned quota = m_storageMap->quota(); m_storageMap = StorageMap::create(quota); if (m_storageAreaSync) m_storageAreaSync->scheduleClear(); StorageEventDispatcher::dispatch(String(), String(), String(), m_storageType, m_securityOrigin.get(), frame); }
void StorageAreaImpl::closeDatabaseTimerFired() { blockUntilImportComplete(); if (m_storageAreaSync) m_storageAreaSync->scheduleCloseDatabase(); }