Need a method to close all idle localstorage databases immediately.

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

Patch by Yongjun Zhang <yongjun_zhang@apple.com> on 2012-12-02
Reviewed by David Kilzer.

Source/WebCore:

Add a new PageGroup method closeIdleLocalStorageDatabases, which walks through
all local storage areas that don't have document referencing to them and closes
their underlying databases.

Test: storage/domstorage/localstorage/close-idle-localstorage-databases-immediately.html

* WebCore.exp.in:
* page/PageGroup.cpp:
(WebCore::PageGroup::clearLocalStorageForOrigin):
(WebCore):
(WebCore::PageGroup::closeIdleLocalStorageDatabases): walking through all idle local storages and
    closing their databases.
* page/PageGroup.h:
(PageGroup):
* storage/StorageArea.h:
(WebCore::StorageArea::closeDatabaseIfIdle):
* storage/StorageAreaImpl.cpp:
(WebCore::StorageAreaImpl::closeDatabaseIfIdle): close the database if it is idle.
(WebCore):
* storage/StorageAreaImpl.h:
(StorageAreaImpl):
* storage/StorageNamespace.h:
(StorageNamespace):
* storage/StorageNamespaceImpl.cpp:
(WebCore::StorageNamespaceImpl::closeIdleLocalStorageDatabases):
(WebCore):
* storage/StorageNamespaceImpl.h:
(StorageNamespaceImpl):

Source/WebKit/mac:

Add a new method to WebStorageManager that we can call to close all
idle local storage databases.

* Storage/WebStorageManager.mm:
(+[WebStorageManager closeIdleLocalStorageDatabases]):
* Storage/WebStorageManagerPrivate.h:

Tools:

Add an JS method to TestRunner, to enable testing closing idle local storage databases in
DumpRenderTree layout tests.

* DumpRenderTree/TestRunner.cpp:
(closeIdleLocalStorageDatabasesCallback):
(TestRunner::staticFunctions):
* DumpRenderTree/TestRunner.h:
(TestRunner):
* DumpRenderTree/blackberry/TestRunnerBlackBerry.cpp:
(TestRunner::closeIdleLocalStorageDatabases):
* DumpRenderTree/efl/TestRunnerEfl.cpp:
(TestRunner::closeIdleLocalStorageDatabases):
* DumpRenderTree/gtk/TestRunnerGtk.cpp:
(TestRunner::closeIdleLocalStorageDatabases):
* DumpRenderTree/mac/TestRunnerMac.mm:
(TestRunner::closeIdleLocalStorageDatabases):
* DumpRenderTree/win/TestRunnerWin.cpp:
(TestRunner::closeIdleLocalStorageDatabases):
* DumpRenderTree/wx/TestRunnerWx.cpp:
(TestRunner::closeIdleLocalStorageDatabases):

LayoutTests:

