OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_NAMESPACE_H_ | 5 #ifndef CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_NAMESPACE_H_ |
6 #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_NAMESPACE_H_ | 6 #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_NAMESPACE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 class DOMStorageArea; | 26 class DOMStorageArea; |
27 class DOMStorageTaskRunner; | 27 class DOMStorageTaskRunner; |
28 class SessionStorageDatabase; | 28 class SessionStorageDatabase; |
29 | 29 |
30 // Container for the set of per-origin Areas. | 30 // Container for the set of per-origin Areas. |
31 // See class comments for DOMStorageContextImpl for a larger overview. | 31 // See class comments for DOMStorageContextImpl for a larger overview. |
32 class CONTENT_EXPORT DOMStorageNamespace | 32 class CONTENT_EXPORT DOMStorageNamespace |
33 : public base::RefCountedThreadSafe<DOMStorageNamespace> { | 33 : public base::RefCountedThreadSafe<DOMStorageNamespace> { |
34 public: | 34 public: |
35 // Option for PurgeMemory. | 35 // Struct to hold statistics about the areas in the namespace. |
36 enum PurgeOption { | 36 struct UsageStatistics { |
37 // Purge unopened areas only. | 37 size_t total_cache_size; |
38 PURGE_UNOPENED, | 38 unsigned total_area_count; |
39 | 39 unsigned inactive_area_count; // areas with open count 0. |
40 // Purge aggressively, i.e. discard cache even for areas that have | |
41 // non-zero open count. | |
42 PURGE_AGGRESSIVE, | |
43 }; | 40 }; |
44 | 41 |
45 // Constructor for a LocalStorage namespace with id of 0 | 42 // Constructor for a LocalStorage namespace with id of 0 |
46 // and an optional backing directory on disk. | 43 // and an optional backing directory on disk. |
47 DOMStorageNamespace(const base::FilePath& directory, // may be empty | 44 DOMStorageNamespace(const base::FilePath& directory, // may be empty |
48 DOMStorageTaskRunner* task_runner); | 45 DOMStorageTaskRunner* task_runner); |
49 | 46 |
50 // Constructor for a SessionStorage namespace with a non-zero id and an | 47 // Constructor for a SessionStorage namespace with a non-zero id and an |
51 // optional backing on disk via |session_storage_database| (may be NULL). | 48 // optional backing on disk via |session_storage_database| (may be NULL). |
52 DOMStorageNamespace(int64_t namespace_id, | 49 DOMStorageNamespace(int64_t namespace_id, |
(...skipping 16 matching lines...) Expand all Loading... |
69 DOMStorageArea* GetOpenStorageArea(const GURL& origin); | 66 DOMStorageArea* GetOpenStorageArea(const GURL& origin); |
70 | 67 |
71 // Creates a clone of |this| namespace including | 68 // Creates a clone of |this| namespace including |
72 // shallow copies of all contained areas. | 69 // shallow copies of all contained areas. |
73 // Should only be called for session storage namespaces. | 70 // Should only be called for session storage namespaces. |
74 DOMStorageNamespace* Clone(int64_t clone_namespace_id, | 71 DOMStorageNamespace* Clone(int64_t clone_namespace_id, |
75 const std::string& clone_persistent_namespace_id); | 72 const std::string& clone_persistent_namespace_id); |
76 | 73 |
77 void DeleteLocalStorageOrigin(const GURL& origin); | 74 void DeleteLocalStorageOrigin(const GURL& origin); |
78 void DeleteSessionStorageOrigin(const GURL& origin); | 75 void DeleteSessionStorageOrigin(const GURL& origin); |
79 void PurgeMemory(PurgeOption purge); | 76 void PurgeMemory(bool aggressively); |
80 void Shutdown(); | 77 void Shutdown(); |
81 void Flush(); | 78 void Flush(); |
82 | 79 |
83 unsigned int CountInMemoryAreas() const; | 80 // Returns statistics about the areas in the namespace. |
| 81 UsageStatistics GetUsageStatistics() const; |
84 | 82 |
85 // Adds memory statistics to |pmd| for chrome://tracing. | 83 // Adds memory statistics to |pmd| for chrome://tracing. |
86 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd); | 84 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd); |
87 | 85 |
88 void GetOriginsWithAreas(std::vector<GURL>* origins) const; | 86 void GetOriginsWithAreas(std::vector<GURL>* origins) const; |
89 | 87 |
90 private: | 88 private: |
91 friend class base::RefCountedThreadSafe<DOMStorageNamespace>; | 89 friend class base::RefCountedThreadSafe<DOMStorageNamespace>; |
92 | 90 |
93 // Struct to hold references to our contained areas and | 91 // Struct to hold references to our contained areas and |
(...skipping 18 matching lines...) Expand all Loading... |
112 base::FilePath directory_; | 110 base::FilePath directory_; |
113 AreaMap areas_; | 111 AreaMap areas_; |
114 scoped_refptr<DOMStorageTaskRunner> task_runner_; | 112 scoped_refptr<DOMStorageTaskRunner> task_runner_; |
115 scoped_refptr<SessionStorageDatabase> session_storage_database_; | 113 scoped_refptr<SessionStorageDatabase> session_storage_database_; |
116 }; | 114 }; |
117 | 115 |
118 } // namespace content | 116 } // namespace content |
119 | 117 |
120 | 118 |
121 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_NAMESPACE_H_ | 119 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_NAMESPACE_H_ |
OLD | NEW |