Title: [149840] trunk/Source/WebCore
Revision
149840
Author
[email protected]
Date
2013-05-09 14:03:56 -0700 (Thu, 09 May 2013)

Log Message

Add a StorageStrategy hook for creating transient local storage namespaces
https://bugs.webkit.org/show_bug.cgi?id=115870

Reviewed by Geoffrey Garen.

* WebCore.exp.in:
Export symbol needed by WebKit2.

* dom/Document.cpp:
(WebCore::Document::topOrigin):
* dom/Document.h:
* dom/ScriptExecutionContext.h:
* workers/WorkerContext.h:
Remove const qualifier from topOrigin() to avoid ugly const_casts when assigning into a RefPtr<SecurityOrigin> variable.

* page/PageGroup.cpp:
(WebCore::PageGroup::transientLocalStorage):
Do a single hash lookup instead of three and use the SecurityOrigin itself as the hash key instead of a string representation of it.

* page/PageGroup.h:
Update HashMap declaration.

* storage/StorageNamespace.cpp:
(WebCore::StorageNamespace::transientLocalStorageNamespace):
Add new implementation that will optionally call out to the storage strategy.

* storage/StorageNamespaceImpl.cpp:
(WebCore::StorageNamespaceImpl::transientLocalStorageNamespace):
Move the default implementation here from PageGroup.

* storage/StorageStrategy.cpp:
(WebCore::StorageStrategy::transientLocalStorageNamespace):
Call the default implementation.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (149839 => 149840)


--- trunk/Source/WebCore/ChangeLog	2013-05-09 20:54:16 UTC (rev 149839)
+++ trunk/Source/WebCore/ChangeLog	2013-05-09 21:03:56 UTC (rev 149840)
@@ -1,3 +1,39 @@
+2013-05-09  Anders Carlsson  <[email protected]>
+
+        Add a StorageStrategy hook for creating transient local storage namespaces
+        https://bugs.webkit.org/show_bug.cgi?id=115870
+
+        Reviewed by Geoffrey Garen.
+
+        * WebCore.exp.in:
+        Export symbol needed by WebKit2.
+        
+        * dom/Document.cpp:
+        (WebCore::Document::topOrigin):
+        * dom/Document.h:
+        * dom/ScriptExecutionContext.h:
+        * workers/WorkerContext.h:
+        Remove const qualifier from topOrigin() to avoid ugly const_casts when assigning into a RefPtr<SecurityOrigin> variable.
+
+        * page/PageGroup.cpp:
+        (WebCore::PageGroup::transientLocalStorage):
+        Do a single hash lookup instead of three and use the SecurityOrigin itself as the hash key instead of a string representation of it.
+
+        * page/PageGroup.h:
+        Update HashMap declaration.
+
+        * storage/StorageNamespace.cpp:
+        (WebCore::StorageNamespace::transientLocalStorageNamespace):
+        Add new implementation that will optionally call out to the storage strategy.
+
+        * storage/StorageNamespaceImpl.cpp:
+        (WebCore::StorageNamespaceImpl::transientLocalStorageNamespace):
+        Move the default implementation here from PageGroup.
+        
+        * storage/StorageStrategy.cpp:
+        (WebCore::StorageStrategy::transientLocalStorageNamespace):
+        Call the default implementation.
+
 2013-05-09  Enrica Casucci  <[email protected]>
 
         A change in system environment should force all CSS properties to be recomputed.

Modified: trunk/Source/WebCore/WebCore.exp.in (149839 => 149840)


--- trunk/Source/WebCore/WebCore.exp.in	2013-05-09 20:54:16 UTC (rev 149839)
+++ trunk/Source/WebCore/WebCore.exp.in	2013-05-09 21:03:56 UTC (rev 149840)
@@ -484,6 +484,7 @@
 __ZN7WebCore15ScrollAlignment19alignToEdgeIfNeededE
 __ZN7WebCore15StorageStrategy21localStorageNamespaceEPNS_9PageGroupE
 __ZN7WebCore15StorageStrategy23sessionStorageNamespaceEPNS_4PageE
