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 : namespace_id_(dom_storage::kLocalStorageNamespaceId) { |
16 : namespace_id_(kLocalStorageNamespaceId) { | |
17 DCHECK(storage_type == DOM_STORAGE_LOCAL); | |
18 } | 16 } |
19 | 17 |
20 RendererWebStorageNamespaceImpl::RendererWebStorageNamespaceImpl( | 18 RendererWebStorageNamespaceImpl::RendererWebStorageNamespaceImpl( |
21 DOMStorageType storage_type, int64 namespace_id) | 19 int64 namespace_id) |
22 : namespace_id_(namespace_id) { | 20 : namespace_id_(namespace_id) { |
23 DCHECK(storage_type == DOM_STORAGE_SESSION); | 21 DCHECK_NE(dom_storage::kInvalidSessionStorageNamespaceId, namespace_id); |
24 } | 22 } |
25 | 23 |
26 RendererWebStorageNamespaceImpl::~RendererWebStorageNamespaceImpl() { | 24 RendererWebStorageNamespaceImpl::~RendererWebStorageNamespaceImpl() { |
27 } | 25 } |
28 | 26 |
29 WebStorageArea* RendererWebStorageNamespaceImpl::createStorageArea( | 27 WebStorageArea* RendererWebStorageNamespaceImpl::createStorageArea( |
30 const WebString& origin) { | 28 const WebString& origin) { |
31 // Ideally, we'd keep a hash map of origin to these objects. Unfortunately | 29 // Ideally, we'd keep a hash map of origin to these objects. Unfortunately |
32 // this doesn't seem practical because there's no good way to ref-count these | 30 // this doesn't seem practical because there's no good way to ref-count these |
33 // objects, and it'd be unclear who owned them. So, instead, we'll pay the | 31 // objects, and it'd be unclear who owned them. So, instead, we'll pay the |
34 // price in terms of wasted memory. | 32 // price in terms of wasted memory. |
35 return new RendererWebStorageAreaImpl(namespace_id_, origin); | 33 return new RendererWebStorageAreaImpl(namespace_id_, origin); |
36 } | 34 } |
37 | 35 |
38 WebStorageNamespace* RendererWebStorageNamespaceImpl::copy() { | 36 WebStorageNamespace* RendererWebStorageNamespaceImpl::copy() { |
39 // By returning NULL, we're telling WebKit to lazily fetch it the next time | 37 // By returning NULL, we're telling WebKit to lazily fetch it the next time |
40 // session storage is used. In the WebViewClient::createView, we do the | 38 // session storage is used. In the WebViewClient::createView, we do the |
41 // book-keeping necessary to make it a true copy-on-write despite not doing | 39 // book-keeping necessary to make it a true copy-on-write despite not doing |
42 // anything here, now. | 40 // anything here, now. |
43 return NULL; | 41 return NULL; |
44 } | 42 } |
45 | 43 |
46 void RendererWebStorageNamespaceImpl::close() { | 44 void RendererWebStorageNamespaceImpl::close() { |
47 // This is called only on LocalStorage namespaces when WebKit thinks its | 45 // TOOD(michaeln): remove this deprecated method. |
48 // shutting down. This has no impact on Chromium. | |
49 } | 46 } |
OLD | NEW |