Commit ea665a21 authored by abarth@webkit.org's avatar abarth@webkit.org

2009-06-13 Ben Murdoch <benm@google.com>

        Reviewed by David Kilzer.  Landed by Adam Barth.

        https://bugs.webkit.org/show_bug.cgi?id=26189

        This patch changes the way PageGroups create their localStorage
        objects. Rather than creating a local storage object for the page group
        when a page is added to the group, the local storage object is now
        created lazily when the local storage object is requested by the
        DOMWindow.

        * page/PageGroup.cpp:
        (WebCore::PageGroup::closeLocalStorage): Before attempting to close a local storage object for a page group, ensure one has been created.
        (WebCore::PageGroup::addPage): Do not automatically try to create a local storage object when a page is added to the group.
        (WebCore::PageGroup::localStorage): Create a local storage object if one does not exist and return it.
        * page/PageGroup.h: Add private hasLocalStorage method to PageGroup.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@44663 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1095f23d
2009-06-13 Ben Murdoch <benm@google.com>
Reviewed by David Kilzer. Landed by Adam Barth.
https://bugs.webkit.org/show_bug.cgi?id=26189
This patch changes the way PageGroups create their localStorage
objects. Rather than creating a local storage object for the page group
when a page is added to the group, the local storage object is now
created lazily when the local storage object is requested by the
DOMWindow.
* page/PageGroup.cpp:
(WebCore::PageGroup::closeLocalStorage): Before attempting to close a local storage object for a page group, ensure one has been created.
(WebCore::PageGroup::addPage): Do not automatically try to create a local storage object when a page is added to the group.
(WebCore::PageGroup::localStorage): Create a local storage object if one does not exist and return it.
* page/PageGroup.h: Add private hasLocalStorage method to PageGroup.
2009-06-13 Ben Murdoch <benm@google.com> 2009-06-13 Ben Murdoch <benm@google.com>
Reviewed by Eric Seidel. Landed by Adam Barth. Reviewed by Eric Seidel. Landed by Adam Barth.
...@@ -97,8 +97,8 @@ void PageGroup::closeLocalStorage() ...@@ -97,8 +97,8 @@ void PageGroup::closeLocalStorage()
PageGroupMap::iterator end = pageGroups->end(); PageGroupMap::iterator end = pageGroups->end();
for (PageGroupMap::iterator it = pageGroups->begin(); it != end; ++it) { for (PageGroupMap::iterator it = pageGroups->begin(); it != end; ++it) {
if (LocalStorage* localStorage = it->second->localStorage()) if (it->second->hasLocalStorage())
localStorage->close(); it->second->localStorage()->close();
} }
#endif #endif
} }
...@@ -108,10 +108,6 @@ void PageGroup::addPage(Page* page) ...@@ -108,10 +108,6 @@ void PageGroup::addPage(Page* page)
ASSERT(page); ASSERT(page);
ASSERT(!m_pages.contains(page)); ASSERT(!m_pages.contains(page));
m_pages.add(page); m_pages.add(page);
#if ENABLE(DOM_STORAGE)
if (!m_localStorage)
m_localStorage = LocalStorage::localStorage(page->settings()->localStorageDatabasePath());
#endif
} }
void PageGroup::removePage(Page* page) void PageGroup::removePage(Page* page)
...@@ -187,6 +183,13 @@ void PageGroup::setShouldTrackVisitedLinks(bool shouldTrack) ...@@ -187,6 +183,13 @@ void PageGroup::setShouldTrackVisitedLinks(bool shouldTrack)
#if ENABLE(DOM_STORAGE) #if ENABLE(DOM_STORAGE)
LocalStorage* PageGroup::localStorage() LocalStorage* PageGroup::localStorage()
{ {
if (!m_localStorage) {
// Need a page in this page group to query the settings for the local storage database path.
Page* page = *m_pages.begin();
ASSERT(page);
m_localStorage = LocalStorage::localStorage(page->settings()->localStorageDatabasePath());
}
return m_localStorage.get(); return m_localStorage.get();
} }
#endif #endif
......
...@@ -68,7 +68,9 @@ namespace WebCore { ...@@ -68,7 +68,9 @@ namespace WebCore {
private: private:
void addVisitedLink(LinkHash stringHash); void addVisitedLink(LinkHash stringHash);
#if ENABLE(DOM_STORAGE)
bool hasLocalStorage() { return m_localStorage; }
#endif
String m_name; String m_name;
HashSet<Page*> m_pages; HashSet<Page*> m_pages;
......
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