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 16 matching lines...) Expand all Loading... |
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 // Option for PurgeMemory. |
36 enum PurgeOption { | 36 enum PurgeOption { |
| 37 // Determines the level of purging based on the usage and the platform. |
| 38 PURGE_UNSPECIFIED, |
| 39 |
37 // Purge unopened areas only. | 40 // Purge unopened areas only. |
38 PURGE_UNOPENED, | 41 PURGE_UNOPENED, |
39 | 42 |
40 // Purge aggressively, i.e. discard cache even for areas that have | 43 // Purge aggressively, i.e. discard cache even for areas that have |
41 // non-zero open count. | 44 // non-zero open count. |
42 PURGE_AGGRESSIVE, | 45 PURGE_AGGRESSIVE, |
43 }; | 46 }; |
44 | 47 |
45 // Constructor for a LocalStorage namespace with id of 0 | 48 // Constructor for a LocalStorage namespace with id of 0 |
46 // and an optional backing directory on disk. | 49 // and an optional backing directory on disk. |
(...skipping 26 matching lines...) Expand all Loading... |
73 // Should only be called for session storage namespaces. | 76 // Should only be called for session storage namespaces. |
74 DOMStorageNamespace* Clone(int64_t clone_namespace_id, | 77 DOMStorageNamespace* Clone(int64_t clone_namespace_id, |
75 const std::string& clone_persistent_namespace_id); | 78 const std::string& clone_persistent_namespace_id); |
76 | 79 |
77 void DeleteLocalStorageOrigin(const GURL& origin); | 80 void DeleteLocalStorageOrigin(const GURL& origin); |
78 void DeleteSessionStorageOrigin(const GURL& origin); | 81 void DeleteSessionStorageOrigin(const GURL& origin); |
79 void PurgeMemory(PurgeOption purge); | 82 void PurgeMemory(PurgeOption purge); |
80 void Shutdown(); | 83 void Shutdown(); |
81 void Flush(); | 84 void Flush(); |
82 | 85 |
83 unsigned int CountInMemoryAreas() const; | |
84 | |
85 // Adds memory statistics to |pmd| for chrome://tracing. | 86 // Adds memory statistics to |pmd| for chrome://tracing. |
86 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd); | 87 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd); |
87 | 88 |
88 private: | 89 private: |
89 friend class base::RefCountedThreadSafe<DOMStorageNamespace>; | 90 friend class base::RefCountedThreadSafe<DOMStorageNamespace>; |
90 | 91 |
91 // Struct to hold references to our contained areas and | 92 // Struct to hold references to our contained areas and |
92 // to keep track of how many tabs have a given area open. | 93 // to keep track of how many tabs have a given area open. |
93 struct AreaHolder { | 94 struct AreaHolder { |
94 scoped_refptr<DOMStorageArea> area_; | 95 scoped_refptr<DOMStorageArea> area_; |
95 int open_count_; | 96 int open_count_; |
96 AreaHolder(); | 97 AreaHolder(); |
97 AreaHolder(DOMStorageArea* area, int count); | 98 AreaHolder(DOMStorageArea* area, int count); |
98 AreaHolder(const AreaHolder& other); | 99 AreaHolder(const AreaHolder& other); |
99 ~AreaHolder(); | 100 ~AreaHolder(); |
100 }; | 101 }; |
101 typedef std::map<GURL, AreaHolder> AreaMap; | 102 typedef std::map<GURL, AreaHolder> AreaMap; |
102 | 103 |
103 ~DOMStorageNamespace(); | 104 ~DOMStorageNamespace(); |
104 | 105 |
105 // Returns a pointer to the area holder in our map or NULL. | 106 // Returns a pointer to the area holder in our map or NULL. |
106 AreaHolder* GetAreaHolder(const GURL& origin); | 107 AreaHolder* GetAreaHolder(const GURL& origin); |
107 | 108 |
| 109 // Helper to determine the purging level based on the usage and the platform. |
| 110 PurgeOption FindPurgeLevel(); |
| 111 |
108 int64_t namespace_id_; | 112 int64_t namespace_id_; |
109 std::string persistent_namespace_id_; | 113 std::string persistent_namespace_id_; |
110 base::FilePath directory_; | 114 base::FilePath directory_; |
111 AreaMap areas_; | 115 AreaMap areas_; |
112 scoped_refptr<DOMStorageTaskRunner> task_runner_; | 116 scoped_refptr<DOMStorageTaskRunner> task_runner_; |
113 scoped_refptr<SessionStorageDatabase> session_storage_database_; | 117 scoped_refptr<SessionStorageDatabase> session_storage_database_; |
| 118 bool is_low_end_device_; |
114 }; | 119 }; |
115 | 120 |
116 } // namespace content | 121 } // namespace content |
117 | 122 |
118 | 123 |
119 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_NAMESPACE_H_ | 124 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_NAMESPACE_H_ |
OLD | NEW |