OLD | NEW |
1 // Copyright (c) 2012 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_RENDERER_DOM_STORAGE_DOM_STORAGE_CACHED_AREA_H_ | 5 #ifndef CONTENT_RENDERER_DOM_STORAGE_DOM_STORAGE_CACHED_AREA_H_ |
6 #define CONTENT_RENDERER_DOM_STORAGE_DOM_STORAGE_CACHED_AREA_H_ | 6 #define CONTENT_RENDERER_DOM_STORAGE_DOM_STORAGE_CACHED_AREA_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <map> | 10 #include <map> |
9 | 11 |
10 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
11 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
12 #include "base/strings/nullable_string16.h" | 14 #include "base/strings/nullable_string16.h" |
13 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
14 #include "url/gurl.h" | 16 #include "url/gurl.h" |
15 | 17 |
16 namespace content { | 18 namespace content { |
17 | 19 |
18 class DOMStorageMap; | 20 class DOMStorageMap; |
19 class DOMStorageProxy; | 21 class DOMStorageProxy; |
20 | 22 |
21 // Unlike the other classes in the dom_storage library, this one is intended | 23 // Unlike the other classes in the dom_storage library, this one is intended |
22 // for use in renderer processes. It maintains a complete cache of the | 24 // for use in renderer processes. It maintains a complete cache of the |
23 // origin's Map of key/value pairs for fast access. The cache is primed on | 25 // origin's Map of key/value pairs for fast access. The cache is primed on |
24 // first access and changes are written to the backend thru the |proxy|. | 26 // first access and changes are written to the backend thru the |proxy|. |
25 // Mutations originating in other processes are applied to the cache via | 27 // Mutations originating in other processes are applied to the cache via |
26 // the ApplyMutation method. | 28 // the ApplyMutation method. |
27 class CONTENT_EXPORT DOMStorageCachedArea | 29 class CONTENT_EXPORT DOMStorageCachedArea |
28 : public base::RefCounted<DOMStorageCachedArea> { | 30 : public base::RefCounted<DOMStorageCachedArea> { |
29 public: | 31 public: |
30 DOMStorageCachedArea(int64 namespace_id, | 32 DOMStorageCachedArea(int64_t namespace_id, |
31 const GURL& origin, | 33 const GURL& origin, |
32 DOMStorageProxy* proxy); | 34 DOMStorageProxy* proxy); |
33 | 35 |
34 int64 namespace_id() const { return namespace_id_; } | 36 int64_t namespace_id() const { return namespace_id_; } |
35 const GURL& origin() const { return origin_; } | 37 const GURL& origin() const { return origin_; } |
36 | 38 |
37 unsigned GetLength(int connection_id); | 39 unsigned GetLength(int connection_id); |
38 base::NullableString16 GetKey(int connection_id, unsigned index); | 40 base::NullableString16 GetKey(int connection_id, unsigned index); |
39 base::NullableString16 GetItem(int connection_id, const base::string16& key); | 41 base::NullableString16 GetItem(int connection_id, const base::string16& key); |
40 bool SetItem(int connection_id, | 42 bool SetItem(int connection_id, |
41 const base::string16& key, | 43 const base::string16& key, |
42 const base::string16& value, | 44 const base::string16& value, |
43 const GURL& page_url); | 45 const GURL& page_url); |
44 void RemoveItem(int connection_id, | 46 void RemoveItem(int connection_id, |
(...skipping 30 matching lines...) Expand all Loading... |
75 void OnClearComplete(bool success); | 77 void OnClearComplete(bool success); |
76 void OnRemoveItemComplete(const base::string16& key, bool success); | 78 void OnRemoveItemComplete(const base::string16& key, bool success); |
77 | 79 |
78 bool should_ignore_key_mutation(const base::string16& key) const { | 80 bool should_ignore_key_mutation(const base::string16& key) const { |
79 return ignore_key_mutations_.find(key) != ignore_key_mutations_.end(); | 81 return ignore_key_mutations_.find(key) != ignore_key_mutations_.end(); |
80 } | 82 } |
81 | 83 |
82 bool ignore_all_mutations_; | 84 bool ignore_all_mutations_; |
83 std::map<base::string16, int> ignore_key_mutations_; | 85 std::map<base::string16, int> ignore_key_mutations_; |
84 | 86 |
85 int64 namespace_id_; | 87 int64_t namespace_id_; |
86 GURL origin_; | 88 GURL origin_; |
87 scoped_refptr<DOMStorageMap> map_; | 89 scoped_refptr<DOMStorageMap> map_; |
88 scoped_refptr<DOMStorageProxy> proxy_; | 90 scoped_refptr<DOMStorageProxy> proxy_; |
89 base::WeakPtrFactory<DOMStorageCachedArea> weak_factory_; | 91 base::WeakPtrFactory<DOMStorageCachedArea> weak_factory_; |
90 }; | 92 }; |
91 | 93 |
92 } // namespace content | 94 } // namespace content |
93 | 95 |
94 #endif // CONTENT_RENDERER_DOM_STORAGE_DOM_STORAGE_CACHED_AREA_H_ | 96 #endif // CONTENT_RENDERER_DOM_STORAGE_DOM_STORAGE_CACHED_AREA_H_ |
OLD | NEW |