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 <map> | 8 #include <map> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 void RemoveItem(int connection_id, | 44 void RemoveItem(int connection_id, |
45 const base::string16& key, | 45 const base::string16& key, |
46 const GURL& page_url); | 46 const GURL& page_url); |
47 void Clear(int connection_id, const GURL& page_url); | 47 void Clear(int connection_id, const GURL& page_url); |
48 | 48 |
49 void ApplyMutation(const base::NullableString16& key, | 49 void ApplyMutation(const base::NullableString16& key, |
50 const base::NullableString16& new_value); | 50 const base::NullableString16& new_value); |
51 | 51 |
52 size_t MemoryBytesUsedByCache() const; | 52 size_t MemoryBytesUsedByCache() const; |
53 | 53 |
54 // Resets the object back to its newly constructed state. | |
55 void Reset(); | |
56 | |
57 private: | 54 private: |
58 friend class DOMStorageCachedAreaTest; | 55 friend class DOMStorageCachedAreaTest; |
59 friend class base::RefCounted<DOMStorageCachedArea>; | 56 friend class base::RefCounted<DOMStorageCachedArea>; |
60 ~DOMStorageCachedArea(); | 57 ~DOMStorageCachedArea(); |
61 | 58 |
62 // Primes the cache, loading all values for the area. | 59 // Primes the cache, loading all values for the area. |
63 void Prime(int connection_id); | 60 void Prime(int connection_id); |
64 void PrimeIfNeeded(int connection_id) { | 61 void PrimeIfNeeded(int connection_id) { |
65 if (!map_.get()) | 62 if (!map_.get()) |
66 Prime(connection_id); | 63 Prime(connection_id); |
67 } | 64 } |
68 | 65 |
| 66 // Resets the object back to its newly constructed state. |
| 67 void Reset(); |
| 68 |
69 // Async completion callbacks for proxied operations. | 69 // Async completion callbacks for proxied operations. |
70 // These are used to maintain cache consistency by preventing | 70 // These are used to maintain cache consistency by preventing |
71 // mutation events from other processes from overwriting local | 71 // mutation events from other processes from overwriting local |
72 // changes made after the mutation. | 72 // changes made after the mutation. |
73 void OnLoadComplete(bool success); | 73 void OnLoadComplete(bool success); |
74 void OnSetItemComplete(const base::string16& key, bool success); | 74 void OnSetItemComplete(const base::string16& key, bool success); |
75 void OnClearComplete(bool success); | 75 void OnClearComplete(bool success); |
76 void OnRemoveItemComplete(const base::string16& key, bool success); | 76 void OnRemoveItemComplete(const base::string16& key, bool success); |
77 | 77 |
78 bool should_ignore_key_mutation(const base::string16& key) const { | 78 bool should_ignore_key_mutation(const base::string16& key) const { |
79 return ignore_key_mutations_.find(key) != ignore_key_mutations_.end(); | 79 return ignore_key_mutations_.find(key) != ignore_key_mutations_.end(); |
80 } | 80 } |
81 | 81 |
82 bool ignore_all_mutations_; | 82 bool ignore_all_mutations_; |
83 std::map<base::string16, int> ignore_key_mutations_; | 83 std::map<base::string16, int> ignore_key_mutations_; |
84 | 84 |
85 int64 namespace_id_; | 85 int64 namespace_id_; |
86 GURL origin_; | 86 GURL origin_; |
87 scoped_refptr<DOMStorageMap> map_; | 87 scoped_refptr<DOMStorageMap> map_; |
88 scoped_refptr<DOMStorageProxy> proxy_; | 88 scoped_refptr<DOMStorageProxy> proxy_; |
89 // Sometimes, we need to send messages to the browser for each get access, | |
90 // for logging purposes. However, we only do this for a fixed maximum number | |
91 // of gets. Here, we keep track of how many remaining get log messages we | |
92 // need to send. | |
93 int remaining_log_get_messages_; | |
94 base::WeakPtrFactory<DOMStorageCachedArea> weak_factory_; | 89 base::WeakPtrFactory<DOMStorageCachedArea> weak_factory_; |
95 }; | 90 }; |
96 | 91 |
97 } // namespace content | 92 } // namespace content |
98 | 93 |
99 #endif // CONTENT_RENDERER_DOM_STORAGE_DOM_STORAGE_CACHED_AREA_H_ | 94 #endif // CONTENT_RENDERER_DOM_STORAGE_DOM_STORAGE_CACHED_AREA_H_ |
OLD | NEW |