OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/renderer_webstoragenamespace_impl.h" | 5 #include "content/renderer/renderer_webstoragenamespace_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/renderer/renderer_webstoragearea_impl.h" | 8 #include "content/renderer/renderer_webstoragearea_impl.h" |
9 | 9 |
10 using WebKit::WebStorageArea; | 10 using WebKit::WebStorageArea; |
11 using WebKit::WebStorageNamespace; | 11 using WebKit::WebStorageNamespace; |
12 using WebKit::WebString; | 12 using WebKit::WebString; |
13 | 13 |
14 RendererWebStorageNamespaceImpl::RendererWebStorageNamespaceImpl( | 14 RendererWebStorageNamespaceImpl::RendererWebStorageNamespaceImpl( |
15 DOMStorageType storage_type) | 15 DOMStorageType storage_type) |
16 : storage_type_(storage_type), | 16 : namespace_id_(kLocalStorageNamespaceId) { |
17 namespace_id_(kLocalStorageNamespaceId) { | |
18 DCHECK(storage_type == DOM_STORAGE_LOCAL); | 17 DCHECK(storage_type == DOM_STORAGE_LOCAL); |
19 } | 18 } |
20 | 19 |
21 RendererWebStorageNamespaceImpl::RendererWebStorageNamespaceImpl( | 20 RendererWebStorageNamespaceImpl::RendererWebStorageNamespaceImpl( |
22 DOMStorageType storage_type, int64 namespace_id) | 21 DOMStorageType storage_type, int64 namespace_id) |
23 : storage_type_(storage_type), | 22 : namespace_id_(namespace_id) { |
24 namespace_id_(namespace_id) { | |
25 DCHECK(storage_type == DOM_STORAGE_SESSION); | 23 DCHECK(storage_type == DOM_STORAGE_SESSION); |
26 } | 24 } |
27 | 25 |
28 RendererWebStorageNamespaceImpl::~RendererWebStorageNamespaceImpl() { | 26 RendererWebStorageNamespaceImpl::~RendererWebStorageNamespaceImpl() { |
29 } | 27 } |
30 | 28 |
31 WebStorageArea* RendererWebStorageNamespaceImpl::createStorageArea( | 29 WebStorageArea* RendererWebStorageNamespaceImpl::createStorageArea( |
32 const WebString& origin) { | 30 const WebString& origin) { |
33 // Ideally, we'd keep a hash map of origin to these objects. Unfortunately | 31 // Ideally, we'd keep a hash map of origin to these objects. Unfortunately |
34 // this doesn't seem practical because there's no good way to ref-count these | 32 // this doesn't seem practical because there's no good way to ref-count these |
35 // objects, and it'd be unclear who owned them. So, instead, we'll pay the | 33 // objects, and it'd be unclear who owned them. So, instead, we'll pay the |
36 // price in terms of wasted memory. | 34 // price in terms of wasted memory. |
37 return new RendererWebStorageAreaImpl(namespace_id_, origin); | 35 return new RendererWebStorageAreaImpl(namespace_id_, origin); |
38 } | 36 } |
39 | 37 |
40 WebStorageNamespace* RendererWebStorageNamespaceImpl::copy() { | 38 WebStorageNamespace* RendererWebStorageNamespaceImpl::copy() { |
41 // By returning NULL, we're telling WebKit to lazily fetch it the next time | 39 // By returning NULL, we're telling WebKit to lazily fetch it the next time |
42 // session storage is used. In the WebViewClient::createView, we do the | 40 // session storage is used. In the WebViewClient::createView, we do the |
43 // book-keeping necessary to make it a true copy-on-write despite not doing | 41 // book-keeping necessary to make it a true copy-on-write despite not doing |
44 // anything here, now. | 42 // anything here, now. |
45 return NULL; | 43 return NULL; |
46 } | 44 } |
47 | 45 |
48 void RendererWebStorageNamespaceImpl::close() { | 46 void RendererWebStorageNamespaceImpl::close() { |
49 // This is called only on LocalStorage namespaces when WebKit thinks its | 47 // This is called only on LocalStorage namespaces when WebKit thinks its |
50 // shutting down. This has no impact on Chromium. | 48 // shutting down. This has no impact on Chromium. |
51 } | 49 } |
OLD | NEW |