OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_LOCAL_STORAGE_CACHED_AREA_H_ | 5 #ifndef CONTENT_RENDERER_DOM_STORAGE_LOCAL_STORAGE_CACHED_AREA_H_ |
6 #define CONTENT_RENDERER_DOM_STORAGE_LOCAL_STORAGE_CACHED_AREA_H_ | 6 #define CONTENT_RENDERER_DOM_STORAGE_LOCAL_STORAGE_CACHED_AREA_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 void AreaCreated(LocalStorageArea* area); | 53 void AreaCreated(LocalStorageArea* area); |
54 void AreaDestroyed(LocalStorageArea* area); | 54 void AreaDestroyed(LocalStorageArea* area); |
55 | 55 |
56 const url::Origin& origin() { return origin_; } | 56 const url::Origin& origin() { return origin_; } |
57 | 57 |
58 private: | 58 private: |
59 friend class base::RefCounted<LocalStorageCachedArea>; | 59 friend class base::RefCounted<LocalStorageCachedArea>; |
60 ~LocalStorageCachedArea() override; | 60 ~LocalStorageCachedArea() override; |
61 | 61 |
62 // LevelDBObserver: | 62 // LevelDBObserver: |
| 63 void KeyAdded(mojo::Array<uint8_t> key, |
| 64 mojo::Array<uint8_t> value, |
| 65 const mojo::String& source) override; |
63 void KeyChanged(mojo::Array<uint8_t> key, | 66 void KeyChanged(mojo::Array<uint8_t> key, |
64 mojo::Array<uint8_t> new_value, | 67 mojo::Array<uint8_t> new_value, |
65 mojo::Array<uint8_t> old_value, | 68 mojo::Array<uint8_t> old_value, |
66 const mojo::String& source) override; | 69 const mojo::String& source) override; |
67 void KeyDeleted(mojo::Array<uint8_t> key, | 70 void KeyDeleted(mojo::Array<uint8_t> key, |
68 mojo::Array<uint8_t> old_value, | 71 mojo::Array<uint8_t> old_value, |
69 const mojo::String& source) override; | 72 const mojo::String& source) override; |
70 void AllDeleted(const mojo::String& source) override; | 73 void AllDeleted(const mojo::String& source) override; |
| 74 void GetAllComplete(uint64_t request_id) override; |
| 75 |
| 76 // Common helper for KeyAdded() and KeyChanged() |
| 77 void KeyAddedOrChanged(mojo::Array<uint8_t> key, |
| 78 mojo::Array<uint8_t> new_value, |
| 79 base::NullableString16& old_value, |
| 80 const mojo::String& source); |
71 | 81 |
72 // Synchronously fetches the origin's local storage data if it hasn't been | 82 // Synchronously fetches the origin's local storage data if it hasn't been |
73 // fetched already. | 83 // fetched already. |
74 void EnsureLoaded(); | 84 void EnsureLoaded(); |
75 | 85 |
76 void OnSetItemComplete(const base::string16& key, | 86 void OnSetItemComplete(const base::string16& key, bool success); |
77 leveldb::DatabaseError result); | 87 void OnRemoveItemComplete(const base::string16& key, bool success); |
78 void OnRemoveItemComplete(const base::string16& key, | 88 void OnClearComplete(bool success); |
79 leveldb::DatabaseError result); | |
80 void OnClearComplete(leveldb::DatabaseError result); | |
81 | 89 |
82 // Resets the object back to its newly constructed state. | 90 // Resets the object back to its newly constructed state. |
83 void Reset(); | 91 void Reset(); |
84 | 92 |
85 bool loaded_; | |
86 url::Origin origin_; | 93 url::Origin origin_; |
87 scoped_refptr<DOMStorageMap> map_; | 94 scoped_refptr<DOMStorageMap> map_; |
88 std::map<base::string16, int> ignore_key_mutations_; | 95 std::map<base::string16, int> ignore_key_mutations_; |
| 96 bool ignore_all_mutations_ = false; |
| 97 uint64_t get_all_request_id_ = UINT64_C(0); |
89 LevelDBWrapperPtr leveldb_; | 98 LevelDBWrapperPtr leveldb_; |
90 mojo::Binding<LevelDBObserver> binding_; | 99 mojo::Binding<LevelDBObserver> binding_; |
91 LocalStorageCachedAreas* cached_areas_; | 100 LocalStorageCachedAreas* cached_areas_; |
92 std::map<std::string, LocalStorageArea*> areas_; | 101 std::map<std::string, LocalStorageArea*> areas_; |
| 102 base::WeakPtrFactory<LocalStorageCachedArea> weak_factory_; |
93 | 103 |
94 DISALLOW_COPY_AND_ASSIGN(LocalStorageCachedArea); | 104 DISALLOW_COPY_AND_ASSIGN(LocalStorageCachedArea); |
95 }; | 105 }; |
96 | 106 |
97 } // namespace content | 107 } // namespace content |
98 | 108 |
99 #endif // CONTENT_RENDERER_DOM_STORAGE_LOCAL_STORAGE_CACHED_AREA_H_ | 109 #endif // CONTENT_RENDERER_DOM_STORAGE_LOCAL_STORAGE_CACHED_AREA_H_ |
OLD | NEW |