Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: chrome/renderer/renderer_webstoragenamespace_impl.cc

Issue 147248: DOM Storage: Add renderer-process IPC code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file.
4
5 #include "chrome/renderer/renderer_webstoragenamespace_impl.h"
6
7 #include "chrome/common/render_messages.h"
8 #include "chrome/renderer/render_thread.h"
9 #include "chrome/renderer/renderer_webstoragearea_impl.h"
10
11 RendererWebStorageNamespaceImpl::RendererWebStorageNamespaceImpl(
12 bool is_local_storage)
13 : is_local_storage_(is_local_storage),
14 namespace_id_(kUninitializedNamespaceId) {
15 }
16
17 RendererWebStorageNamespaceImpl::RendererWebStorageNamespaceImpl(
18 bool is_local_storage, int64 namespace_id)
19 : is_local_storage_(is_local_storage),
20 namespace_id_(namespace_id) {
21 DCHECK(namespace_id_ != kUninitializedNamespaceId);
22 }
23
24 RendererWebStorageNamespaceImpl::~RendererWebStorageNamespaceImpl() {
25 if (namespace_id_ != kUninitializedNamespaceId)
26 RenderThread::current()->Send(
27 new ViewHostMsg_DOMStorageDerefNamespaceId(namespace_id_));
28 }
29
30 WebKit::WebStorageArea* RendererWebStorageNamespaceImpl::createStorageArea(
31 const WebKit::WebString& origin) {
32 // This could be done async in the background (started when this class is
33 // first instantiated) rather than lazily on first use, but it's unclear
34 // whether it's worth the complexity.
35 if (namespace_id_ == kUninitializedNamespaceId) {
36 RenderThread::current()->Send(
37 new ViewHostMsg_DOMStorageNamespaceId(is_local_storage_,
38 &namespace_id_));
39 DCHECK(namespace_id_ != kUninitializedNamespaceId);
40 }
41 // Ideally, we'd keep a hash map of origin to these objects. Unfortunately
42 // this doesn't seem practical because there's no good way to ref-count these
43 // objects, and it'd be unclear who owned them. So, instead, we'll pay a
44 // price for an allocaiton and IPC for each.
45 return new RendererWebStorageAreaImpl(namespace_id_, origin);
46 }
47
48 WebKit::WebStorageNamespace* RendererWebStorageNamespaceImpl::copy() {
49 // If we haven't been used yet, we might as well start out fresh (and lazy).
50 if (namespace_id_ == kUninitializedNamespaceId)
51 return new RendererWebStorageNamespaceImpl(is_local_storage_);
52
53 // This cannot easily be differed because we need a snapshot in time.
54 int64 new_namespace_id;
55 RenderThread::current()->Send(
56 new ViewHostMsg_DOMStorageCloneNamespaceId(namespace_id_,
57 &new_namespace_id));
58 return new RendererWebStorageNamespaceImpl(is_local_storage_,
59 new_namespace_id);
60 }
61
62 void RendererWebStorageNamespaceImpl::close() {
63 // This is called only on LocalStorage namespaces when WebKit thinks its
64 // shutting down. This has no impact on Chromium.
65 }
OLDNEW
« no previous file with comments | « chrome/renderer/renderer_webstoragenamespace_impl.h ('k') | chrome/worker/worker_webkitclient_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698