OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_NAMESPACE_H_ | |
6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_NAMESPACE_H_ | |
7 #pragma once | |
8 | |
9 #include "base/hash_tables.h" | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/string16.h" | |
12 #include "content/common/dom_storage_common.h" | |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | |
14 #include "webkit/dom_storage/dom_storage_types.h" | |
15 | |
16 #ifdef ENABLE_NEW_DOM_STORAGE_BACKEND | |
17 // This class is no longer applicable. | |
18 #else | |
19 | |
20 class DOMStorageArea; | |
21 class DOMStorageContextImpl; | |
22 class FilePath; | |
23 | |
24 namespace WebKit { | |
25 class WebStorageArea; | |
26 class WebStorageNamespace; | |
27 } | |
28 | |
29 // Only to be used on the WebKit thread. | |
30 class DOMStorageNamespace { | |
31 public: | |
32 static DOMStorageNamespace* CreateLocalStorageNamespace( | |
33 DOMStorageContextImpl* dom_storage_context, | |
34 const FilePath& data_dir_path); | |
35 static DOMStorageNamespace* CreateSessionStorageNamespace( | |
36 DOMStorageContextImpl* dom_storage_context, int64 namespace_id); | |
37 | |
38 ~DOMStorageNamespace(); | |
39 | |
40 DOMStorageArea* GetStorageArea(const string16& origin); | |
41 DOMStorageNamespace* Copy(int64 clone_namespace_id); | |
42 | |
43 void PurgeMemory(); | |
44 | |
45 const DOMStorageContextImpl* dom_storage_context() const { | |
46 return dom_storage_context_; | |
47 } | |
48 int64 id() const { return id_; } | |
49 const WebKit::WebString& data_dir_path() const { return data_dir_path_; } | |
50 DOMStorageType dom_storage_type() const { return dom_storage_type_; } | |
51 | |
52 // Creates a WebStorageArea for the given origin. This should only be called | |
53 // by an owned DOMStorageArea. | |
54 WebKit::WebStorageArea* CreateWebStorageArea(const string16& origin); | |
55 | |
56 private: | |
57 // Called by the static factory methods above. | |
58 DOMStorageNamespace(DOMStorageContextImpl* dom_storage_context, | |
59 int64 id, | |
60 const WebKit::WebString& data_dir_path, | |
61 DOMStorageType storage_type); | |
62 | |
63 // Creates the underlying WebStorageNamespace on demand. | |
64 void CreateWebStorageNamespaceIfNecessary(); | |
65 | |
66 // All the storage areas we own. | |
67 typedef base::hash_map<string16, DOMStorageArea*> OriginToStorageAreaMap; | |
68 OriginToStorageAreaMap origin_to_storage_area_; | |
69 | |
70 // The DOMStorageContext that owns us. | |
71 DOMStorageContextImpl* dom_storage_context_; | |
72 | |
73 // The WebKit storage namespace we manage. | |
74 scoped_ptr<WebKit::WebStorageNamespace> storage_namespace_; | |
75 | |
76 // Our id. Unique to our parent DOMStorageContext class. | |
77 int64 id_; | |
78 | |
79 // The path used to create us, so we can recreate our WebStorageNamespace on | |
80 // demand. | |
81 WebKit::WebString data_dir_path_; | |
82 | |
83 // SessionStorage vs. LocalStorage. | |
84 const DOMStorageType dom_storage_type_; | |
85 | |
86 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageNamespace); | |
87 }; | |
88 | |
89 #endif // ENABLE_NEW_DOM_STORAGE_BACKEND | |
90 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_NAMESPACE_H_ | |
91 | |
OLD | NEW |