Changeset 147354 in webkit


Ignore:
Timestamp:
Apr 1, 2013 1:05:25 PM (11 years ago)
Author:
andersca@apple.com
Message:

Apply changes from storage events locally
https://bugs.webkit.org/show_bug.cgi?id=111502

Reviewed by Sam Weinig.

Source/WebCore:

Add and export a helper function for setting an item without taking
into account the quota for the map. Also, reindent StorageMap.h

  • WebCore.exp.in:
  • storage/StorageMap.cpp:

(WebCore::StorageMap::setItemIgnoringQuota):
(WebCore):

  • storage/StorageMap.h:

(StorageMap):
(WebCore::StorageMap::quota):

Source/WebKit2:

  • WebProcess/Storage/StorageAreaProxy.cpp:

(WebKit::StorageAreaProxy::StorageAreaProxy):
Store the security origin as a member variable.

(WebKit::StorageAreaProxy::dispatchStorageEvent):
Set the item and call the appropriate event dispatch function.

(WebKit::StorageAreaProxy::dispatchSessionStorageEvent):
(WebKit::StorageAreaProxy::dispatchLocalStorageEvent):
Add stubs.

  • WebProcess/Storage/StorageAreaProxy.h:
Location:
trunk/Source
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r147353 r147354  
     12013-03-05  Anders Carlsson  <andersca@apple.com>
     2
     3        Apply changes from storage events locally
     4        https://bugs.webkit.org/show_bug.cgi?id=111502
     5
     6        Reviewed by Sam Weinig.
     7
     8        Add and export a helper function for setting an item without taking
     9        into account the quota for the map. Also, reindent StorageMap.h
     10
     11        * WebCore.exp.in:
     12        * storage/StorageMap.cpp:
     13        (WebCore::StorageMap::setItemIgnoringQuota):
     14        (WebCore):
     15        * storage/StorageMap.h:
     16        (StorageMap):
     17        (WebCore::StorageMap::quota):
     18
    1192013-04-01  Benjamin Poulain  <benjamin@webkit.org>
    220
  • trunk/Source/WebCore/WebCore.exp.in

    r147039 r147354  
    8686__ZN7WebCore10ScrollView8addChildEN3WTF10PassRefPtrINS_6WidgetEEE
    8787__ZN7WebCore10StorageMap11importItemsERKN3WTF7HashMapINS1_6StringES3_NS1_10StringHashENS1_10HashTraitsIS3_EES6_EE
     88__ZN7WebCore10StorageMap20setItemIgnoringQuotaERKN3WTF6StringES4_
    8889__ZN7WebCore10StorageMap3keyEj
    8990__ZN7WebCore10StorageMap6createEj
  • trunk/Source/WebCore/storage/StorageMap.cpp

    r144103 r147354  
    2727#include "StorageMap.h"
    2828
     29#include <wtf/TemporaryChange.h>
     30
    2931namespace WebCore {
    3032
     
    141143}
    142144
     145PassRefPtr<StorageMap> StorageMap::setItemIgnoringQuota(const String& key, const String& value)
     146{
     147    TemporaryChange<unsigned> quotaSizeChange(m_quotaSize, noQuota);
     148
     149    String oldValue;
     150    bool quotaException;
     151
     152    RefPtr<StorageMap> map = setItem(key, value, oldValue, quotaException);
     153    ASSERT(!quotaException);
     154
     155    return map.release();
     156}
     157
    143158PassRefPtr<StorageMap> StorageMap::removeItem(const String& key, String& oldValue)
    144159{
  • trunk/Source/WebCore/storage/StorageMap.h

    r144103 r147354  
    3535namespace WebCore {
    3636
    37     class StorageMap : public RefCounted<StorageMap> {
    38     public:
    39         // Quota size measured in bytes.
    40         static PassRefPtr<StorageMap> create(unsigned quotaSize);
     37class StorageMap : public RefCounted<StorageMap> {
     38public:
     39    // Quota size measured in bytes.
     40    static PassRefPtr<StorageMap> create(unsigned quotaSize);
    4141
    42         unsigned length() const;
    43         String key(unsigned index);
    44         String getItem(const String&) const;
    45         PassRefPtr<StorageMap> setItem(const String& key, const String& value, String& oldValue, bool& quota_exception);
    46         PassRefPtr<StorageMap> removeItem(const String&, String& oldValue);
     42    unsigned length() const;
     43    String key(unsigned index);
     44    String getItem(const String&) const;
     45    PassRefPtr<StorageMap> setItem(const String& key, const String& value, String& oldValue, bool& quotaException);
     46    PassRefPtr<StorageMap> setItemIgnoringQuota(const String& key, const String& value);
     47    PassRefPtr<StorageMap> removeItem(const String&, String& oldValue);
    4748
    48         bool contains(const String& key) const;
     49    bool contains(const String& key) const;
    4950
    50         void importItems(const HashMap<String, String>&);
     51    void importItems(const HashMap<String, String>&);
    5152
    52         unsigned quota() const { return m_quotaSize; }
     53    unsigned quota() const { return m_quotaSize; }
    5354
    54         static const unsigned noQuota = UINT_MAX;
     55    static const unsigned noQuota = UINT_MAX;
    5556
    56     private:
    57         explicit StorageMap(unsigned quota);
    58         PassRefPtr<StorageMap> copy();
    59         void invalidateIterator();
    60         void setIteratorToIndex(unsigned);
     57private:
     58    explicit StorageMap(unsigned quota);
     59    PassRefPtr<StorageMap> copy();
     60    void invalidateIterator();
     61    void setIteratorToIndex(unsigned);
    6162
    62         HashMap<String, String> m_map;
    63         HashMap<String, String>::iterator m_iterator;
    64         unsigned m_iteratorIndex;
     63    HashMap<String, String> m_map;
     64    HashMap<String, String>::iterator m_iterator;
     65    unsigned m_iteratorIndex;
    6566
    66         unsigned m_quotaSize; // Measured in bytes.
    67         unsigned m_currentLength; // Measured in UChars.
    68     };
     67    unsigned m_quotaSize; // Measured in bytes.
     68    unsigned m_currentLength; // Measured in UChars.
     69};
    6970
    7071} // namespace WebCore
  • trunk/Source/WebKit2/ChangeLog

    r147344 r147354  
     12013-03-05  Anders Carlsson  <andersca@apple.com>
     2
     3        Apply changes from storage events locally
     4        https://bugs.webkit.org/show_bug.cgi?id=111502
     5
     6        Reviewed by Sam Weinig.
     7
     8        * WebProcess/Storage/StorageAreaProxy.cpp:
     9        (WebKit::StorageAreaProxy::StorageAreaProxy):
     10        Store the security origin as a member variable.
     11
     12        (WebKit::StorageAreaProxy::dispatchStorageEvent):
     13        Set the item and call the appropriate event dispatch function.
     14   
     15        (WebKit::StorageAreaProxy::dispatchSessionStorageEvent):
     16        (WebKit::StorageAreaProxy::dispatchLocalStorageEvent):
     17        Add stubs.
     18
     19        * WebProcess/Storage/StorageAreaProxy.h:
     20
    1212013-04-01  Alexey Proskuryakov  <ap@apple.com>
    222
  • trunk/Source/WebKit2/WebProcess/Storage/StorageAreaProxy.cpp

    r144851 r147354  
    5858    , m_quotaInBytes(storageNamespaceProxy->quotaInBytes())
    5959    , m_storageAreaID(generateStorageAreaID())
    60 {
    61     WebProcess::shared().connection()->send(Messages::StorageManager::CreateStorageArea(m_storageAreaID, storageNamespaceProxy->storageNamespaceID(), SecurityOriginData::fromSecurityOrigin(securityOrigin.get())), 0);
     60    , m_securityOrigin(securityOrigin)
     61{
     62    WebProcess::shared().connection()->send(Messages::StorageManager::CreateStorageArea(m_storageAreaID, storageNamespaceProxy->storageNamespaceID(), SecurityOriginData::fromSecurityOrigin(m_securityOrigin.get())), 0);
    6263    WebProcess::shared().addMessageReceiver(Messages::StorageAreaProxy::messageReceiverName(), m_storageAreaID, this);
    6364}
     
    217218        return;
    218219
    219     // FIXME: Implement this.
     220    ASSERT(!key.isNull());
     221    ASSERT(!newValue.isNull());
     222
     223    ASSERT(m_storageMap->hasOneRef());
     224    m_storageMap->setItemIgnoringQuota(key, newValue);
     225
     226    if (storageType() == SessionStorage)
     227        dispatchSessionStorageEvent(key, oldValue, newValue, urlString);
     228    else
     229        dispatchLocalStorageEvent(key, oldValue, newValue, urlString);
    220230}
    221231
     
    275285}
    276286
     287void StorageAreaProxy::dispatchSessionStorageEvent(const String& key, const String& oldValue, const String& newValue, const String& urlString)
     288{
     289    ASSERT(storageType() == SessionStorage);
     290
     291    // FIXME: Implement.
     292}
     293
     294void StorageAreaProxy::dispatchLocalStorageEvent(const String& key, const String& oldValue, const String& newValue, const String& urlString)
     295{
     296    ASSERT(storageType() == LocalStorage);
     297
     298    // FIXME: Implement.
     299}
     300
    277301} // namespace WebKit
  • trunk/Source/WebKit2/WebProcess/Storage/StorageAreaProxy.h

    r144851 r147354  
    7575    void resetValues();
    7676
     77    void dispatchSessionStorageEvent(const String& key, const String& oldValue, const String& newValue, const String& urlString);
     78    void dispatchLocalStorageEvent(const String& key, const String& oldValue, const String& newValue, const String& urlString);
     79
    7780    uint64_t m_storageNamespaceID;
    7881    unsigned m_quotaInBytes;
    7982    uint64_t m_storageAreaID;
     83
     84    RefPtr<WebCore::SecurityOrigin> m_securityOrigin;
    8085    RefPtr<WebCore::StorageMap> m_storageMap;
    8186
  • trunk/Source/WebKit2/WebProcess/Storage/StorageNamespaceProxy.cpp

    r144829 r147354  
    5353PassRefPtr<StorageArea> StorageNamespaceProxy::storageArea(PassRefPtr<SecurityOrigin> securityOrigin)
    5454{
    55     return StorageAreaProxy::create(this, securityOrigin);
     55    printf("%p - looking for storage area in %s\n", this, securityOrigin->toString().utf8().data());
     56    HashMap<RefPtr<WebCore::SecurityOrigin>, RefPtr<StorageAreaProxy> >::AddResult result = m_storageAreaMap.add(securityOrigin.get(), 0);
     57    if (result.isNewEntry) {
     58        result.iterator->value = StorageAreaProxy::create(this, securityOrigin);
     59        printf("new entry!!\n");
     60    } else {
     61        printf("reusing!!\n");
     62    }
     63
     64    printf("returning %p\n", result.iterator->value.get());
     65    return result.iterator->value;
    5666}
    5767
  • trunk/Source/WebKit2/WebProcess/Storage/StorageNamespaceProxy.h

    r144829 r147354  
    2727#define StorageNamespaceProxy_h
    2828
     29#include <WebCore/SecurityOriginHash.h>
    2930#include <WebCore/StorageArea.h>
    3031#include <WebCore/StorageNamespace.h>
     32#include <wtf/HashMap.h>
    3133
    3234namespace WebKit {
    3335
     36class StorageAreaProxy;
    3437class WebPage;
    3538
     
    5558    uint64_t m_storageNamespaceID;
    5659    unsigned m_quotaInBytes;
     60
     61    HashMap<RefPtr<WebCore::SecurityOrigin>, RefPtr<StorageAreaProxy> > m_storageAreaMap;
    5762};
    5863
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp

    r144499 r147354  
    6161
    6262// FIXME: Remove this once it works well enough to be the default.
    63 #define ENABLE_UI_PROCESS_STORAGE 0
     63#define ENABLE_UI_PROCESS_STORAGE 1
    6464
    6565using namespace WebCore;
Note: See TracChangeset for help on using the changeset viewer.