diff options
author | jorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-03 06:51:15 +0000 |
---|---|---|
committer | jorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-03 06:51:15 +0000 |
commit | 75c91e64b82abaa843d9327f7b57cc9a0abe1696 (patch) | |
tree | 28e9093690edc475c7a7d69b21a90facef3d2641 /chrome | |
parent | 8922e1ff7ac33a3f88079e1e6d3ae8671602a952 (diff) | |
download | chromium_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
Diffstat (limited to 'chrome')
10 files changed, 22 insertions, 32 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, "a_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, + "a_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_ |