Commit 668179f9 authored by andersca@apple.com's avatar andersca@apple.com

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.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@149840 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 8aba7518
2013-05-09 Anders Carlsson <andersca@apple.com>
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 <enrica@apple.com>
A change in system environment should force all CSS properties to be recomputed.
......
......@@ -484,6 +484,7 @@ __ZN7WebCore15ScrollAlignment17alignCenterAlwaysE
__ZN7WebCore15ScrollAlignment19alignToEdgeIfNeededE
__ZN7WebCore15StorageStrategy21localStorageNamespaceEPNS_9PageGroupE
__ZN7WebCore15StorageStrategy23sessionStorageNamespaceEPNS_4PageE
__ZN7WebCore15StorageStrategy30transientLocalStorageNamespaceEPNS_9PageGroupEPNS_14SecurityOriginEO
__ZN7WebCore15StringTruncator13rightTruncateERKN3WTF6StringEfRKNS_4FontENS0_24EnableRoundingHacksOrNotE
__ZN7WebCore15StringTruncator14centerTruncateERKN3WTF6StringEfRKNS_4FontENS0_24EnableRoundingHacksOrNotE
__ZN7WebCore15StringTruncator5widthERKN3WTF6StringERKNS_4FontENS0_24EnableRoundingHacksOrNotE
......
......@@ -4808,7 +4808,7 @@ void Document::addMessage(MessageSource source, MessageLevel level, const String
page->console()->addMessage(source, level, message, sourceURL, lineNumber, columnNumber, callStack, state, requestIdentifier);
}
const SecurityOrigin* Document::topOrigin() const
SecurityOrigin* Document::topOrigin() const
{
return topDocument()->securityOrigin();
}
......
......@@ -1209,7 +1209,7 @@ public:
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();
......
......@@ -82,7 +82,7 @@ public:
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();
......
......@@ -263,13 +263,14 @@ StorageNamespace* PageGroup::localStorage()
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,
......
......@@ -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 @@ namespace WebCore {
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 @@ namespace WebCore {
private:
PageGroup(Page*);
void addVisitedLink(LinkHash stringHash);
void addVisitedLink(LinkHash);
void invalidatedInjectedStyleSheetCacheInAllFrames();
String m_name;
......@@ -130,7 +130,7 @@ namespace WebCore {
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;
......
......@@ -44,6 +44,15 @@ PassRefPtr<StorageNamespace> StorageNamespace::localStorageNamespace(PageGroup*
#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)
......
......@@ -40,6 +40,7 @@ class StorageArea;
class StorageNamespace : public RefCounted<StorageNamespace> {
public:
static PassRefPtr<StorageNamespace> localStorageNamespace(PageGroup*);
static PassRefPtr<StorageNamespace> transientLocalStorageNamespace(PageGroup*, SecurityOrigin*);
static PassRefPtr<StorageNamespace> sessionStorageNamespace(Page*);
virtual ~StorageNamespace() { }
......
......@@ -75,6 +75,13 @@ PassRefPtr<StorageNamespace> StorageNamespaceImpl::sessionStorageNamespace(Page*
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())
......
......@@ -40,6 +40,7 @@ class StorageAreaImpl;
class StorageNamespaceImpl : public StorageNamespace {
public:
static PassRefPtr<StorageNamespace> localStorageNamespace(PageGroup*);
static PassRefPtr<StorageNamespace> transientLocalStorageNamespace(PageGroup*, SecurityOrigin*);
static PassRefPtr<StorageNamespace> sessionStorageNamespace(Page*);
virtual ~StorageNamespaceImpl();
......
......@@ -42,6 +42,11 @@ PassRefPtr<StorageNamespace> StorageStrategy::sessionStorageNamespace(Page* page
return StorageNamespaceImpl::sessionStorageNamespace(page);
}
PassRefPtr<StorageNamespace> StorageStrategy::transientLocalStorageNamespace(PageGroup* pageGroup, SecurityOrigin* securityOrigin)
{
return StorageNamespaceImpl::transientLocalStorageNamespace(pageGroup, securityOrigin);
}
} // namespace WebCore
#endif // USE(STORAGE_STRATEGIES)
......@@ -34,11 +34,13 @@ namespace WebCore {
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:
......
......@@ -138,7 +138,7 @@ namespace WebCore {
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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment