summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-03 06:51:15 +0000
committerjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-03 06:51:15 +0000
commit75c91e64b82abaa843d9327f7b57cc9a0abe1696 (patch)
tree28e9093690edc475c7a7d69b21a90facef3d2641
parent8922e1ff7ac33a3f88079e1e6d3ae8671602a952 (diff)
downloadchromium_src-75c91e64b82abaa843d9327f7b57cc9a0abe1696.zip
chromium_src-75c91e64b82abaa843d9327f7b57cc9a0abe1696.tar.gz
chromium_src-75c91e64b82abaa843d9327f7b57cc9a0abe1696.tar.bz2
Add quota support.
Add a 5mb quota to DOM Storage. Most of the details are in an upstream patch (https://bugs.webkit.org/show_bug.cgi?id=29991 ). BUG=16876 TEST=I added a layout test upstream and it works. Review URL: http://codereview.chromium.org/255050 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27942 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc11
-rw-r--r--chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h2
-rw-r--r--chrome/browser/in_process_webkit/storage_namespace.cc3
-rw-r--r--chrome/browser/in_process_webkit/storage_namespace.h3
-rw-r--r--chrome/common/render_messages_internal.h9
-rw-r--r--chrome/renderer/renderer_webkitclient_impl.cc5
-rw-r--r--chrome/renderer/renderer_webkitclient_impl.h2
-rw-r--r--chrome/renderer/renderer_webstoragearea_impl.cc3
-rw-r--r--chrome/worker/worker_webkitclient_impl.cc13
-rw-r--r--chrome/worker/worker_webkitclient_impl.h3
-rw-r--r--webkit/api/public/WebKitClient.h6
-rw-r--r--webkit/api/public/WebStorageNamespace.h4
-rw-r--r--webkit/api/src/StorageNamespaceProxy.cpp2
-rw-r--r--webkit/api/src/WebStorageNamespaceImpl.cpp5
-rw-r--r--webkit/glue/webkitclient_impl.cc13
-rw-r--r--webkit/glue/webkitclient_impl.h9
-rw-r--r--webkit/tools/layout_tests/test_expectations.txt3
-rw-r--r--webkit/tools/test_shell/test_shell_webkit_init.h5
18 files changed, 53 insertions, 48 deletions
diff --git a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc
index ac39acb..1e144ce 100644
--- a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc
+++ b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc
@@ -79,7 +79,7 @@ bool DOMStorageDispatcherHost::OnMessageReceived(
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_DOMStorageLength, OnLength)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_DOMStorageKey, OnKey)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_DOMStorageGetItem, OnGetItem)
- IPC_MESSAGE_HANDLER(ViewHostMsg_DOMStorageSetItem, OnSetItem)
+ IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_DOMStorageSetItem, OnSetItem)
IPC_MESSAGE_HANDLER(ViewHostMsg_DOMStorageRemoveItem, OnRemoveItem)
IPC_MESSAGE_HANDLER(ViewHostMsg_DOMStorageClear, OnClear)
IPC_MESSAGE_UNHANDLED(handled = false)
@@ -254,13 +254,13 @@ void DOMStorageDispatcherHost::OnGetItem(int64 storage_area_id,
}
void DOMStorageDispatcherHost::OnSetItem(int64 storage_area_id,
- const string16& key,
- const string16& value) {
+ const string16& key, const string16& value, IPC::Message* reply_msg) {
DCHECK(!shutdown_);
if (ChromeThread::CurrentlyOn(ChromeThread::IO)) {
MessageLoop* webkit_loop = webkit_thread_->GetMessageLoop();
webkit_loop->PostTask(FROM_HERE, NewRunnableMethod(this,
- &DOMStorageDispatcherHost::OnSetItem, storage_area_id, key, value));
+ &DOMStorageDispatcherHost::OnSetItem, storage_area_id, key, value,
+ reply_msg));
return;
}
@@ -273,7 +273,8 @@ void DOMStorageDispatcherHost::OnSetItem(int64 storage_area_id,
return;
}
storage_area->SetItem(key, value, &quota_exception);
- DCHECK(!quota_exception); // This is tracked by the renderer.
+ ViewHostMsg_DOMStorageSetItem::WriteReplyParams(reply_msg, quota_exception);
+ Send(reply_msg);
}
void DOMStorageDispatcherHost::OnRemoveItem(int64 storage_area_id,
diff --git a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h
index a0d3d77..2e6ee96 100644
--- a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h
+++ b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h
@@ -51,7 +51,7 @@ class DOMStorageDispatcherHost :
void OnGetItem(int64 storage_area_id, const string16& key,
IPC::Message* reply_msg);
void OnSetItem(int64 storage_area_id, const string16& key,
- const string16& value);
+ const string16& value, IPC::Message* reply_msg);
void OnRemoveItem(int64 storage_area_id, const string16& key);
void OnClear(int64 storage_area_id);
diff --git a/chrome/browser/in_process_webkit/storage_namespace.cc b/chrome/browser/in_process_webkit/storage_namespace.cc
index fa2c74a..6629f22 100644
--- a/chrome/browser/in_process_webkit/storage_namespace.cc
+++ b/chrome/browser/in_process_webkit/storage_namespace.cc
@@ -24,7 +24,8 @@ StorageNamespace* StorageNamespace::CreateLocalStorageNamespace(
DCHECK(!dom_storage_context->GetStorageNamespace(id));
WebString path = webkit_glue::FilePathToWebString(dir_path);
WebStorageNamespace* web_storage_namespace =
- WebStorageNamespace::createLocalStorageNamespace(path);
+ WebStorageNamespace::createLocalStorageNamespace(path,
+ kLocalStorageQuota);
return new StorageNamespace(dom_storage_context, web_storage_namespace, id,
DOM_STORAGE_LOCAL);
}
diff --git a/chrome/browser/in_process_webkit/storage_namespace.h b/chrome/browser/in_process_webkit/storage_namespace.h
index 91e0ae6..712dd41 100644
--- a/chrome/browser/in_process_webkit/storage_namespace.h
+++ b/chrome/browser/in_process_webkit/storage_namespace.h
@@ -55,6 +55,9 @@ class StorageNamespace {
// SessionStorage vs. LocalStorage.
const DOMStorageType storage_type_;
+ // The quota for each storage area. Suggested by the spec.
+ static const unsigned kLocalStorageQuota = 5 * 1024 * 1024;
+
DISALLOW_IMPLICIT_CONSTRUCTORS(StorageNamespace);
};
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index ad27705..9ff073c 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -1707,10 +1707,11 @@ IPC_BEGIN_MESSAGES(ViewHost)
NullableString16 /* value */)
// Set a value that's associated with a key in a storage area.
- IPC_MESSAGE_CONTROL3(ViewHostMsg_DOMStorageSetItem,
- int64 /* storage_area_id */,
- string16 /* key */,
- string16 /* value */)
+ IPC_SYNC_MESSAGE_CONTROL3_1(ViewHostMsg_DOMStorageSetItem,
+ int64 /* storage_area_id */,
+ string16 /* key */,
+ string16 /* value */,
+ bool /* quota_exception */)
// Remove the value associated with a key in a storage area.
IPC_MESSAGE_CONTROL2(ViewHostMsg_DOMStorageRemoveItem,
diff --git a/chrome/renderer/renderer_webkitclient_impl.cc b/chrome/renderer/renderer_webkitclient_impl.cc
index 545da3a..69db1df 100644
--- a/chrome/renderer/renderer_webkitclient_impl.cc
+++ b/chrome/renderer/renderer_webkitclient_impl.cc
@@ -152,10 +152,9 @@ void RendererWebKitClientImpl::suddenTerminationChanged(bool enabled) {
}
WebStorageNamespace* RendererWebKitClientImpl::createLocalStorageNamespace(
- const WebString& path) {
+ const WebString& path, unsigned quota) {
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess))
- return WebStorageNamespace::createLocalStorageNamespace(path);
- // The browser process decides the path, so ignore that param.
+ return WebStorageNamespace::createLocalStorageNamespace(path, quota);
return new RendererWebStorageNamespaceImpl(DOM_STORAGE_LOCAL);
}
diff --git a/chrome/renderer/renderer_webkitclient_impl.h b/chrome/renderer/renderer_webkitclient_impl.h
index 759d90e..d9b7fc3 100644
--- a/chrome/renderer/renderer_webkitclient_impl.h
+++ b/chrome/renderer/renderer_webkitclient_impl.h
@@ -42,7 +42,7 @@ class RendererWebKitClientImpl : public webkit_glue::WebKitClientImpl {
virtual WebKit::WebString defaultLocale();
virtual void suddenTerminationChanged(bool enabled);
virtual WebKit::WebStorageNamespace* createLocalStorageNamespace(
- const WebKit::WebString& path);
+ const WebKit::WebString& path, unsigned quota);
virtual WebKit::WebStorageNamespace* createSessionStorageNamespace();
virtual WebKit::WebKitClient::FileHandle databaseOpenFile(
diff --git a/chrome/renderer/renderer_webstoragearea_impl.cc b/chrome/renderer/renderer_webstoragearea_impl.cc
index b03396d..417e949 100644
--- a/chrome/renderer/renderer_webstoragearea_impl.cc
+++ b/chrome/renderer/renderer_webstoragearea_impl.cc
@@ -44,7 +44,8 @@ void RendererWebStorageAreaImpl::setItem(const WebString& key,
const WebString& value,
bool& quota_exception) {
RenderThread::current()->Send(
- new ViewHostMsg_DOMStorageSetItem(storage_area_id_, key, value));
+ new ViewHostMsg_DOMStorageSetItem(storage_area_id_, key, value,
+ &quota_exception));
}
void RendererWebStorageAreaImpl::removeItem(const WebString& key) {
diff --git a/chrome/worker/worker_webkitclient_impl.cc b/chrome/worker/worker_webkitclient_impl.cc
index aa2fb57..2d60954 100644
--- a/chrome/worker/worker_webkitclient_impl.cc
+++ b/chrome/worker/worker_webkitclient_impl.cc
@@ -74,16 +74,3 @@ WebKit::WebString WorkerWebKitClientImpl::defaultLocale() {
NOTREACHED();
return WebKit::WebString();
}
-
-WebKit::WebStorageNamespace*
-WorkerWebKitClientImpl::createLocalStorageNamespace(
- const WebKit::WebString& path) {
- NOTREACHED();
- return 0;
-}
-
-WebKit::WebStorageNamespace*
-WorkerWebKitClientImpl::createSessionStorageNamespace() {
- NOTREACHED();
- return 0;
-}
diff --git a/chrome/worker/worker_webkitclient_impl.h b/chrome/worker/worker_webkitclient_impl.h
index 673bfc6..a9ccb36 100644
--- a/chrome/worker/worker_webkitclient_impl.h
+++ b/chrome/worker/worker_webkitclient_impl.h
@@ -26,9 +26,6 @@ class WorkerWebKitClientImpl : public webkit_glue::WebKitClientImpl {
virtual void prefetchHostName(const WebKit::WebString&);
virtual bool getFileSize(const WebKit::WebString& path, long long& result);
virtual WebKit::WebString defaultLocale();
- virtual WebKit::WebStorageNamespace* createLocalStorageNamespace(
- const WebKit::WebString& path);
- virtual WebKit::WebStorageNamespace* createSessionStorageNamespace();
};
#endif // CHROME_WORKER_WORKER_WEBKIT_CLIENT_IMPL_H_
diff --git a/webkit/api/public/WebKitClient.h b/webkit/api/public/WebKitClient.h
index 32bd4c70..0e380048 100644
--- a/webkit/api/public/WebKitClient.h
+++ b/webkit/api/public/WebKitClient.h
@@ -83,10 +83,8 @@ namespace WebKit {
// DOM Storage --------------------------------------------------
- // Return a LocalStorage namespace that corresponds to the following
- // path.
- virtual WebStorageNamespace* createLocalStorageNamespace(
- const WebString& path) = 0;
+ // Return a LocalStorage namespace that corresponds to the following path.
+ virtual WebStorageNamespace* createLocalStorageNamespace(const WebString& path, unsigned quota) = 0;
// Return a new SessionStorage namespace.
virtual WebStorageNamespace* createSessionStorageNamespace() = 0;
diff --git a/webkit/api/public/WebStorageNamespace.h b/webkit/api/public/WebStorageNamespace.h
index 362e41e1..1253cec 100644
--- a/webkit/api/public/WebStorageNamespace.h
+++ b/webkit/api/public/WebStorageNamespace.h
@@ -46,9 +46,11 @@ namespace WebKit {
// where the SQLite databases that make LocalStorage data persistent are located.
// If path is empty, data will not persist. You should call delete on the returned
// object when you're finished.
- WEBKIT_API static WebStorageNamespace* createLocalStorageNamespace(const WebString& backingDirectoryPath);
+ WEBKIT_API static WebStorageNamespace* createLocalStorageNamespace(const WebString& backingDirectoryPath, unsigned quota);
WEBKIT_API static WebStorageNamespace* createSessionStorageNamespace();
+ static const unsigned noQuota = UINT_MAX;
+
virtual ~WebStorageNamespace() { }
// Create a new WebStorageArea object. Two subsequent calls with the same origin
diff --git a/webkit/api/src/StorageNamespaceProxy.cpp b/webkit/api/src/StorageNamespaceProxy.cpp
index 8b44f6e..e22bbef 100644
--- a/webkit/api/src/StorageNamespaceProxy.cpp
+++ b/webkit/api/src/StorageNamespaceProxy.cpp
@@ -39,7 +39,7 @@ namespace WebCore {
PassRefPtr<StorageNamespace> StorageNamespace::localStorageNamespace(const String& path, unsigned quota)
{
- return new StorageNamespaceProxy(WebKit::webKitClient()->createLocalStorageNamespace(path));
+ return new StorageNamespaceProxy(WebKit::webKitClient()->createLocalStorageNamespace(path, quota));
}
PassRefPtr<StorageNamespace> StorageNamespace::sessionStorageNamespace()
diff --git a/webkit/api/src/WebStorageNamespaceImpl.cpp b/webkit/api/src/WebStorageNamespaceImpl.cpp
index 6754d18..11d2cf3 100644
--- a/webkit/api/src/WebStorageNamespaceImpl.cpp
+++ b/webkit/api/src/WebStorageNamespaceImpl.cpp
@@ -34,16 +34,15 @@
#if ENABLE(DOM_STORAGE)
#include "SecurityOrigin.h"
-#include "StorageMap.h"
#include "WebStorageAreaImpl.h"
#include "WebString.h"
namespace WebKit {
-WebStorageNamespace* WebStorageNamespace::createLocalStorageNamespace(const WebString& path)
+WebStorageNamespace* WebStorageNamespace::createLocalStorageNamespace(const WebString& path, unsigned quota)
{
- return new WebStorageNamespaceImpl(WebCore::StorageNamespaceImpl::localStorageNamespace(path, WebCore::StorageMap::noQuota));
+ return new WebStorageNamespaceImpl(WebCore::StorageNamespaceImpl::localStorageNamespace(path, quota));
}
WebStorageNamespace* WebStorageNamespace::createSessionStorageNamespace()
diff --git a/webkit/glue/webkitclient_impl.cc b/webkit/glue/webkitclient_impl.cc
index 34c7ba5..ed7efa1 100644
--- a/webkit/glue/webkitclient_impl.cc
+++ b/webkit/glue/webkitclient_impl.cc
@@ -42,6 +42,7 @@ using WebKit::WebCursorInfo;
using WebKit::WebData;
using WebKit::WebLocalizedString;
using WebKit::WebPluginListBuilder;
+using WebKit::WebStorageNamespace;
using WebKit::WebString;
using WebKit::WebThemeEngine;
using WebKit::WebURLLoader;
@@ -464,6 +465,17 @@ WebCore::WorkerContextProxy* WebKitClientImpl::createWorkerContextProxy(
return WebWorkerClientImpl::createWorkerContextProxy(worker);
}
+WebStorageNamespace* WebKitClientImpl::createLocalStorageNamespace(
+ const WebString& path, unsigned quota) {
+ NOTREACHED();
+ return 0;
+}
+
+WebStorageNamespace* WebKitClientImpl::createSessionStorageNamespace() {
+ NOTREACHED();
+ return 0;
+}
+
WebKit::WebString WebKitClientImpl::getAbsolutePath(
const WebKit::WebString& path) {
FilePath file_path(webkit_glue::WebStringToFilePathString(path));
@@ -481,4 +493,5 @@ WebKit::WebURL WebKitClientImpl::filePathToURL(const WebKit::WebString& path) {
GURL file_url = net::FilePathToFileURL(file_path);
return webkit_glue::KURLToWebURL(webkit_glue::GURLToKURL(file_url));
}
+
} // namespace webkit_glue
diff --git a/webkit/glue/webkitclient_impl.h b/webkit/glue/webkitclient_impl.h
index ba25918..d10f8d4 100644
--- a/webkit/glue/webkitclient_impl.h
+++ b/webkit/glue/webkitclient_impl.h
@@ -70,7 +70,8 @@ class WebKitClientImpl : public WebKit::WebKitClient {
// these methods will be deleted.
virtual WebKit::WebMediaPlayer* createWebMediaPlayer(
WebKit::WebMediaPlayerClient*, WebCore::Frame*);
- virtual void setCursorForPlugin(const WebKit::WebCursorInfo&, WebCore::Frame*);
+ virtual void setCursorForPlugin(
+ const WebKit::WebCursorInfo&, WebCore::Frame*);
virtual WebCore::String uiResourceProtocol();
virtual void notifyJSOutOfMemory(WebCore::Frame*);
virtual int screenDepth(WebCore::Widget*);
@@ -81,7 +82,11 @@ class WebKitClientImpl : public WebKit::WebKitClient {
virtual bool popupsAllowed(NPP);
virtual void widgetSetCursor(WebCore::Widget*, const WebCore::Cursor&);
virtual void widgetSetFocus(WebCore::Widget*);
- virtual WebCore::WorkerContextProxy* createWorkerContextProxy(WebCore::Worker* worker);
+ virtual WebCore::WorkerContextProxy* createWorkerContextProxy(
+ WebCore::Worker* worker);
+ virtual WebKit::WebStorageNamespace* createLocalStorageNamespace(
+ const WebKit::WebString& path, unsigned quota);
+ virtual WebKit::WebStorageNamespace* createSessionStorageNamespace();
private:
void DoTimeout() {
diff --git a/webkit/tools/layout_tests/test_expectations.txt b/webkit/tools/layout_tests/test_expectations.txt
index 66491cf..d17c220 100644
--- a/webkit/tools/layout_tests/test_expectations.txt
+++ b/webkit/tools/layout_tests/test_expectations.txt
@@ -638,9 +638,6 @@ BUG21118 WIN LINUX : LayoutTests/fast/forms/box-shadow-override.html = FAIL
// I'm marking them as deferred for now, but we should do something with them.
BUG849072 SKIP : chrome/http/mime = PASS
-// Disable quota test for now.
-BUG16876 : LayoutTests/storage/domstorage/localstorage/quota.html = FAIL
-
// These tests all depend on DOM Storage events which are not yet supported.
BUG4360 : LayoutTests/storage/domstorage/window-attributes-exist.html = FAIL
BUG4360 : LayoutTests/storage/domstorage/localstorage/iframe-events.html = TIMEOUT
diff --git a/webkit/tools/test_shell/test_shell_webkit_init.h b/webkit/tools/test_shell/test_shell_webkit_init.h
index 15f69d4..de5b26f 100644
--- a/webkit/tools/test_shell/test_shell_webkit_init.h
+++ b/webkit/tools/test_shell/test_shell_webkit_init.h
@@ -181,8 +181,9 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl {
}
virtual WebKit::WebStorageNamespace* createLocalStorageNamespace(
- const WebKit::WebString& path) {
- return WebKit::WebStorageNamespace::createLocalStorageNamespace(path);
+ const WebKit::WebString& path, unsigned quota) {
+ return WebKit::WebStorageNamespace::createLocalStorageNamespace(path,
+ quota);
}
virtual WebKit::WebStorageNamespace* createSessionStorageNamespace() {