Title: [177365] trunk/Source/WebCore
Revision
177365
Author
[email protected]
Date
2014-12-16 10:39:14 -0800 (Tue, 16 Dec 2014)

Log Message

Put some common code in StorageNamespaceProvider
https://bugs.webkit.org/show_bug.cgi?id=139682

Reviewed by Tim Horton.

We have code in two places that gets the local storage area from a given document,
choosing either the local storage namespace or the transient local storage namespace.
Move it to StorageNamespaceProvider::localStorageArea.

* bindings/js/ScriptController.cpp:
* inspector/InspectorDOMStorageAgent.cpp:
(WebCore::InspectorDOMStorageAgent::findStorageArea):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::localStorage):
* page/Navigator.cpp:
* storage/StorageNamespaceProvider.cpp:
(WebCore::StorageNamespaceProvider::localStorageArea):
(WebCore::StorageNamespaceProvider::localStorageNamespace):
* storage/StorageNamespaceProvider.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (177364 => 177365)


--- trunk/Source/WebCore/ChangeLog	2014-12-16 18:36:01 UTC (rev 177364)
+++ trunk/Source/WebCore/ChangeLog	2014-12-16 18:39:14 UTC (rev 177365)
@@ -1,5 +1,27 @@
 2014-12-16  Anders Carlsson  <[email protected]>
 
+        Put some common code in StorageNamespaceProvider
+        https://bugs.webkit.org/show_bug.cgi?id=139682
+
+        Reviewed by Tim Horton.
+
+        We have code in two places that gets the local storage area from a given document,
+        choosing either the local storage namespace or the transient local storage namespace.
+        Move it to StorageNamespaceProvider::localStorageArea.
+
+        * bindings/js/ScriptController.cpp:
+        * inspector/InspectorDOMStorageAgent.cpp:
+        (WebCore::InspectorDOMStorageAgent::findStorageArea):
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::localStorage):
+        * page/Navigator.cpp:
+        * storage/StorageNamespaceProvider.cpp:
+        (WebCore::StorageNamespaceProvider::localStorageArea):
+        (WebCore::StorageNamespaceProvider::localStorageNamespace):
+        * storage/StorageNamespaceProvider.h:
+
+2014-12-16  Anders Carlsson  <[email protected]>
+
         Add FeatureCounterKeys.h to the Xcode project.
 
         * WebCore.xcodeproj/project.pbxproj:

Modified: trunk/Source/WebCore/bindings/js/ScriptController.cpp (177364 => 177365)


--- trunk/Source/WebCore/bindings/js/ScriptController.cpp	2014-12-16 18:36:01 UTC (rev 177364)
+++ trunk/Source/WebCore/bindings/js/ScriptController.cpp	2014-12-16 18:39:14 UTC (rev 177365)
@@ -43,7 +43,6 @@
 #include "ScriptSourceCode.h"
 #include "ScriptableDocumentParser.h"
 #include "Settings.h"
-#include "StorageNamespace.h"
 #include "UserGestureIndicator.h"
 #include "WebCoreJSClientData.h"
 #include "npruntime_impl.h"

Modified: trunk/Source/WebCore/inspector/InspectorDOMStorageAgent.cpp (177364 => 177365)


--- trunk/Source/WebCore/inspector/InspectorDOMStorageAgent.cpp	2014-12-16 18:36:01 UTC (rev 177364)
+++ trunk/Source/WebCore/inspector/InspectorDOMStorageAgent.cpp	2014-12-16 18:39:14 UTC (rev 177365)
@@ -45,7 +45,6 @@
 #include "PageGroup.h"
 #include "SecurityOrigin.h"
 #include "Storage.h"
-#include "StorageNamespace.h"
 #include "StorageNamespaceProvider.h"
 #include "VoidCallback.h"
 #include <inspector/InspectorFrontendDispatchers.h>
@@ -201,14 +200,7 @@
         return nullptr;
     }
 
-    Page* page = m_pageAgent->page();
-    Document* document = targetFrame->document();
-    if (isLocalStorage) {
-        if (document->securityOrigin()->canAccessLocalStorage(document->topOrigin()))
-            return page->storageNamespaceProvider().localStorageNamespace().storageArea(document->securityOrigin());
-        return page->storageNamespaceProvider().transientLocalStorageNamespace(*document->topOrigin()).storageArea(document->securityOrigin());
-    }
-    return page->sessionStorage()->storageArea(document->securityOrigin());
+    return m_pageAgent->page()->storageNamespaceProvider().localStorageArea(*targetFrame->document());
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/DOMWindow.cpp (177364 => 177365)


