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_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_ |
6 #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_ | 6 #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <set> | 11 #include <set> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/atomic_sequence_num.h" | 15 #include "base/atomic_sequence_num.h" |
16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
17 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
| 18 #include "base/memory/memory_pressure_listener.h" |
18 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
19 #include "base/observer_list.h" | 20 #include "base/observer_list.h" |
20 #include "base/time/time.h" | 21 #include "base/time/time.h" |
21 #include "base/trace_event/memory_dump_provider.h" | 22 #include "base/trace_event/memory_dump_provider.h" |
22 #include "content/common/content_export.h" | 23 #include "content/common/content_export.h" |
23 #include "url/gurl.h" | 24 #include "url/gurl.h" |
24 | 25 |
25 namespace base { | 26 namespace base { |
26 class FilePath; | 27 class FilePath; |
27 class NullableString16; | 28 class NullableString16; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 169 |
169 // Starts backing sessionStorage on disk. This function must be called right | 170 // Starts backing sessionStorage on disk. This function must be called right |
170 // after DOMStorageContextImpl is created, before it's used. | 171 // after DOMStorageContextImpl is created, before it's used. |
171 void SetSaveSessionStorageOnDisk(); | 172 void SetSaveSessionStorageOnDisk(); |
172 | 173 |
173 // Deletes all namespaces which don't have an associated DOMStorageNamespace | 174 // Deletes all namespaces which don't have an associated DOMStorageNamespace |
174 // alive. This function is used for deleting possible leftover data after an | 175 // alive. This function is used for deleting possible leftover data after an |
175 // unclean exit. | 176 // unclean exit. |
176 void StartScavengingUnusedSessionStorage(); | 177 void StartScavengingUnusedSessionStorage(); |
177 | 178 |
| 179 // Called on the |task_runner| to purge memory in case of memory pressure. |
| 180 void PurgeMemory( |
| 181 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level); |
| 182 |
178 // base::trace_event::MemoryDumpProvider implementation. | 183 // base::trace_event::MemoryDumpProvider implementation. |
179 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, | 184 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
180 base::trace_event::ProcessMemoryDump* pmd) override; | 185 base::trace_event::ProcessMemoryDump* pmd) override; |
181 | 186 |
182 private: | 187 private: |
| 188 class DOMStorageMemoryPressureListener; |
183 friend class DOMStorageContextImplTest; | 189 friend class DOMStorageContextImplTest; |
184 FRIEND_TEST_ALL_PREFIXES(DOMStorageContextImplTest, Basics); | 190 FRIEND_TEST_ALL_PREFIXES(DOMStorageContextImplTest, Basics); |
185 friend class base::RefCountedThreadSafe<DOMStorageContextImpl>; | 191 friend class base::RefCountedThreadSafe<DOMStorageContextImpl>; |
186 typedef std::map<int64_t, scoped_refptr<DOMStorageNamespace>> | 192 typedef std::map<int64_t, scoped_refptr<DOMStorageNamespace>> |
187 StorageNamespaceMap; | 193 StorageNamespaceMap; |
188 | 194 |
189 ~DOMStorageContextImpl() override; | 195 ~DOMStorageContextImpl() override; |
190 | 196 |
191 void ClearSessionOnlyOrigins(); | 197 void ClearSessionOnlyOrigins(); |
192 | 198 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 bool scavenging_started_; | 237 bool scavenging_started_; |
232 std::vector<std::string> deletable_persistent_namespace_ids_; | 238 std::vector<std::string> deletable_persistent_namespace_ids_; |
233 | 239 |
234 // Persistent namespace IDs to protect from gradual deletion (they will | 240 // Persistent namespace IDs to protect from gradual deletion (they will |
235 // be needed for session restore). | 241 // be needed for session restore). |
236 std::set<std::string> protected_persistent_session_ids_; | 242 std::set<std::string> protected_persistent_session_ids_; |
237 | 243 |
238 // Mapping between persistent namespace IDs and namespace IDs for | 244 // Mapping between persistent namespace IDs and namespace IDs for |
239 // sessionStorage. | 245 // sessionStorage. |
240 std::map<std::string, int64_t> persistent_namespace_id_to_namespace_id_; | 246 std::map<std::string, int64_t> persistent_namespace_id_to_namespace_id_; |
| 247 |
| 248 // Notifier for memory pressure signals to purges memory. |
| 249 DOMStorageMemoryPressureListener* leaked_memory_pressure_listener_; |
241 }; | 250 }; |
242 | 251 |
243 } // namespace content | 252 } // namespace content |
244 | 253 |
245 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_ | 254 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_ |
OLD | NEW |