+__ZN7WebCore15StorageStrategy30transientLocalStorageNamespaceEPNS_9PageGroupEPNS_14SecurityOriginEO
 __ZN7WebCore15StringTruncator13rightTruncateERKN3WTF6StringEfRKNS_4FontENS0_24EnableRoundingHacksOrNotE
 __ZN7WebCore15StringTruncator14centerTruncateERKN3WTF6StringEfRKNS_4FontENS0_24EnableRoundingHacksOrNotE
 __ZN7WebCore15StringTruncator5widthERKN3WTF6StringERKNS_4FontENS0_24EnableRoundingHacksOrNotE

Modified: trunk/Source/WebCore/dom/Document.cpp (149839 => 149840)


--- trunk/Source/WebCore/dom/Document.cpp	2013-05-09 20:54:16 UTC (rev 149839)
+++ trunk/Source/WebCore/dom/Document.cpp	2013-05-09 21:03:56 UTC (rev 149840)
@@ -4808,7 +4808,7 @@
         page->console()->addMessage(source, level, message, sourceURL, lineNumber, columnNumber, callStack, state, requestIdentifier);
 }
 
-const SecurityOrigin* Document::topOrigin() const
+SecurityOrigin* Document::topOrigin() const
 {
     return topDocument()->securityOrigin();
 }

Modified: trunk/Source/WebCore/dom/Document.h (149839 => 149840)


--- trunk/Source/WebCore/dom/Document.h	2013-05-09 20:54:16 UTC (rev 149839)
+++ trunk/Source/WebCore/dom/Document.h	2013-05-09 21:03:56 UTC (rev 149840)
@@ -1209,7 +1209,7 @@
 
     virtual void addConsoleMessage(MessageSource, MessageLevel, const String& message, unsigned long requestIdentifier = 0);
 
-    virtual const SecurityOrigin* topOrigin() const OVERRIDE;
+    virtual SecurityOrigin* topOrigin() const OVERRIDE;
 
 #if ENABLE(FONT_LOAD_EVENTS)
     PassRefPtr<FontLoader> fontloader();

Modified: trunk/Source/WebCore/dom/ScriptExecutionContext.h (149839 => 149840)


--- trunk/Source/WebCore/dom/ScriptExecutionContext.h	2013-05-09 20:54:16 UTC (rev 149839)
+++ trunk/Source/WebCore/dom/ScriptExecutionContext.h	2013-05-09 21:03:56 UTC (rev 149840)
@@ -82,7 +82,7 @@
     void addConsoleMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, ScriptState* = 0, unsigned long requestIdentifier = 0);
     virtual void addConsoleMessage(MessageSource, MessageLevel, const String& message, unsigned long requestIdentifier = 0) = 0;
 
-    virtual const SecurityOrigin* topOrigin() const = 0;
+    virtual SecurityOrigin* topOrigin() const = 0;
 
 #if ENABLE(BLOB)
     PublicURLManager& publicURLManager();

Modified: trunk/Source/WebCore/page/PageGroup.cpp (149839 => 149840)


--- trunk/Source/WebCore/page/PageGroup.cpp	2013-05-09 20:54:16 UTC (rev 149839)
+++ trunk/Source/WebCore/page/PageGroup.cpp	2013-05-09 21:03:56 UTC (rev 149840)
@@ -263,13 +263,14 @@
     return m_localStorage.get();
 }
 