--- trunk/Source/WebCore/page/DOMWindow.cpp	2014-12-16 18:36:01 UTC (rev 177364)
+++ trunk/Source/WebCore/page/DOMWindow.cpp	2014-12-16 18:39:14 UTC (rev 177365)
@@ -856,13 +856,8 @@
     if (!page->settings().localStorageEnabled())
         return nullptr;
 
-    RefPtr<StorageArea> storageArea;
+    RefPtr<StorageArea> storageArea = page->storageNamespaceProvider().localStorageArea(*document);
 
-    if (document->securityOrigin()->canAccessLocalStorage(document->topOrigin()))
-        storageArea = page->storageNamespaceProvider().localStorageNamespace().storageArea(document->securityOrigin());
-    else
-        storageArea = page->storageNamespaceProvider().transientLocalStorageNamespace(*document->topOrigin()).storageArea(document->securityOrigin());
-
     if (!storageArea->canAccessStorage(m_frame)) {
         ec = SECURITY_ERR;
         return nullptr;

Modified: trunk/Source/WebCore/page/Navigator.cpp (177364 => 177365)


--- trunk/Source/WebCore/page/Navigator.cpp	2014-12-16 18:36:01 UTC (rev 177364)
+++ trunk/Source/WebCore/page/Navigator.cpp	2014-12-16 18:39:14 UTC (rev 177365)
@@ -37,7 +37,6 @@
 #include "ScriptController.h"
 #include "SecurityOrigin.h"
 #include "Settings.h"
-#include "StorageNamespace.h"
 #include <wtf/HashSet.h>
 #include <wtf/NumberOfCores.h>
 #include <wtf/StdLibExtras.h>

Modified: trunk/Source/WebCore/storage/StorageNamespaceProvider.cpp (177364 => 177365)


--- trunk/Source/WebCore/storage/StorageNamespaceProvider.cpp	2014-12-16 18:36:01 UTC (rev 177364)
+++ trunk/Source/WebCore/storage/StorageNamespaceProvider.cpp	2014-12-16 18:39:14 UTC (rev 177365)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "StorageNamespaceProvider.h"
 
+#include "Document.h"
+#include "StorageArea.h"
 #include "StorageNamespace.h"
 
 namespace WebCore {
@@ -56,6 +58,13 @@
     m_pages.remove(&page);
 }
 
+RefPtr<StorageArea> StorageNamespaceProvider::localStorageArea(Document& document)
+{
+    auto& storageNamespace = document.securityOrigin()->canAccessLocalStorage(document.topOrigin()) ? localStorageNamespace() : transientLocalStorageNamespace(*document.topOrigin());
+
+    return storageNamespace.storageArea(document.securityOrigin());
+}
+
 StorageNamespace& StorageNamespaceProvider::localStorageNamespace()
 {
     if (!m_localStorageNamespace)

Modified: trunk/Source/WebCore/storage/StorageNamespaceProvider.h (177364 => 177365)


--- trunk/Source/WebCore/storage/StorageNamespaceProvider.h	2014-12-16 18:36:01 UTC (rev 177364)
+++ trunk/Source/WebCore/storage/StorageNamespaceProvider.h	2014-12-16 18:39:14 UTC (rev 177365)
@@ -34,8 +34,10 @@
 
 namespace WebCore {
 
+class Document;
 class Page;
 class SecurityOrigin;
+class StorageArea;
 class StorageNamespace;
 
 class StorageNamespaceProvider : public RefCounted<StorageNamespaceProvider> {
@@ -44,8 +46,7 @@
     virtual ~StorageNamespaceProvider();
 
     virtual RefPtr<StorageNamespace> createSessionStorageNamespace(Page&, unsigned quota) = 0;
-    StorageNamespace& localStorageNamespace();
-    StorageNamespace& transientLocalStorageNamespace(SecurityOrigin&);
+    RefPtr<StorageArea> localStorageArea(Document&);
 
     void addPage(Page&);
     void removePage(Page&);
@@ -54,6 +55,9 @@
     StorageNamespace* optionalLocalStorageNamespace() { return m_localStorageNamespace.get(); }
 
 private:
+    StorageNamespace& localStorageNamespace();
+    StorageNamespace& transientLocalStorageNamespace(SecurityOrigin&);
+
     virtual RefPtr<StorageNamespace> createLocalStorageNamespace(unsigned quota) = 0;
     virtual RefPtr<StorageNamespace> createTransientLocalStorageNamespace(SecurityOrigin&, unsigned quota) = 0;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to