Commit 653985c6 authored by beidson@apple.com's avatar beidson@apple.com

2008-04-17 Brady Eidson <beidson@apple.com>

        Reviewed by the Mitzpettel

        Before things get much more intertwined, move away from a global LocalStorage model
        to a per-PageGroup LocalStorage model.

        * page/DOMWindow.cpp:
        (WebCore::DOMWindow::localStorage): Get it from the current PageGroup, not the global
          LocalStorage (which doesn't exist anymore).

        * page/Page.cpp:
        * page/PageGroup.cpp:
        (WebCore::PageGroup::localStorage): Create a LocalStorage object on demand.
        * page/PageGroup.h:

        * storage/LocalStorage.cpp:
        (WebCore::LocalStorage::LocalStorage): Hold a back pointer to the owning PageGroup.
        (WebCore::LocalStorage::storageArea):
        * storage/LocalStorage.h:
        (WebCore::LocalStorage::create):

        * storage/LocalStorageArea.cpp:
        (WebCore::LocalStorageArea::LocalStorageArea): Hold a back pointer to the owning LocalStorage.
        * storage/LocalStorageArea.h:
        (WebCore::LocalStorageArea::create):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@32020 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d66a1152
2008-04-17 Brady Eidson <beidson@apple.com>
Reviewed by the Mitzpettel
Before things get much more intertwined, move away from a global LocalStorage model
to a per-PageGroup LocalStorage model.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::localStorage): Get it from the current PageGroup, not the global
LocalStorage (which doesn't exist anymore).
* page/Page.cpp:
* page/PageGroup.cpp:
(WebCore::PageGroup::localStorage): Create a LocalStorage object on demand.
* page/PageGroup.h:
* storage/LocalStorage.cpp:
(WebCore::LocalStorage::LocalStorage): Hold a back pointer to the owning PageGroup.
(WebCore::LocalStorage::storageArea):
* storage/LocalStorage.h:
(WebCore::LocalStorage::create):
* storage/LocalStorageArea.cpp:
(WebCore::LocalStorageArea::LocalStorageArea): Hold a back pointer to the owning LocalStorage.
* storage/LocalStorageArea.h:
(WebCore::LocalStorageArea::create):
2008-04-17 Anders Carlsson <andersca@apple.com>
Fix indentation.
......@@ -49,6 +49,7 @@
#include "Location.h"
#include "Navigator.h"
#include "Page.h"
#include "PageGroup.h"
#include "PlatformScreen.h"
#include "PlatformString.h"
#include "Screen.h"
......@@ -307,7 +308,11 @@ Storage* DOMWindow::localStorage() const
if (!document)
return 0;
RefPtr<StorageArea> storageArea = LocalStorage::sharedLocalStorage().storageArea(document->securityOrigin());
Page* page = document->page();
if (!page)
return 0;
RefPtr<StorageArea> storageArea = page->group().localStorage()->storageArea(document->securityOrigin());
m_localStorage = Storage::create(m_frame, storageArea.release());
return m_localStorage.get();
}
......
......@@ -37,6 +37,7 @@
#include "HistoryItem.h"
#include "InspectorController.h"
#include "JavaScriptDebugServer.h"
#include "LocalStorage.h"
#include "Logging.h"
#include "Navigator.h"
#include "PageGroup.h"
......
......@@ -28,7 +28,9 @@
#include "ChromeClient.h"
#include "Document.h"
#include "LocalStorage.h"
#include "Page.h"
#include "StorageArea.h"
namespace WebCore {
......@@ -114,4 +116,12 @@ void PageGroup::setShouldTrackVisitedLinks(bool shouldTrack)
removeAllVisitedLinks();
}
LocalStorage* PageGroup::localStorage()
{
if (!m_localStorage)
m_localStorage = LocalStorage::create(this);
return m_localStorage.get();
}
} // namespace WebCore
......@@ -33,6 +33,7 @@
namespace WebCore {
class KURL;
class LocalStorage;
class Page;
class PageGroup : Noncopyable {
......@@ -52,6 +53,8 @@ namespace WebCore {
static void setShouldTrackVisitedLinks(bool);
static void removeAllVisitedLinks();
LocalStorage* localStorage();
private:
void addVisitedLink(unsigned stringHash);
......@@ -59,6 +62,7 @@ namespace WebCore {
HashSet<Page*> m_pages;
HashSet<unsigned, AlreadyHashed> m_visitedLinkHashes;
bool m_visitedLinksPopulated;
RefPtr<LocalStorage> m_localStorage;
};
} // namespace WebCore
......
......@@ -36,18 +36,11 @@
namespace WebCore {
LocalStorage& LocalStorage::sharedLocalStorage()
{
static LocalStorage* sharedLocalStorage = 0;
if (!sharedLocalStorage)
sharedLocalStorage = new LocalStorage();
return *sharedLocalStorage;
}
LocalStorage::LocalStorage()
LocalStorage::LocalStorage(PageGroup* group)
: m_group(group)
{
ASSERT(m_group);
}
PassRefPtr<StorageArea> LocalStorage::storageArea(SecurityOrigin* origin)
......@@ -56,7 +49,7 @@ PassRefPtr<StorageArea> LocalStorage::storageArea(SecurityOrigin* origin)
if (storageArea = m_storageAreaMap.get(origin))
return storageArea.release();
storageArea = LocalStorageArea::create(origin);
storageArea = LocalStorageArea::create(origin, this);
m_storageAreaMap.set(origin, storageArea);
return storageArea.release();
}
......
......@@ -30,23 +30,26 @@
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/Noncopyable.h>
namespace WebCore {
class LocalStorageArea;
class PageGroup;
class StorageArea;
class LocalStorage : Noncopyable{
class LocalStorage : public RefCounted<LocalStorage> {
public:
static LocalStorage& sharedLocalStorage();
static PassRefPtr<LocalStorage> create(PageGroup* group) { return adoptRef(new LocalStorage(group)); }
PassRefPtr<StorageArea> storageArea(SecurityOrigin*);
private:
LocalStorage();
LocalStorage(PageGroup*);
typedef HashMap<RefPtr<SecurityOrigin>, RefPtr<StorageArea>, SecurityOriginHash, SecurityOriginTraits> StorageAreaMap;
StorageAreaMap m_storageAreaMap;
PageGroup* m_group;
};
} // namespace WebCore
......
......@@ -36,8 +36,9 @@
namespace WebCore {
LocalStorageArea::LocalStorageArea(SecurityOrigin* origin)
LocalStorageArea::LocalStorageArea(SecurityOrigin* origin, LocalStorage* localStorage)
: StorageArea(origin)
, m_localStorage(localStorage)
{
}
......
......@@ -32,17 +32,21 @@
namespace WebCore {
class LocalStorage;
class LocalStorageArea : public StorageArea {
public:
static PassRefPtr<LocalStorageArea> create(SecurityOrigin* origin) { return adoptRef(new LocalStorageArea(origin)); }
static PassRefPtr<LocalStorageArea> create(SecurityOrigin* origin, LocalStorage* localStorage) { return adoptRef(new LocalStorageArea(origin, localStorage)); }
private:
LocalStorageArea(SecurityOrigin*);
LocalStorageArea(SecurityOrigin*, LocalStorage*);
virtual void itemChanged(const String& key, const String& oldValue, const String& newValue, Frame* sourceFrame);
virtual void itemRemoved(const String& key, const String& oldValue, Frame* sourceFrame);
void dispatchStorageEvent(const String& key, const String& oldValue, const String& newValue, Frame* sourceFrame);
LocalStorage* m_localStorage;
};
} // namespace WebCore
......
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