OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_AREA_H_ | 5 #ifndef WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_ |
6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_AREA_H_ | 6 #define WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/hash_tables.h" | 9 #include "base/file_path.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/nullable_string16.h" | 11 #include "base/nullable_string16.h" |
13 #include "base/string16.h" | 12 #include "base/string16.h" |
14 #include "content/common/dom_storage_common.h" | |
15 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageArea.h" | 14 #include "webkit/dom_storage/dom_storage_task_runner.h" |
17 | 15 |
18 class DOMStorageNamespace; | 16 class FilePath; |
19 // Only use on the WebKit thread. DOMStorageNamespace manages our registration | 17 class GURL; |
20 // with DOMStorageContext. | 18 |
21 class DOMStorageArea { | 19 namespace dom_storage { |
20 | |
21 // Not thread-safe, should only be called on the | |
22 // background thread. | |
23 class DomStorageArea | |
24 : public base::RefCounted<DomStorageArea> { | |
25 | |
22 public: | 26 public: |
23 DOMStorageArea(const string16& origin, | 27 DomStorageArea(const GURL& origin, |
24 int64 id, | 28 int64 namespace_id, |
25 DOMStorageNamespace* owner); | 29 const FilePath& backing_file, |
26 ~DOMStorageArea(); | 30 DomStorageTaskRunner* task_runner); |
27 | 31 |
28 unsigned Length(); | 32 const GURL& origin() const { return origin_; } |
29 NullableString16 Key(unsigned index); | 33 const int64 namespace_id() { return namespace_id_; } |
34 | |
35 int Length(); | |
benm (inactive)
2012/01/31 18:03:38
I used unsigned here, wdyt? (also for Key below)
michaeln
2012/01/31 21:17:45
k... lets switch to unsigned so we retain the data
| |
36 NullableString16 Key(int index); | |
30 NullableString16 GetItem(const string16& key); | 37 NullableString16 GetItem(const string16& key); |
31 NullableString16 SetItem( | 38 bool SetItem( |
32 const string16& key, const string16& value, | 39 const string16& key, const string16& value, |
33 WebKit::WebStorageArea::Result* result); | 40 NullableString16* old_value); |
34 NullableString16 RemoveItem(const string16& key); | 41 bool RemoveItem( |
42 const string16& key, | |
43 string16* old_value); | |
35 bool Clear(); | 44 bool Clear(); |
45 | |
36 void PurgeMemory(); | 46 void PurgeMemory(); |
37 | 47 |
38 int64 id() const { return id_; } | 48 void SyncChanges(); |
benm (inactive)
2012/01/31 18:03:38
SyncChangesToBacking?
michaeln
2012/01/31 21:17:45
'sync' can imply reading and writing, but really t
| |
39 | |
40 DOMStorageNamespace* owner() const { return owner_; } | |
41 | 49 |
42 private: | 50 private: |
43 // Creates the underlying WebStorageArea on demand. | 51 friend class base::RefCounted<DomStorageArea>; |
44 void CreateWebStorageAreaIfNecessary(); | |
45 | 52 |
46 // The origin this storage area represents. | 53 ~DomStorageArea(); |
47 string16 origin_; | |
48 GURL origin_url_; | |
49 | 54 |
50 // The storage area we wrap. | 55 int64 namespace_id_; |
51 scoped_ptr<WebKit::WebStorageArea> storage_area_; | 56 GURL origin_; |
52 | 57 FilePath backing_fail_path_; |
benm (inactive)
2012/01/31 18:03:38
file :)
| |
53 // Our storage area id. Unique to our parent WebKitContext. | 58 scoped_refptr<DomStorageTaskRunner> task_runner_; |
54 int64 id_; | |
55 | |
56 // The DOMStorageNamespace that owns us. | |
57 DOMStorageNamespace* owner_; | |
58 | |
59 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageArea); | |
60 }; | 59 }; |
61 | 60 |
62 #if defined(COMPILER_GCC) | 61 } // namespace dom_storage |
63 namespace __gnu_cxx { | |
64 | 62 |
65 template<> | 63 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_AREA_H_ |
66 struct hash<DOMStorageArea*> { | |
67 std::size_t operator()(DOMStorageArea* const& p) const { | |
68 return reinterpret_cast<std::size_t>(p); | |
69 } | |
70 }; | |
71 | |
72 } // namespace __gnu_cxx | |
73 #endif | |
74 | |
75 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_AREA_H_ | |
OLD | NEW |