* storage/domstorage/localstorage/close-idle-localstorage-databases-immediately-expected.txt: Added.
* storage/domstorage/localstorage/close-idle-localstorage-databases-immediately.html: Added.
* storage/resources/storage-close-idle-localstorage-databases-immediately.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@136323 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b5d56825
2012-12-02 Yongjun Zhang <yongjun_zhang@apple.com>
Need a method to close all idle localstorage databases immediately.
https://bugs.webkit.org/show_bug.cgi?id=103469
Reviewed by David Kilzer.
* storage/domstorage/localstorage/close-idle-localstorage-databases-immediately-expected.txt: Added.
* storage/domstorage/localstorage/close-idle-localstorage-databases-immediately.html: Added.
* storage/resources/storage-close-idle-localstorage-databases-immediately.html: Added.
2012-12-02 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r136236.
......@@ -804,6 +804,7 @@ fast/forms/get-forms-to-about-blank.html [ WontFix ]
# implement because we can't emulate the caching behaviors it expects.
fast/dom/HTMLScriptElement/nested-execution.html [ WontFix ]
storage/domstorage/storage-close-database-on-idle.html [ WontFix ]
storage/domstorage/localstorage/close-idle-localstorage-databases-immediately.html [ WontFix ]
# Deletion UI is a Mail-ism. We don't need to worry about this.
editing/deleting/deletionUI-single-instance.html [ WontFix ]
......
<html>
<head>
<script src="../../../fast/js/resources/js-test-pre.js"></script>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
function loadNextPage()
{
location.href = "../../resources/storage-close-idle-localstorage-databases-immediately.html";
}
function runTest()
{
if (window.testRunner) {
testRunner.setCacheModel(0); // WebCacheModelDocumentViewer.
}
// Test to make sure the storage values don't change after the database is closed.
if ("localStorage" in window) {
var loadCount = window.sessionStorage['testPageLoadCount'];
if (loadCount !== undefined)
loadCount++;
else
loadCount = 1;
window.sessionStorage['testPageLoadCount'] = loadCount;
if (loadCount == 1) {
window.localStorage.clear();
window.localStorage['foo'] = 'FOO';
window.localStorage['bar'] = 'BAR';
setTimeout("loadNextPage()", 0);
} else {
// Test if we still have the right values.
if (window.localStorage['foo'] === 'FOO')
testPassed("foo");
else
testFailed("foo");
if (window.localStorage['bar'] === 'BAR')
testPassed("bar");
else
testFailed("bar");
window.sessionStorage.removeItem('testPageLoadCount');
if (window.testRunner) {
window.testRunner.notifyDone();
}
}
}
}
</script>
</head>
<body onload="runTest();">
<p id="description"></p>
<div id="console"></div>
</body>
</html>
<html>
<script>
function swingBack()
{
if (window.testRunner) {
window.testRunner.closeIdleLocalStorageDatabases();
}
location.href='../domstorage/localstorage/close-idle-localstorage-databases-immediately.html';
}
</script>
<body onload='setTimeout(swingBack(), 100);'>
</body>
</html>
2012-12-02 Yongjun Zhang <yongjun_zhang@apple.com>
Need a method to close all idle localstorage databases immediately.
https://bugs.webkit.org/show_bug.cgi?id=103469
Reviewed by David Kilzer.
Add a new PageGroup method closeIdleLocalStorageDatabases, which walks through
all local storage areas that don't have document referencing to them and closes
their underlying databases.
Test: storage/domstorage/localstorage/close-idle-localstorage-databases-immediately.html
* WebCore.exp.in:
* page/PageGroup.cpp:
(WebCore::PageGroup::clearLocalStorageForOrigin):
(WebCore):
(WebCore::PageGroup::closeIdleLocalStorageDatabases): walking through all idle local storages and
closing their databases.
* page/PageGroup.h:
(PageGroup):
* storage/StorageArea.h:
(WebCore::StorageArea::closeDatabaseIfIdle):
* storage/StorageAreaImpl.cpp:
(WebCore::StorageAreaImpl::closeDatabaseIfIdle): close the database if it is idle.
(WebCore):
* storage/StorageAreaImpl.h:
(StorageAreaImpl):
* storage/StorageNamespace.h:
(StorageNamespace):
* storage/StorageNamespaceImpl.cpp:
(WebCore::StorageNamespaceImpl::closeIdleLocalStorageDatabases):
(WebCore):
* storage/StorageNamespaceImpl.h:
(StorageNamespaceImpl):
2012-12-02 Otto Derek Cheung <otcheung@rim.com>
[BlackBerry] Adding checks for null when checking cookie status in CookieJarBlackBerry
......@@ -1089,6 +1089,7 @@ __ZN7WebCore9PageGroup26setShouldTrackVisitedLinksEb
__ZN7WebCore9PageGroup29removeUserStyleSheetFromWorldEPNS_15DOMWrapperWorldERKNS_4KURLE
__ZN7WebCore9PageGroup30removeUserStyleSheetsFromWorldEPNS_15DOMWrapperWorldE
__ZN7WebCore9PageGroup9pageGroupERKN3WTF6StringE
__ZN7WebCore9PageGroup30closeIdleLocalStorageDatabasesEv
__ZN7WebCore9Scrollbar10mouseMovedERKNS_18PlatformMouseEventE
__ZN7WebCore9Scrollbar11mouseExitedEv
__ZN7WebCore9Scrollbar12mouseEnteredEv
......
......@@ -144,9 +144,21 @@ void PageGroup::clearLocalStorageForOrigin(SecurityOrigin* origin)
for (PageGroupMap::iterator it = pageGroups->begin(); it != end; ++it) {
if (it->value->hasLocalStorage())
it->value->localStorage()->clearOriginForDeletion(origin);
}
}
}
void PageGroup::closeIdleLocalStorageDatabases()
{
if (!pageGroups)
return;
PageGroupMap::iterator end = pageGroups->end();
for (PageGroupMap::iterator it = pageGroups->begin(); it != end; ++it) {
if (it->value->hasLocalStorage())
it->value->localStorage()->closeIdleLocalStorageDatabases();
}
}
void PageGroup::syncLocalStorage()
{
if (!pageGroups)
......
......@@ -60,6 +60,7 @@ namespace WebCore {
static void clearLocalStorageForAllOrigins();
static void clearLocalStorageForOrigin(SecurityOrigin*);
static void closeIdleLocalStorageDatabases();
// DumpRenderTree helper that triggers a StorageArea sync.
static void syncLocalStorage();
......
......@@ -60,6 +60,7 @@ namespace WebCore {
virtual void incrementAccessCount() { }
virtual void decrementAccessCount() { }
virtual void closeDatabaseIfIdle() { }
};
} // namespace WebCore
......
......@@ -349,4 +349,14 @@ void StorageAreaImpl::closeDatabaseTimerFired(Timer<StorageAreaImpl> *)
m_storageAreaSync->scheduleCloseDatabase();
}
void StorageAreaImpl::closeDatabaseIfIdle()
{
if (m_closeDatabaseTimer.isActive()) {
ASSERT(!m_accessCount);
m_closeDatabaseTimer.stop();
closeDatabaseTimerFired(&m_closeDatabaseTimer);
}
}
}
......@@ -58,6 +58,7 @@ namespace WebCore {
virtual void incrementAccessCount();
virtual void decrementAccessCount();
virtual void closeDatabaseIfIdle();
PassRefPtr<StorageAreaImpl> copy();
void close();
......
......@@ -49,6 +49,7 @@ public:
virtual void clearOriginForDeletion(SecurityOrigin*) = 0;
virtual void clearAllOriginsForDeletion() = 0;
virtual void sync() = 0;
virtual void closeIdleLocalStorageDatabases() { }
};
} // namespace WebCore
......
......@@ -165,4 +165,12 @@ void StorageNamespaceImpl::sync()
it->value->sync();
}
void StorageNamespaceImpl::closeIdleLocalStorageDatabases()
{
ASSERT(isMainThread());
StorageAreaMap::iterator end = m_storageAreaMap.end();
for (StorageAreaMap::iterator it = m_storageAreaMap.begin(); it != end; ++it)
it->value->closeDatabaseIfIdle();
}
} // namespace WebCore
......@@ -54,7 +54,8 @@ namespace WebCore {
virtual void clearOriginForDeletion(SecurityOrigin*);
virtual void clearAllOriginsForDeletion();
virtual void sync();
virtual void closeIdleLocalStorageDatabases();
private:
StorageNamespaceImpl(StorageType, const String& path, unsigned quota);
......
2012-12-02 Yongjun Zhang <yongjun_zhang@apple.com>
Need a method to close all idle localstorage databases immediately.
https://bugs.webkit.org/show_bug.cgi?id=103469
Reviewed by David Kilzer.
Add a new method to WebStorageManager that we can call to close all
idle local storage databases.
* Storage/WebStorageManager.mm:
(+[WebStorageManager closeIdleLocalStorageDatabases]):
* Storage/WebStorageManagerPrivate.h:
2012-11-30 Mihai Maerean <mmaerean@adobe.com>
[CSSRegions] when WebKit uses V8, there should be a single variable to store if the CSS Regions feature is enabled
......
......@@ -28,6 +28,7 @@
#import "WebStorageManagerInternal.h"
#import "WebStorageTrackerClient.h"
#import <WebCore/PageGroup.h>
#import <WebCore/SecurityOrigin.h>
#import <WebCore/StorageTracker.h>
#import <pthread.h>
......@@ -102,6 +103,11 @@ static pthread_once_t registerLocalStoragePath = PTHREAD_ONCE_INIT;
StorageTracker::tracker().setStorageDatabaseIdleInterval(interval);
}
+ (void)closeIdleLocalStorageDatabases
{
PageGroup::closeIdleLocalStorageDatabases();
}
static void initializeLocalStoragePath()
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
......
......@@ -44,5 +44,6 @@ extern NSString * const WebStorageDidModifyOriginNotification;
+ (NSString *)_storageDirectoryPath;
+ (void)setStorageDatabaseIdleInterval:(double)interval;
+ (void)closeIdleLocalStorageDatabases;
@end
2012-12-02 Yongjun Zhang <yongjun_zhang@apple.com>
Need a method to close all idle localstorage databases immediately.
https://bugs.webkit.org/show_bug.cgi?id=103469
Reviewed by David Kilzer.
Add an JS method to TestRunner, to enable testing closing idle local storage databases in
DumpRenderTree layout tests.
* DumpRenderTree/TestRunner.cpp:
(closeIdleLocalStorageDatabasesCallback):
(TestRunner::staticFunctions):
* DumpRenderTree/TestRunner.h:
(TestRunner):
* DumpRenderTree/blackberry/TestRunnerBlackBerry.cpp:
(TestRunner::closeIdleLocalStorageDatabases):
* DumpRenderTree/efl/TestRunnerEfl.cpp:
(TestRunner::closeIdleLocalStorageDatabases):
* DumpRenderTree/gtk/TestRunnerGtk.cpp:
(TestRunner::closeIdleLocalStorageDatabases):
* DumpRenderTree/mac/TestRunnerMac.mm:
(TestRunner::closeIdleLocalStorageDatabases):
* DumpRenderTree/win/TestRunnerWin.cpp:
(TestRunner::closeIdleLocalStorageDatabases):
* DumpRenderTree/wx/TestRunnerWx.cpp:
(TestRunner::closeIdleLocalStorageDatabases):
2012-12-02 Yael Aharon <yael.aharon@intel.com>
[EFL][WK2] MiniBrowser should have a legacy mode
......
......@@ -2079,6 +2079,14 @@ static JSValueRef setStorageDatabaseIdleIntervalCallback(JSContextRef context, J
return JSValueMakeUndefined(context);
}
static JSValueRef closeIdleLocalStorageDatabasesCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
TestRunner* controller = static_cast<TestRunner*>(JSObjectGetPrivate(thisObject));
controller->closeIdleLocalStorageDatabases();
return JSValueMakeUndefined(context);
}
static JSValueRef grantWebNotificationPermissionCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
if (argumentCount < 1)
......@@ -2344,6 +2352,7 @@ JSStaticFunction* TestRunner::staticFunctions()
{ "preciseTime", preciseTimeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "setHasCustomFullScreenBehavior", setHasCustomFullScreenBehaviorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "setStorageDatabaseIdleInterval", setStorageDatabaseIdleIntervalCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "closeIdleLocalStorageDatabases", closeIdleLocalStorageDatabasesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "grantWebNotificationPermission", grantWebNotificationPermissionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "denyWebNotificationPermission", denyWebNotificationPermissionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "removeAllWebNotificationPermissions", removeAllWebNotificationPermissionsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
......
......@@ -362,6 +362,7 @@ public:
bool hasCustomFullScreenBehavior() const { return m_customFullScreenBehavior; }
void setStorageDatabaseIdleInterval(double);
void closeIdleLocalStorageDatabases();
bool hasPendingWebNotificationClick() const { return m_hasPendingWebNotificationClick; }
......
......@@ -856,3 +856,8 @@ void TestRunner::setStorageDatabaseIdleInterval(double)
// FIXME: Implement this.
notImplemented();
}
void TestRunner::closeIdleLocalStorageDatabases()
{
notImplemented();
}
......@@ -924,3 +924,8 @@ void TestRunner::setStorageDatabaseIdleInterval(double)
{
notImplemented();
}
void TestRunner::closeIdleLocalStorageDatabases()
{
notImplemented();
}
......@@ -997,3 +997,7 @@ void TestRunner::setStorageDatabaseIdleInterval(double)
{
// FIXME: Implement this.
}
void TestRunner::closeIdleLocalStorageDatabases()
{
}
......@@ -213,6 +213,11 @@ void TestRunner::setStorageDatabaseIdleInterval(double interval)
[WebStorageManager setStorageDatabaseIdleInterval:interval];
}
void TestRunner::closeIdleLocalStorageDatabases()
{
[WebStorageManager closeIdleLocalStorageDatabases];
}
JSValueRef TestRunner::originsWithLocalStorage(JSContextRef context)
{
return originsArrayToJS(context, [[WebStorageManager sharedWebStorageManager] origins]);
......
......@@ -1445,3 +1445,8 @@ void TestRunner::setStorageDatabaseIdleInterval(double)
{
// FIXME: Implement this.
}
void TestRunner::closeIdleLocalStorageDatabases()
{
// FIXME: Implement this.
}
......@@ -617,3 +617,8 @@ void TestRunner::setStorageDatabaseIdleInterval(double)
{
// FIXME: Implement this.
}
void TestRunner::closeIdleLocalStorageDatabases()
{
// FIXME: Implement this.
}
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