Changeset 144675 in webkit


Ignore:
Timestamp:
Mar 4, 2013 2:25:57 PM (11 years ago)
Author:
andersca@apple.com
Message:

Create and destroy storage areas in the UI process
https://bugs.webkit.org/show_bug.cgi?id=111361

Reviewed by Sam Weinig.

  • UIProcess/Storage/StorageManager.cpp:

(StorageManager::StorageArea):
Keep track of listener connection and storage area ID pairs.

(WebKit::StorageManager::StorageArea::~StorageArea):
Assert that we don't have any listeners left.

(WebKit::StorageManager::StorageArea::addListener):
Add the pair to the set of listeners.

(WebKit::StorageManager::StorageArea::removeListener):
Remove the pair from the set of listeners.

(WebKit::StorageManager::SessionStorageNamespace::getOrCreateStorageArea):
Given an origin, look up or create the storage area.

(WebKit::StorageManager::createStorageArea):
Create the storage area if it doesn't already exist.

(WebKit::StorageManager::destroyStorageArea):
Look up the storage area and destroy it.

  • UIProcess/Storage/StorageManager.h:

Add a map of open storage areas.

Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r144672 r144675  
     12013-03-04  Anders Carlsson  <andersca@apple.com>
     2
     3        Create and destroy storage areas in the UI process
     4        https://bugs.webkit.org/show_bug.cgi?id=111361
     5
     6        Reviewed by Sam Weinig.
     7
     8        * UIProcess/Storage/StorageManager.cpp:
     9        (StorageManager::StorageArea):
     10        Keep track of listener connection and storage area ID pairs.
     11       
     12        (WebKit::StorageManager::StorageArea::~StorageArea):
     13        Assert that we don't have any listeners left.
     14
     15        (WebKit::StorageManager::StorageArea::addListener):
     16        Add the pair to the set of listeners.
     17       
     18        (WebKit::StorageManager::StorageArea::removeListener):
     19        Remove the pair from the set of listeners.
     20       
     21        (WebKit::StorageManager::SessionStorageNamespace::getOrCreateStorageArea):
     22        Given an origin, look up or create the storage area.
     23
     24        (WebKit::StorageManager::createStorageArea):
     25        Create the storage area if it doesn't already exist.
     26
     27        (WebKit::StorageManager::destroyStorageArea):
     28        Look up the storage area and destroy it.
     29
     30        * UIProcess/Storage/StorageManager.h:
     31        Add a map of open storage areas.
     32
    1332013-03-04  Jer Noble  <jer.noble@apple.com>
    234
  • trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp

    r144390 r144675  
    4343    ~StorageArea();
    4444
     45    void addListener(CoreIPC::Connection*, uint64_t storageAreaID);
     46    void removeListener(CoreIPC::Connection*, uint64_t storageAreaID);
     47
    4548private:
    4649    StorageArea();
     50
     51    HashSet<std::pair<RefPtr<CoreIPC::Connection>, uint64_t>> m_eventListeners;
    4752};
    4853
     
    5863StorageManager::StorageArea::~StorageArea()
    5964{
     65    ASSERT(m_eventListeners.isEmpty());
     66}
     67
     68void StorageManager::StorageArea::addListener(CoreIPC::Connection* connection, uint64_t storageAreaID)
     69{
     70    ASSERT(!m_eventListeners.contains(std::make_pair(connection, storageAreaID)));
     71    m_eventListeners.add(std::make_pair(connection, storageAreaID));
     72}
     73
     74void StorageManager::StorageArea::removeListener(CoreIPC::Connection* connection, uint64_t storageAreaID)
     75{
     76    ASSERT(m_eventListeners.contains(std::make_pair(connection, storageAreaID)));
     77    m_eventListeners.remove(std::make_pair(connection, storageAreaID));
    6078}
    6179
     
    7088    void setAllowedConnection(CoreIPC::Connection*);
    7189
     90    PassRefPtr<StorageArea> getOrCreateStorageArea(PassRefPtr<SecurityOrigin>);
     91
    7292    void cloneTo(SessionStorageNamespace& newSessionStorageNamespace);
    7393
     
    100120}
    101121
     122PassRefPtr<StorageManager::StorageArea> StorageManager::SessionStorageNamespace::getOrCreateStorageArea(PassRefPtr<SecurityOrigin> securityOrigin)
     123{
     124    HashMap<RefPtr<SecurityOrigin>, RefPtr<StorageArea> >::AddResult result = m_storageAreaMap.add(securityOrigin, 0);
     125    if (result.isNewEntry)
     126        result.iterator->value = StorageArea::create();
     127
     128    return result.iterator->value;
     129}
     130
    102131void StorageManager::SessionStorageNamespace::cloneTo(SessionStorageNamespace& newSessionStorageNamespace)
    103132{
     
    153182void StorageManager::createStorageArea(CoreIPC::Connection* connection, uint64_t storageAreaID, uint64_t storageNamespaceID, const SecurityOriginData& securityOriginData)
    154183{
    155     UNUSED_PARAM(storageAreaID);
    156     UNUSED_PARAM(storageNamespaceID);
     184    std::pair<RefPtr<CoreIPC::Connection>, uint64_t> connectionAndStorageAreaIDPair(connection, storageAreaID);
     185
     186    // FIXME: This should be a message check.
     187    ASSERT((HashMap<std::pair<RefPtr<CoreIPC::Connection>, uint64_t>, RefPtr<StorageArea> >::isValidKey(connectionAndStorageAreaIDPair)));
     188
     189    HashMap<std::pair<RefPtr<CoreIPC::Connection>, uint64_t>, RefPtr<StorageArea> >::AddResult result = m_storageAreas.add(connectionAndStorageAreaIDPair, 0);
     190
     191    // FIXME: This should be a message check.
     192    ASSERT(result.isNewEntry);
    157193
    158194    if (!storageNamespaceID) {
     
    160196        ASSERT_NOT_REACHED();
    161197    }
    162 }
    163 
    164 void StorageManager::destroyStorageArea(CoreIPC::Connection*, uint64_t)
    165 {
     198
     199    ASSERT((HashMap<uint64_t, RefPtr<SessionStorageNamespace> >::isValidKey(storageNamespaceID)));
     200    SessionStorageNamespace* sessionStorageNamespace = m_sessionStorageNamespaces.get(storageNamespaceID).get();
     201
     202    // FIXME: These should be message checks.
     203    ASSERT(sessionStorageNamespace);
     204    ASSERT(connection == sessionStorageNamespace->allowedConnection());
     205
     206    RefPtr<StorageArea> storageArea = sessionStorageNamespace->getOrCreateStorageArea(securityOriginData.securityOrigin());
     207    storageArea->addListener(connection, storageAreaID);
     208
     209    result.iterator->value = storageArea.release();
     210}
     211
     212void StorageManager::destroyStorageArea(CoreIPC::Connection* connection, uint64_t storageAreaID)
     213{
     214    std::pair<RefPtr<CoreIPC::Connection>, uint64_t> connectionAndStorageAreaIDPair(connection, storageAreaID);
     215
     216    // FIXME: This should be a message check.
     217    ASSERT((HashMap<std::pair<RefPtr<CoreIPC::Connection>, uint64_t>, RefPtr<StorageArea> >::isValidKey(connectionAndStorageAreaIDPair)));
     218
     219    HashMap<std::pair<RefPtr<CoreIPC::Connection>, uint64_t>, RefPtr<StorageArea> >::iterator it = m_storageAreas.find(connectionAndStorageAreaIDPair);
     220
     221    // FIXME: This should be a message check.
     222    ASSERT(it != m_storageAreas.end());
     223
     224    it->value->removeListener(connection, storageAreaID);
     225
     226    m_storageAreas.remove(connectionAndStorageAreaIDPair);
    166227}
    167228
  • trunk/Source/WebKit2/UIProcess/Storage/StorageManager.h

    r144386 r144675  
    7676
    7777    class StorageArea;
     78    HashMap<std::pair<RefPtr<CoreIPC::Connection>, uint64_t>, RefPtr<StorageArea> > m_storageAreas;
    7879};
    7980
Note: See TracChangeset for help on using the changeset viewer.