Commit 06c8e74b authored by beidson@apple.com's avatar beidson@apple.com

2008-05-05 Brady Eidson <beidson@apple.com>

        Reviewed by Mitz Pettel RTL

        Preparation for upcoming work making LocalStorage persistent.

        - Create the LocalStorage object for a PageGroup the moment the first Page is added to it
          The Settings of the first Page define what persistent path the LocalStorage will use
        - Add a Frame argument for the LocalStorageArea request - this will allow a client object
          to be queried before the LocalStorageArea is established

        * page/DOMWindow.cpp:
        (WebCore::DOMWindow::localStorage):

        * page/PageGroup.cpp:
        (WebCore::PageGroup::addPage):
        (WebCore::PageGroup::localStorage):

        * storage/LocalStorage.cpp:
        (WebCore::LocalStorage::LocalStorage): Take the path as a constructor argument.  Deep copy
          the path as it will be used from another thread.
        (WebCore::LocalStorage::storageArea):
        * storage/LocalStorage.h:
        (WebCore::LocalStorage::create):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@32899 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 2cfbe4c4
2008-05-05 Brady Eidson <beidson@apple.com>
Reviewed by Mitz Pettel RTL
Preparation for upcoming work making LocalStorage persistent.
- Create the LocalStorage object for a PageGroup the moment the first Page is added to it
The Settings of the first Page define what persistent path the LocalStorage will use
- Add a Frame argument for the LocalStorageArea request - this will allow a client object
to be queried before the LocalStorageArea is established
* page/DOMWindow.cpp:
(WebCore::DOMWindow::localStorage):
* page/PageGroup.cpp:
(WebCore::PageGroup::addPage):
(WebCore::PageGroup::localStorage):
* storage/LocalStorage.cpp:
(WebCore::LocalStorage::LocalStorage): Take the path as a constructor argument. Deep copy
the path as it will be used from another thread.
(WebCore::LocalStorage::storageArea):
* storage/LocalStorage.h:
(WebCore::LocalStorage::create):
2008-05-05 Brady Eidson <beidson@apple.com>
Reviewed by Mitz Pettel RTL
......@@ -316,8 +316,10 @@ Storage* DOMWindow::localStorage() const
if (!page)
return 0;
RefPtr<StorageArea> storageArea = page->group().localStorage()->storageArea(document->securityOrigin());
m_localStorage = Storage::create(m_frame, storageArea.release());
RefPtr<StorageArea> storageArea = page->group().localStorage()->storageArea(m_frame, document->securityOrigin());
if (storageArea)
m_localStorage = Storage::create(m_frame, storageArea.release());
return m_localStorage.get();
}
#endif
......
......@@ -29,6 +29,7 @@
#include "ChromeClient.h"
#include "Document.h"
#include "Page.h"
#include "Settings.h"
#if ENABLE(DOM_STORAGE)
#include "LocalStorage.h"
......@@ -88,6 +89,10 @@ void PageGroup::addPage(Page* page)
ASSERT(page);
ASSERT(!m_pages.contains(page));
m_pages.add(page);
#if ENABLE(DOM_STORAGE)
if (!m_localStorage)
m_localStorage = LocalStorage::create(this, page->settings()->localStorageDatabasePath());
#endif
}
void PageGroup::removePage(Page* page)
......@@ -157,9 +162,6 @@ void PageGroup::setShouldTrackVisitedLinks(bool shouldTrack)
#if ENABLE(DOM_STORAGE)
LocalStorage* PageGroup::localStorage()
{
if (!m_localStorage)
m_localStorage = LocalStorage::create(this);
return m_localStorage.get();
}
#endif
......
......@@ -37,14 +37,20 @@
namespace WebCore {
LocalStorage::LocalStorage(PageGroup* group)
LocalStorage::LocalStorage(PageGroup* group, const String& path)
: m_group(group)
, m_path(path.copy())
{
ASSERT(m_group);
}
PassRefPtr<StorageArea> LocalStorage::storageArea(SecurityOrigin* origin)
PassRefPtr<StorageArea> LocalStorage::storageArea(Frame* sourceFrame, SecurityOrigin* origin)
{
// FIXME: If the security origin in question has never had a storage area established,
// we need to ask a client call if establishing it is okay. If the client denies the request,
// this method will return null.
// The sourceFrame argument exists for the purpose of asking a client.
RefPtr<StorageArea> storageArea;
if (storageArea = m_storageAreaMap.get(origin))
return storageArea.release();
......
......@@ -39,17 +39,19 @@ namespace WebCore {
class LocalStorage : public RefCounted<LocalStorage> {
public:
static PassRefPtr<LocalStorage> create(PageGroup* group) { return adoptRef(new LocalStorage(group)); }
PassRefPtr<StorageArea> storageArea(SecurityOrigin*);
static PassRefPtr<LocalStorage> create(PageGroup* group, const String& path) { return adoptRef(new LocalStorage(group, path)); }
PassRefPtr<StorageArea> storageArea(Frame* sourceFrame, SecurityOrigin*);
private:
LocalStorage(PageGroup*);
LocalStorage(PageGroup*, const String& path);
typedef HashMap<RefPtr<SecurityOrigin>, RefPtr<StorageArea>, SecurityOriginHash> StorageAreaMap;
StorageAreaMap m_storageAreaMap;
PageGroup* m_group;
String m_path;
};
} // 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