OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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_AREA_H_ | |
6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_AREA_H_ | |
7 #pragma once | |
8 | |
9 #include "base/hash_tables.h" | |
10 #include "base/memory/ref_counted.h" | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/nullable_string16.h" | |
13 #include "base/string16.h" | |
14 #include "content/common/dom_storage_common.h" | |
15 #include "googleurl/src/gurl.h" | |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageArea.h" | |
17 #include "webkit/dom_storage/dom_storage_types.h" | |
18 | |
19 #ifdef ENABLE_NEW_DOM_STORAGE_BACKEND | |
20 // This class is no longer applicable. | |
21 #else | |
22 | |
23 class DOMStorageNamespace; | |
24 // Only use on the WebKit thread. DOMStorageNamespace manages our registration | |
25 // with DOMStorageContext. | |
26 class DOMStorageArea { | |
27 public: | |
28 DOMStorageArea(const string16& origin, | |
29 int64 id, | |
30 DOMStorageNamespace* owner); | |
31 ~DOMStorageArea(); | |
32 | |
33 unsigned Length(); | |
34 NullableString16 Key(unsigned index); | |
35 NullableString16 GetItem(const string16& key); | |
36 NullableString16 SetItem( | |
37 const string16& key, const string16& value, | |
38 WebKit::WebStorageArea::Result* result); | |
39 NullableString16 RemoveItem(const string16& key); | |
40 bool Clear(); | |
41 void PurgeMemory(); | |
42 | |
43 int64 id() const { return id_; } | |
44 | |
45 DOMStorageNamespace* owner() const { return owner_; } | |
46 | |
47 private: | |
48 // Creates the underlying WebStorageArea on demand. | |
49 void CreateWebStorageAreaIfNecessary(); | |
50 | |
51 // The origin this storage area represents. | |
52 string16 origin_; | |
53 GURL origin_url_; | |
54 | |
55 // The storage area we wrap. | |
56 scoped_ptr<WebKit::WebStorageArea> storage_area_; | |
57 | |
58 // Our storage area id. Unique to our parent DOMStorageContext. | |
59 int64 id_; | |
60 | |
61 // The DOMStorageNamespace that owns us. | |
62 DOMStorageNamespace* owner_; | |
63 | |
64 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageArea); | |
65 }; | |
66 | |
67 #if defined(COMPILER_GCC) | |
68 #if defined(OS_ANDROID) | |
69 // Android stlport uses std namespace | |
70 namespace std { | |
71 #else | |
72 namespace __gnu_cxx { | |
73 #endif | |
74 | |
75 template<> | |
76 struct hash<DOMStorageArea*> { | |
77 std::size_t operator()(DOMStorageArea* const& p) const { | |
78 return reinterpret_cast<std::size_t>(p); | |
79 } | |
80 }; | |
81 | |
82 } // namespace __gnu_cxx | |
83 #endif | |
84 | |
85 #endif // ENABLE_NEW_DOM_STORAGE_BACKEND | |
86 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_AREA_H_ | |
87 | |
OLD | NEW |