Esempio n. 1
0
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);
    }
}
Esempio n. 2
0
unsigned StorageAreaImpl::length()
{
    ASSERT(!m_isShutdown);
    blockUntilImportComplete();

    return m_storageMap->length();
}
Esempio n. 3
0
String StorageAreaImpl::key(unsigned index)
{
    ASSERT(!m_isShutdown);
    blockUntilImportComplete();

    return m_storageMap->key(index);
}
Esempio n. 4
0
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);
}
Esempio n. 5
0
String StorageAreaImpl::getItem(const String& key) const
{
    ASSERT(!m_isShutdown);
    blockUntilImportComplete();

    return m_storageMap->getItem(key);
}
Esempio n. 6
0
bool StorageAreaImpl::contains(const String& key) const
{
    ASSERT(!m_isShutdown);
    blockUntilImportComplete();

    return m_storageMap->contains(key);
}
Esempio n. 7
0
void StorageAreaImpl::sync()
{
    ASSERT(!m_isShutdown);
    blockUntilImportComplete();
    
    if (m_storageAreaSync)
        m_storageAreaSync->scheduleSync();
}
Esempio n. 8
0
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();
    }
}
Esempio n. 9
0
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);
}
Esempio n. 10
0
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);
}
Esempio n. 11
0
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);
}
Esempio n. 12
0
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();
}
Esempio n. 13
0
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;
}
Esempio n. 15
0
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);
}
Esempio n. 16
0
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);
}
Esempio n. 17
0
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);
    }
}
Esempio n. 18
0
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);
}
Esempio n. 19
0
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);
}
Esempio n. 20
0
void StorageAreaImpl::closeDatabaseTimerFired()
{
    blockUntilImportComplete();
    if (m_storageAreaSync)
        m_storageAreaSync->scheduleCloseDatabase();
}