summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/renderer_webstoragenamespace_impl.cc
diff options
context:
space:
mode:
authorjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-24 01:22:51 +0000
committerjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-24 01:22:51 +0000
commit2a10f681c582df15719956061b6742a55bccb46a (patch)
tree4e4ee689cafbecb9b211f437f478b7588f6c05c2 /chrome/renderer/renderer_webstoragenamespace_impl.cc
parent4f9b2a7e42fc567073f4999a888b3140bec460bb (diff)
downloadchromium_src-2a10f681c582df15719956061b6742a55bccb46a.zip
chromium_src-2a10f681c582df15719956061b6742a55bccb46a.tar.gz
chromium_src-2a10f681c582df15719956061b6742a55bccb46a.tar.bz2
The final CL for plumbing DOM Storage.
Add webKitClient plumbing for getting/creating storage namespaces. Add a chromium implementation for WebStorageArea and WebStorageNamespace which communicates via IPC with the dom_storage_dispatcher_host in the browser process. Flesh out the StorageAreaProxy and StorageNamespaceProxy to use the aforementioned implementations. The WebStorageArea implementation includes decently aggressive caching optimizations. There's still a lot of work to do, though. BUG=4360 TEST=none Review URL: http://codereview.chromium.org/147248 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21495 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/renderer_webstoragenamespace_impl.cc')
-rw-r--r--chrome/renderer/renderer_webstoragenamespace_impl.cc65
1 files changed, 65 insertions, 0 deletions
diff --git a/chrome/renderer/renderer_webstoragenamespace_impl.cc b/chrome/renderer/renderer_webstoragenamespace_impl.cc
new file mode 100644
index 0000000..453bbcf
--- /dev/null
+++ b/chrome/renderer/renderer_webstoragenamespace_impl.cc
@@ -0,0 +1,65 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
+// source code is governed by a BSD-style license that can be found in the
+// LICENSE file.
+
+#include "chrome/renderer/renderer_webstoragenamespace_impl.h"
+
+#include "chrome/common/render_messages.h"
+#include "chrome/renderer/render_thread.h"
+#include "chrome/renderer/renderer_webstoragearea_impl.h"
+
+RendererWebStorageNamespaceImpl::RendererWebStorageNamespaceImpl(
+ bool is_local_storage)
+ : is_local_storage_(is_local_storage),
+ namespace_id_(kUninitializedNamespaceId) {
+}
+
+RendererWebStorageNamespaceImpl::RendererWebStorageNamespaceImpl(
+ bool is_local_storage, int64 namespace_id)
+ : is_local_storage_(is_local_storage),
+ namespace_id_(namespace_id) {
+ DCHECK(namespace_id_ != kUninitializedNamespaceId);
+}
+
+RendererWebStorageNamespaceImpl::~RendererWebStorageNamespaceImpl() {
+ if (namespace_id_ != kUninitializedNamespaceId)
+ RenderThread::current()->Send(
+ new ViewHostMsg_DOMStorageDerefNamespaceId(namespace_id_));
+}
+
+WebKit::WebStorageArea* RendererWebStorageNamespaceImpl::createStorageArea(
+ const WebKit::WebString& origin) {
+ // This could be done async in the background (started when this class is
+ // first instantiated) rather than lazily on first use, but it's unclear
+ // whether it's worth the complexity.
+ if (namespace_id_ == kUninitializedNamespaceId) {
+ RenderThread::current()->Send(
+ new ViewHostMsg_DOMStorageNamespaceId(is_local_storage_,
+ &namespace_id_));
+ DCHECK(namespace_id_ != kUninitializedNamespaceId);
+ }
+ // Ideally, we'd keep a hash map of origin to these objects. Unfortunately
+ // this doesn't seem practical because there's no good way to ref-count these
+ // objects, and it'd be unclear who owned them. So, instead, we'll pay a
+ // price for an allocaiton and IPC for each.
+ return new RendererWebStorageAreaImpl(namespace_id_, origin);
+}
+
+WebKit::WebStorageNamespace* RendererWebStorageNamespaceImpl::copy() {
+ // If we haven't been used yet, we might as well start out fresh (and lazy).
+ if (namespace_id_ == kUninitializedNamespaceId)
+ return new RendererWebStorageNamespaceImpl(is_local_storage_);
+
+ // This cannot easily be differed because we need a snapshot in time.
+ int64 new_namespace_id;
+ RenderThread::current()->Send(
+ new ViewHostMsg_DOMStorageCloneNamespaceId(namespace_id_,
+ &new_namespace_id));
+ return new RendererWebStorageNamespaceImpl(is_local_storage_,
+ new_namespace_id);
+}
+
+void RendererWebStorageNamespaceImpl::close() {
+ // This is called only on LocalStorage namespaces when WebKit thinks its
+ // shutting down. This has no impact on Chromium.
+}