-StorageNamespace* PageGroup::transientLocalStorage(const SecurityOrigin* topOrigin)
+StorageNamespace* PageGroup::transientLocalStorage(SecurityOrigin* topOrigin)
 {
-    String topOriginString = topOrigin->toString();
-    if (!m_transientLocalStorage.get(topOriginString))
-        m_transientLocalStorage.set(topOriginString, StorageNamespace::sessionStorageNamespace(*this->pages().begin()));
+    HashMap<RefPtr<SecurityOrigin>, RefPtr<StorageNamespace> >::AddResult result = m_transientLocalStorageMap.add(topOrigin, 0);
 
-    return m_transientLocalStorage.get(topOriginString);
+    if (result.isNewEntry)
+        result.iterator->value = StorageNamespace::transientLocalStorageNamespace(this, topOrigin);
+
+    return result.iterator->value.get();
 }
 
 void PageGroup::addUserScriptToWorld(DOMWrapperWorld* world, const String& source, const KURL& url,

Modified: trunk/Source/WebCore/page/PageGroup.h (149839 => 149840)


--- trunk/Source/WebCore/page/PageGroup.h	2013-05-09 20:54:16 UTC (rev 149839)
+++ trunk/Source/WebCore/page/PageGroup.h	2013-05-09 21:03:56 UTC (rev 149840)
@@ -26,13 +26,13 @@
 #ifndef PageGroup_h
 #define PageGroup_h
 
-#include <wtf/HashSet.h>
-#include <wtf/Noncopyable.h>
 #include "LinkHash.h"
+#include "SecurityOriginHash.h"
 #include "Supplementable.h"
 #include "UserScript.h"
 #include "UserStyleSheet.h"
-#include <wtf/text/StringHash.h>
+#include <wtf/HashSet.h>
+#include <wtf/Noncopyable.h>
 
 namespace WebCore {
 
@@ -87,7 +87,7 @@
         StorageNamespace* localStorage();
         bool hasLocalStorage() { return m_localStorage; }
 
-        StorageNamespace* transientLocalStorage(const SecurityOrigin* topOrigin);
+        StorageNamespace* transientLocalStorage(SecurityOrigin* topOrigin);
 
         void addUserScriptToWorld(DOMWrapperWorld*, const String& source, const KURL&,
                                   const Vector<String>& whitelist, const Vector<String>& blacklist,
@@ -118,7 +118,7 @@
     private:
         PageGroup(Page*);
 
-        void addVisitedLink(LinkHash stringHash);
+        void addVisitedLink(LinkHash);
         void invalidatedInjectedStyleSheetCacheInAllFrames();
 
         String m_name;
@@ -130,7 +130,7 @@
 
         unsigned m_identifier;
         RefPtr<StorageNamespace> m_localStorage;
-        HashMap<String, RefPtr<StorageNamespace> > m_transientLocalStorage;
+        HashMap<RefPtr<SecurityOrigin>, RefPtr<StorageNamespace> > m_transientLocalStorageMap;
 
         OwnPtr<UserScriptMap> m_userScripts;
         OwnPtr<UserStyleSheetMap> m_userStyleSheets;

Modified: trunk/Source/WebCore/storage/StorageNamespace.cpp (149839 => 149840)


--- trunk/Source/WebCore/storage/StorageNamespace.cpp	2013-05-09 20:54:16 UTC (rev 149839)
+++ trunk/Source/WebCore/storage/StorageNamespace.cpp	2013-05-09 21:03:56 UTC (rev 149840)
@@ -44,6 +44,15 @@
 #endif
 }
 
+PassRefPtr<StorageNamespace> StorageNamespace::transientLocalStorageNamespace(PageGroup* pageGroup, SecurityOrigin* securityOrigin)
+{
+#if USE(PLATFORM_STRATEGIES)
+    return platformStrategies()->storageStrategy()->transientLocalStorageNamespace(pageGroup, securityOrigin);
+#else
+    return StorageNamespaceImpl::transientLocalStorageNamespace(pageGroup, securityOrigin);
+#endif
+}
+
 PassRefPtr<StorageNamespace> StorageNamespace::sessionStorageNamespace(Page* page)
 {
 #if USE(PLATFORM_STRATEGIES)

Modified: trunk/Source/WebCore/storage/StorageNamespace.h (149839 => 149840)


--- trunk/Source/WebCore/storage/StorageNamespace.h	2013-05-09 20:54:16 UTC (rev 149839)
+++ trunk/Source/WebCore/storage/StorageNamespace.h	2013-05-09 21:03:56 UTC (rev 149840)
@@ -40,6 +40,7 @@
 class StorageNamespace : public RefCounted<StorageNamespace> {
 public:
     static PassRefPtr<StorageNamespace> localStorageNamespace(PageGroup*);
+    static PassRefPtr<StorageNamespace> transientLocalStorageNamespace(PageGroup*, SecurityOrigin*);
     static PassRefPtr<StorageNamespace> sessionStorageNamespace(Page*);
 
     virtual ~StorageNamespace() { }

Modified: trunk/Source/WebCore/storage/StorageNamespaceImpl.cpp (149839 => 149840)


--- trunk/Source/WebCore/storage/StorageNamespaceImpl.cpp	2013-05-09 20:54:16 UTC (rev 149839)
+++ trunk/Source/WebCore/storage/StorageNamespaceImpl.cpp	2013-05-09 21:03:56 UTC (rev 149840)
@@ -75,6 +75,13 @@
     return adoptRef(new StorageNamespaceImpl(SessionStorage, String(), page->settings()->sessionStorageQuota()));
 }
 
+PassRefPtr<StorageNamespace> StorageNamespaceImpl::transientLocalStorageNamespace(PageGroup* pageGroup, SecurityOrigin*)
+{
+    // FIXME: A smarter implementation would create a special namespace type instead of just piggy-backing off
+    // SessionStorageNamespace here.
+    return StorageNamespaceImpl::sessionStorageNamespace(*pageGroup->pages().begin());
+}
+
 StorageNamespaceImpl::StorageNamespaceImpl(StorageType storageType, const String& path, unsigned quota)
     : m_storageType(storageType)
     , m_path(path.isolatedCopy())

Modified: trunk/Source/WebCore/storage/StorageNamespaceImpl.h (149839 => 149840)


--- trunk/Source/WebCore/storage/StorageNamespaceImpl.h	2013-05-09 20:54:16 UTC (rev 149839)
+++ trunk/Source/WebCore/storage/StorageNamespaceImpl.h	2013-05-09 21:03:56 UTC (rev 149840)
@@ -40,6 +40,7 @@
 class StorageNamespaceImpl : public StorageNamespace {
 public:
     static PassRefPtr<StorageNamespace> localStorageNamespace(PageGroup*);
+    static PassRefPtr<StorageNamespace> transientLocalStorageNamespace(PageGroup*, SecurityOrigin*);
     static PassRefPtr<StorageNamespace> sessionStorageNamespace(Page*);
     virtual ~StorageNamespaceImpl();
 

Modified: trunk/Source/WebCore/storage/StorageStrategy.cpp (149839 => 149840)


--- trunk/Source/WebCore/storage/StorageStrategy.cpp	2013-05-09 20:54:16 UTC (rev 149839)
+++ trunk/Source/WebCore/storage/StorageStrategy.cpp	2013-05-09 21:03:56 UTC (rev 149840)
@@ -42,6 +42,11 @@
     return StorageNamespaceImpl::sessionStorageNamespace(page);
 }
 
+PassRefPtr<StorageNamespace> StorageStrategy::transientLocalStorageNamespace(PageGroup* pageGroup, SecurityOrigin* securityOrigin)
+{
+    return StorageNamespaceImpl::transientLocalStorageNamespace(pageGroup, securityOrigin);
+}
+
 } // namespace WebCore
 
 #endif // USE(STORAGE_STRATEGIES)

Modified: trunk/Source/WebCore/storage/StorageStrategy.h (149839 => 149840)


--- trunk/Source/WebCore/storage/StorageStrategy.h	2013-05-09 20:54:16 UTC (rev 149839)
+++ trunk/Source/WebCore/storage/StorageStrategy.h	2013-05-09 21:03:56 UTC (rev 149840)
@@ -34,11 +34,13 @@
 
 class Page;
 class PageGroup;
+class SecurityOrigin;
 class StorageNamespace;
 
 class StorageStrategy {
 public:
     virtual PassRefPtr<StorageNamespace> localStorageNamespace(PageGroup*);
+    virtual PassRefPtr<StorageNamespace> transientLocalStorageNamespace(PageGroup*, SecurityOrigin*);
     virtual PassRefPtr<StorageNamespace> sessionStorageNamespace(Page*);
 
 protected:

Modified: trunk/Source/WebCore/workers/WorkerContext.h (149839 => 149840)


--- trunk/Source/WebCore/workers/WorkerContext.h	2013-05-09 20:54:16 UTC (rev 149839)
+++ trunk/Source/WebCore/workers/WorkerContext.h	2013-05-09 21:03:56 UTC (rev 149840)
@@ -138,7 +138,7 @@
         void unregisterObserver(Observer*);
         void notifyObserversOfStop();
 
-        virtual const SecurityOrigin* topOrigin() const OVERRIDE { return m_topOrigin.get(); }
+        virtual SecurityOrigin* topOrigin() const OVERRIDE { return m_topOrigin.get(); }
 
     protected:
         WorkerContext(const KURL&, const String& userAgent, PassOwnPtr<GroupSettings>, WorkerThread*, PassRefPtr<SecurityOrigin> topOrigin);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to