Implement StorageAreaProxy::getItem and StorageAreaProxy::setItem
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Feb 2013 01:20:27 +0000 (01:20 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Feb 2013 01:20:27 +0000 (01:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=110927

Reviewed by Sam Weinig.

Source/WebCore:

Export StorageMap::getItem and StorageMap::setItem.

* WebCore.exp.in:

Source/WebKit2:

* UIProcess/Storage/StorageManager.cpp:
(WebKit::StorageManager::setItem):
* UIProcess/Storage/StorageManager.h:
Add empty stub.

* UIProcess/Storage/StorageManager.messages.in:
Add SetItem message.

* WebProcess/Storage/StorageAreaProxy.cpp:
(WebKit::StorageAreaProxy::getItem):
Fill the storage map and get the item from it.

(WebKit::StorageAreaProxy::setItem):
Update the storage map and send a SetItem message to the UI process.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@144130 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/Storage/StorageManager.cpp
Source/WebKit2/UIProcess/Storage/StorageManager.h
Source/WebKit2/UIProcess/Storage/StorageManager.messages.in
Source/WebKit2/WebProcess/Storage/StorageAreaProxy.cpp

index cdf24d5..4ccffff 100644 (file)
@@ -1,3 +1,14 @@
+2013-02-26  Anders Carlsson  <andersca@apple.com>
+
+        Implement StorageAreaProxy::getItem and StorageAreaProxy::setItem
+        https://bugs.webkit.org/show_bug.cgi?id=110927
+
+        Reviewed by Sam Weinig.
+
+        Export StorageMap::getItem and StorageMap::setItem.
+
+        * WebCore.exp.in:
+
 2013-02-26  Adam Klein  <adamk@chromium.org>
 
         Parsing of HTML tags in MathML Text Insertion Points leads to bogus parser behavior
index cc97301..b57b87c 100644 (file)
@@ -84,6 +84,7 @@ __ZN7WebCore10ScrollView24windowResizerRectChangedEv
 __ZN7WebCore10ScrollView8addChildEN3WTF10PassRefPtrINS_6WidgetEEE
 __ZN7WebCore10StorageMap11importItemsERKN3WTF7HashMapINS1_6StringES3_NS1_10StringHashENS1_10HashTraitsIS3_EES6_EE
 __ZN7WebCore10StorageMap6createEj
+__ZN7WebCore10StorageMap7setItemERKN3WTF6StringES4_RS2_Rb
 __ZN7WebCore10deleteFileERKN3WTF6StringE
 __ZN7WebCore10setCookiesEPNS_8DocumentERKNS_4KURLERKN3WTF6StringE
 __ZN7WebCore10toDocumentEN3JSC7JSValueE
@@ -1186,6 +1187,7 @@ __ZNK7WebCore10ScrollView16windowToContentsERKNS_8IntPointE
 __ZNK7WebCore10ScrollView18contentsToRootViewERKNS_7IntRectE
 __ZNK7WebCore10ScrollView18contentsToRootViewERKNS_8IntPointE
 __ZNK7WebCore10StorageMap6lengthEv
+__ZNK7WebCore10StorageMap7getItemERKN3WTF6StringE
 __ZNK7WebCore11FrameLoader10isCompleteEv
 __ZNK7WebCore11FrameLoader14cancelledErrorERKNS_15ResourceRequestE
 __ZNK7WebCore11FrameLoader14frameHasLoadedEv
index f909cca..ff4c42b 100644 (file)
@@ -1,5 +1,27 @@
 2013-02-26  Anders Carlsson  <andersca@apple.com>
 
+        Implement StorageAreaProxy::getItem and StorageAreaProxy::setItem
+        https://bugs.webkit.org/show_bug.cgi?id=110927
+
+        Reviewed by Sam Weinig.
+
+        * UIProcess/Storage/StorageManager.cpp:
+        (WebKit::StorageManager::setItem):
+        * UIProcess/Storage/StorageManager.h:
+        Add empty stub.
+        
+        * UIProcess/Storage/StorageManager.messages.in:
+        Add SetItem message.
+
+        * WebProcess/Storage/StorageAreaProxy.cpp:
+        (WebKit::StorageAreaProxy::getItem):
+        Fill the storage map and get the item from it.
+
+        (WebKit::StorageAreaProxy::setItem):
+        Update the storage map and send a SetItem message to the UI process.
+
+2013-02-26  Anders Carlsson  <andersca@apple.com>
+
         StorageAreaProxy should hold on to a StorageMap and not a HashMap
         https://bugs.webkit.org/show_bug.cgi?id=110919
 
index 42e13b9..f952904 100644 (file)
@@ -146,6 +146,11 @@ void StorageManager::getValues(CoreIPC::Connection*, uint64_t, HashMap<String, S
     // FIXME: Implement this.
 }
 
+void StorageManager::setItem(CoreIPC::Connection*, uint64_t storageAreaID, const String& key, const String& value)
+{
+    // FIXME: Find the right storage area and set the item.
+}
+
 void StorageManager::createSessionStorageNamespaceInternal(uint64_t storageNamespaceID)
 {
     ASSERT(!m_sessionStorageNamespaces.contains(storageNamespaceID));
index 540ee83..c6e52ee 100644 (file)
@@ -61,6 +61,7 @@ private:
     void createStorageArea(CoreIPC::Connection*, uint64_t storageAreaID, uint64_t storageNamespaceID, const SecurityOriginData&);
     void destroyStorageArea(CoreIPC::Connection*, uint64_t storageAreaID);
     void getValues(CoreIPC::Connection*, uint64_t storageAreaID, HashMap<String, String>& values);
+    void setItem(CoreIPC::Connection*, uint64_t storageAreaID, const String& key, const String& value);
 
     void createSessionStorageNamespaceInternal(uint64_t storageNamespaceID);
     void destroySessionStorageNamespaceInternal(uint64_t storageNamespaceID);
index 4e6ea1c..4a3b929 100644 (file)
@@ -25,4 +25,6 @@ messages -> StorageManager {
     DestroyStorageArea(uint64_t storageAreaID) WantsConnection
 
     GetValues(uint64_t storageAreaID) -> (WTF::HashMap<WTF::String, WTF::String> values) WantsConnection
+
+    SetItem(uint64_t storageAreaID, WTF::String key, WTF::String value) WantsConnection
 }
index bad56a6..679ddde 100644 (file)
@@ -87,11 +87,18 @@ String StorageAreaProxy::key(unsigned index, ExceptionCode&, Frame* sourceFrame)
     return String();
 }
 
-String StorageAreaProxy::getItem(const String& key, ExceptionCode&, Frame* sourceFrame)
+String StorageAreaProxy::getItem(const String& key, ExceptionCode& ec, Frame* sourceFrame)
 {
-    // FIXME: Implement this.
-    ASSERT_NOT_REACHED();
-    return String();
+    ec = 0;
+    if (!canAccessStorage(sourceFrame)) {
+        ec = SECURITY_ERR;
+        return String();
+    }
+    if (disabledByPrivateBrowsingInFrame(sourceFrame))
+        return String();
+
+    loadValuesIfNeeded();
+    return m_storageMap->getItem(key);
 }
 
 void StorageAreaProxy::setItem(const String& key, const String& value, ExceptionCode& ec, Frame* sourceFrame)
@@ -111,8 +118,20 @@ void StorageAreaProxy::setItem(const String& key, const String& value, Exception
 
     loadValuesIfNeeded();
 
-    // FIXME: Actually set the value.
-    ASSERT_NOT_REACHED();
+    ASSERT(m_storageMap->hasOneRef());
+    String oldValue;
+    bool quotaException;
+    m_storageMap->setItem(key, value, oldValue, quotaException);
+
+    if (quotaException) {
+        ec = QUOTA_EXCEEDED_ERR;
+        return;
+    }
+
+    if (oldValue == value)
+        return;
+
+    WebProcess::shared().connection()->send(Messages::StorageManager::SetItem(m_storageAreaID, key, value), 0);
 }
 
 void StorageAreaProxy::removeItem(const String& key, ExceptionCode&, Frame* sourceFrame)