Changeset 148250 in webkit


Ignore:
Timestamp:
Apr 11, 2013 4:55:03 PM (11 years ago)
Author:
andersca@apple.com
Message:

Add support for clearing storage areas
https://bugs.webkit.org/show_bug.cgi?id=114479

Reviewed by Beth Dakin.

  • UIProcess/Storage/StorageManager.cpp:

(WebKit::StorageManager::StorageArea::StorageArea):
Store the quota size so we can recreate the underlying StorageMap when clearing.

(WebKit::StorageManager::StorageArea::clear):
Create a new storage map and dispatch events.

(WebKit::StorageManager::clear):
Find the right storage area and call clear.

  • UIProcess/Storage/StorageManager.messages.in:

Add Clear message.

  • WebProcess/Storage/StorageAreaImpl.cpp:

(WebKit::StorageAreaImpl::clear):
Call the storage map.

  • WebProcess/Storage/StorageAreaMap.cpp:

(WebKit::StorageAreaMap::clear):
Reset the cached values and send a clear message.

(WebKit::StorageAreaMap::resetValues):
New helper function.

(WebKit::StorageAreaMap::didClear):
New stub.

  • WebProcess/Storage/StorageAreaMap.messages.in:

Add DidClear message.

Location:
trunk/Source/WebKit2
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r148249 r148250  
     12013-04-11  Anders Carlsson  <andersca@apple.com>
     2
     3        Add support for clearing storage areas
     4        https://bugs.webkit.org/show_bug.cgi?id=114479
     5
     6        Reviewed by Beth Dakin.
     7
     8        * UIProcess/Storage/StorageManager.cpp:
     9        (WebKit::StorageManager::StorageArea::StorageArea):
     10        Store the quota size so we can recreate the underlying StorageMap when clearing.
     11       
     12        (WebKit::StorageManager::StorageArea::clear):
     13        Create a new storage map and dispatch events.
     14
     15        (WebKit::StorageManager::clear):
     16        Find the right storage area and call clear.
     17
     18        * UIProcess/Storage/StorageManager.messages.in:
     19        Add Clear message.
     20
     21        * WebProcess/Storage/StorageAreaImpl.cpp:
     22        (WebKit::StorageAreaImpl::clear):
     23        Call the storage map.
     24
     25        * WebProcess/Storage/StorageAreaMap.cpp:
     26        (WebKit::StorageAreaMap::clear):
     27        Reset the cached values and send a clear message.
     28
     29        (WebKit::StorageAreaMap::resetValues):
     30        New helper function.
     31
     32        (WebKit::StorageAreaMap::didClear):
     33        New stub.
     34
     35        * WebProcess/Storage/StorageAreaMap.messages.in:
     36        Add DidClear message.
     37
    1382013-04-11  Beth Dakin  <bdakin@apple.com>
    239
  • trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp

    r148245 r148250  
    4949    void setItem(CoreIPC::Connection* sourceConnection, uint64_t sourceStorageAreaID, const String& key, const String& value, const String& urlString, bool& quotaException);
    5050    void removeItem(CoreIPC::Connection* sourceConnection, uint64_t sourceStorageAreaID, const String& key, const String& urlString);
     51    void clear(CoreIPC::Connection* sourceConnection, uint64_t sourceStorageAreaID, const String& urlString);
    5152
    5253    const HashMap<String, String>& items() const { return m_storageMap->items(); }
     
    5758    void dispatchEvents(CoreIPC::Connection* sourceConnection, uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString) const;
    5859
     60    unsigned m_quotaInBytes;
    5961    RefPtr<StorageMap> m_storageMap;
    6062    HashSet<std::pair<RefPtr<CoreIPC::Connection>, uint64_t> > m_eventListeners;
     
    6769
    6870StorageManager::StorageArea::StorageArea(unsigned quotaInBytes)
    69     : m_storageMap(StorageMap::create(quotaInBytes))
     71    : m_quotaInBytes(quotaInBytes)
     72    , m_storageMap(StorageMap::create(m_quotaInBytes))
    7073{
    7174}
     
    108111
    109112    dispatchEvents(sourceConnection, sourceStorageAreaID, key, oldValue, String(), urlString);
     113}
     114
     115void StorageManager::StorageArea::clear(CoreIPC::Connection* sourceConnection, uint64_t sourceStorageAreaID, const String& urlString)
     116{
     117    if (!m_storageMap->length())
     118        return;
     119
     120    m_storageMap = StorageMap::create(m_quotaInBytes);
     121
     122    dispatchEvents(sourceConnection, sourceStorageAreaID, String(), String(), String(), urlString);
    110123}
    111124
     
    302315    storageArea->removeItem(connection, sourceStorageAreaID, key, urlString);
    303316    connection->send(Messages::StorageAreaMap::DidRemoveItem(key), storageMapID);
     317}
     318
     319void StorageManager::clear(CoreIPC::Connection* connection, uint64_t storageMapID, uint64_t sourceStorageAreaID, const String& urlString)
     320{
     321    StorageArea* storageArea = findStorageArea(connection, storageMapID);
     322
     323    // FIXME: This should be a message check.
     324    ASSERT(storageArea);
     325
     326    storageArea->clear(connection, sourceStorageAreaID, urlString);
     327    connection->send(Messages::StorageAreaMap::DidClear(), storageMapID);
    304328}
    305329
  • trunk/Source/WebKit2/UIProcess/Storage/StorageManager.h

    r148245 r148250  
    6565    void setItem(CoreIPC::Connection*, uint64_t storageAreaID, uint64_t sourceStorageAreaID, const String& key, const String& value, const String& urlString);
    6666    void removeItem(CoreIPC::Connection*, uint64_t storageMapID, uint64_t sourceStorageAreaID, const String& key, const String& urlString);
     67    void clear(CoreIPC::Connection*, uint64_t storageMapID, uint64_t sourceStorageAreaID, const String& urlString);
    6768
    6869    void createSessionStorageNamespaceInternal(uint64_t storageNamespaceID, CoreIPC::Connection* allowedConnection, unsigned quotaInBytes);
  • trunk/Source/WebKit2/UIProcess/Storage/StorageManager.messages.in

    r148245 r148250  
    2929    SetItem(uint64_t storageMapID, uint64_t sourceStorageAreaID, WTF::String key, WTF::String value, WTF::String urlString) WantsConnection
    3030    RemoveItem(uint64_t storageMapID, uint64_t sourceStorageAreaID, WTF::String key, WTF::String urlString) WantsConnection
     31    Clear(uint64_t storageMapID, uint64_t sourceStorageAreaID, WTF::String urlString) WantsConnection
    3132}
  • trunk/Source/WebKit2/WebProcess/Storage/StorageAreaImpl.cpp

    r148245 r148250  
    142142}
    143143
    144 void StorageAreaImpl::clear(ExceptionCode&, Frame* sourceFrame)
     144void StorageAreaImpl::clear(ExceptionCode& ec, Frame* sourceFrame)
     145{
     146    ec = 0;
     147    if (!canAccessStorage(sourceFrame)) {
     148        ec = SECURITY_ERR;
     149        return;
     150    }
     151
     152    if (disabledByPrivateBrowsingInFrame(sourceFrame))
     153        return;
     154
     155    m_storageAreaMap->clear(sourceFrame, this);
     156}
     157
     158bool StorageAreaImpl::contains(const String& key, ExceptionCode& ec, Frame* sourceFrame)
     159{
     160    ec = 0;
     161    if (!canAccessStorage(sourceFrame)) {
     162        ec = SECURITY_ERR;
     163        return false;
     164    }
     165    if (disabledByPrivateBrowsingInFrame(sourceFrame))
     166        return false;
     167
     168    return m_storageAreaMap->contains(key);
     169}
     170
     171bool StorageAreaImpl::canAccessStorage(Frame* frame)
     172{
     173    return frame && frame->page();
     174}
     175
     176size_t StorageAreaImpl::memoryBytesUsedByCache()
     177{
     178    return 0;
     179}
     180
     181void StorageAreaImpl::incrementAccessCount()
     182{
     183    // Storage access is handled in the UI process, so there's nothing to do here.
     184}
     185
     186void StorageAreaImpl::decrementAccessCount()
     187{
     188    // Storage access is handled in the UI process, so there's nothing to do here.
     189}
     190
     191void StorageAreaImpl::closeDatabaseIfIdle()
    145192{
    146193    // FIXME: Implement this.
    147194    ASSERT_NOT_REACHED();
    148     UNUSED_PARAM(sourceFrame);
    149 }
    150 
    151 bool StorageAreaImpl::contains(const String& key, ExceptionCode& ec, Frame* sourceFrame)
    152 {
    153     ec = 0;
    154     if (!canAccessStorage(sourceFrame)) {
    155         ec = SECURITY_ERR;
    156         return false;
    157     }
    158     if (disabledByPrivateBrowsingInFrame(sourceFrame))
    159         return false;
    160 
    161     return m_storageAreaMap->contains(key);
    162 }
    163 
    164 bool StorageAreaImpl::canAccessStorage(Frame* frame)
    165 {
    166     return frame && frame->page();
    167 }
    168 
    169 size_t StorageAreaImpl::memoryBytesUsedByCache()
    170 {
    171     return 0;
    172 }
    173 
    174 void StorageAreaImpl::incrementAccessCount()
    175 {
    176     // Storage access is handled in the UI process, so there's nothing to do here.
    177 }
    178 
    179 void StorageAreaImpl::decrementAccessCount()
    180 {
    181     // Storage access is handled in the UI process, so there's nothing to do here.
    182 }
    183 
    184 void StorageAreaImpl::closeDatabaseIfIdle()
    185 {
    186     // FIXME: Implement this.
    187     ASSERT_NOT_REACHED();
    188195}
    189196
  • trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp

    r148245 r148250  
    137137}
    138138
     139void StorageAreaMap::clear(WebCore::Frame* sourceFrame, StorageAreaImpl* sourceArea)
     140{
     141    resetValues();
     142
     143    m_storageMap = StorageMap::create(m_quotaInBytes);
     144    WebProcess::shared().connection()->send(Messages::StorageManager::Clear(m_storageMapID, sourceArea->storageAreaID(), sourceFrame->document()->url()), 0);
     145}
     146
    139147bool StorageAreaMap::contains(const String& key)
    140148{
     
    142150
    143151    return m_storageMap->contains(key);
     152}
     153
     154void StorageAreaMap::resetValues()
     155{
     156    m_storageMap = nullptr;
    144157}
    145158
     
    169182}
    170183
     184void StorageAreaMap::didClear()
     185{
     186    // FIXME: Implement.
     187}
     188
    171189void StorageAreaMap::dispatchStorageEvent(uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString)
    172190{
  • trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.h

    r148245 r148250  
    5757    void setItem(WebCore::Frame* sourceFrame, StorageAreaImpl* sourceArea, const String& key, const String& value, bool& quotaException);
    5858    void removeItem(WebCore::Frame* sourceFrame, StorageAreaImpl* sourceArea, const String& key);
     59    void clear(WebCore::Frame* sourceFrame, StorageAreaImpl* sourceArea);
    5960    bool contains(const String& key);
    6061
     
    6768    void didSetItem(const String& key, bool quotaError);
    6869    void didRemoveItem(const String& key);
     70    void didClear();
    6971
    7072    void dispatchStorageEvent(uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString);
    7173
     74    void resetValues();
    7275    void loadValuesIfNeeded();
    7376
  • trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.messages.in

    r148245 r148250  
    2424    DidSetItem(WTF::String key, bool quotaException)
    2525    DidRemoveItem(WTF::String key)
     26    DidClear()
    2627
    2728    DispatchStorageEvent(uint64_t sourceStorageAreaID, WTF::String key, WTF::String oldValue, WTF::String newValue, WTF::String urlString)
Note: See TracChangeset for help on using the changeset viewer.