Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: storage/browser/quota/quota_database.h

Issue 1424653002: Add access count and time-since-accessed histograms to temp storage eviction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@quota_uma
Patch Set: fix test Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 STORAGE_BROWSER_QUOTA_QUOTA_DATABASE_H_ 5 #ifndef STORAGE_BROWSER_QUOTA_QUOTA_DATABASE_H_
6 #define STORAGE_BROWSER_QUOTA_QUOTA_DATABASE_H_ 6 #define STORAGE_BROWSER_QUOTA_QUOTA_DATABASE_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 18 matching lines...) Expand all
29 29
30 class GURL; 30 class GURL;
31 31
32 namespace storage { 32 namespace storage {
33 33
34 class SpecialStoragePolicy; 34 class SpecialStoragePolicy;
35 35
36 // All the methods of this class must run on the DB thread. 36 // All the methods of this class must run on the DB thread.
37 class STORAGE_EXPORT_PRIVATE QuotaDatabase { 37 class STORAGE_EXPORT_PRIVATE QuotaDatabase {
38 public: 38 public:
39 struct STORAGE_EXPORT_PRIVATE OriginInfoTableEntry {
40 OriginInfoTableEntry();
41 OriginInfoTableEntry(const GURL& origin,
42 StorageType type,
43 int used_count,
44 const base::Time& last_access_time,
45 const base::Time& last_modified_time);
46 GURL origin;
47 StorageType type;
48 int used_count;
49 base::Time last_access_time;
50 base::Time last_modified_time;
51 };
52
39 // Constants for {Get,Set}QuotaConfigValue keys. 53 // Constants for {Get,Set}QuotaConfigValue keys.
40 static const char kDesiredAvailableSpaceKey[]; 54 static const char kDesiredAvailableSpaceKey[];
41 static const char kTemporaryQuotaOverrideKey[]; 55 static const char kTemporaryQuotaOverrideKey[];
42 56
43 // If 'path' is empty, an in memory database will be used. 57 // If 'path' is empty, an in memory database will be used.
44 explicit QuotaDatabase(const base::FilePath& path); 58 explicit QuotaDatabase(const base::FilePath& path);
45 ~QuotaDatabase(); 59 ~QuotaDatabase();
46 60
47 void CloseConnection(); 61 void CloseConnection();
48 62
63 // Returns whether the record could be found.
49 bool GetHostQuota(const std::string& host, StorageType type, int64* quota); 64 bool GetHostQuota(const std::string& host, StorageType type, int64* quota);
65
66 // Returns whether the operation succeeded.
50 bool SetHostQuota(const std::string& host, StorageType type, int64 quota); 67 bool SetHostQuota(const std::string& host, StorageType type, int64 quota);
51 bool DeleteHostQuota(const std::string& host, StorageType type); 68 bool DeleteHostQuota(const std::string& host, StorageType type);
52 69
53 bool SetOriginLastAccessTime(const GURL& origin, 70 bool SetOriginLastAccessTime(const GURL& origin,
54 StorageType type, 71 StorageType type,
55 base::Time last_access_time); 72 base::Time last_access_time);
56 73
57 bool SetOriginLastModifiedTime(const GURL& origin, 74 bool SetOriginLastModifiedTime(const GURL& origin,
58 StorageType type, 75 StorageType type,
59 base::Time last_modified_time); 76 base::Time last_modified_time);
60 77
78 // Gets the time |origin| was last evicted. Returns whether the record could
79 // be found.
61 bool GetOriginLastEvictionTime(const GURL& origin, 80 bool GetOriginLastEvictionTime(const GURL& origin,
62 StorageType type, 81 StorageType type,
63 base::Time* last_eviction_time); 82 base::Time* last_eviction_time);
83
84 // Sets the time the origin was last evicted. Returns whether the operation
85 // succeeded.
64 bool SetOriginLastEvictionTime(const GURL& origin, 86 bool SetOriginLastEvictionTime(const GURL& origin,
65 StorageType type, 87 StorageType type,
66 base::Time last_eviction_time); 88 base::Time last_eviction_time);
67 bool DeleteOriginLastEvictionTime(const GURL& origin, StorageType type); 89 bool DeleteOriginLastEvictionTime(const GURL& origin, StorageType type);
68 90
69 // Register initial |origins| info |type| to the database. 91 // Register initial |origins| info |type| to the database.
70 // This method is assumed to be called only after the installation or 92 // This method is assumed to be called only after the installation or
71 // the database schema reset. 93 // the database schema reset.
72 bool RegisterInitialOriginInfo( 94 bool RegisterInitialOriginInfo(
73 const std::set<GURL>& origins, StorageType type); 95 const std::set<GURL>& origins, StorageType type);
74 96
97 // Gets the OriginInfoTableEntry for |origin|. Returns whether the record
98 // could be found.
99 bool GetOriginInfo(const GURL& origin,
100 StorageType type,
101 OriginInfoTableEntry* entry);
102
75 bool DeleteOriginInfo(const GURL& origin, StorageType type); 103 bool DeleteOriginInfo(const GURL& origin, StorageType type);
76 104
77 bool GetQuotaConfigValue(const char* key, int64* value); 105 bool GetQuotaConfigValue(const char* key, int64* value);
78 bool SetQuotaConfigValue(const char* key, int64 value); 106 bool SetQuotaConfigValue(const char* key, int64 value);
79 107
80 // Sets |origin| to the least recently used origin of origins not included 108 // Sets |origin| to the least recently used origin of origins not included
81 // in |exceptions| and not granted the special unlimited storage right. 109 // in |exceptions| and not granted the special unlimited storage right.
82 // It returns false when it failed in accessing the database. 110 // It returns false when it failed in accessing the database.
83 // |origin| is set to empty when there is no matching origin. 111 // |origin| is set to empty when there is no matching origin.
84 bool GetLRUOrigin(StorageType type, 112 bool GetLRUOrigin(StorageType type,
85 const std::set<GURL>& exceptions, 113 const std::set<GURL>& exceptions,
86 SpecialStoragePolicy* special_storage_policy, 114 SpecialStoragePolicy* special_storage_policy,
87 GURL* origin); 115 GURL* origin);
88 116
89 // Populates |origins| with the ones that have been modified since 117 // Populates |origins| with the ones that have been modified since
90 // the |modified_since|. 118 // the |modified_since|. Returns whether the operation succeeded.
91 bool GetOriginsModifiedSince(StorageType type, 119 bool GetOriginsModifiedSince(StorageType type,
92 std::set<GURL>* origins, 120 std::set<GURL>* origins,
93 base::Time modified_since); 121 base::Time modified_since);
94 122
95 // Returns false if SetOriginDatabaseBootstrapped has never 123 // Returns false if SetOriginDatabaseBootstrapped has never
96 // been called before, which means existing origins may not have been 124 // been called before, which means existing origins may not have been
97 // registered. 125 // registered.
98 bool IsOriginDatabaseBootstrapped(); 126 bool IsOriginDatabaseBootstrapped();
99 bool SetOriginDatabaseBootstrapped(bool bootstrap_flag); 127 bool SetOriginDatabaseBootstrapped(bool bootstrap_flag);
100 128
101 private: 129 private:
102 struct STORAGE_EXPORT_PRIVATE QuotaTableEntry { 130 struct STORAGE_EXPORT_PRIVATE QuotaTableEntry {
103 QuotaTableEntry(); 131 QuotaTableEntry();
104 QuotaTableEntry( 132 QuotaTableEntry(
105 const std::string& host, 133 const std::string& host,
106 StorageType type, 134 StorageType type,
107 int64 quota); 135 int64 quota);
108 std::string host; 136 std::string host;
109 StorageType type; 137 StorageType type;
110 int64 quota; 138 int64 quota;
111 }; 139 };
112 friend STORAGE_EXPORT_PRIVATE bool operator <( 140 friend STORAGE_EXPORT_PRIVATE bool operator <(
113 const QuotaTableEntry& lhs, const QuotaTableEntry& rhs); 141 const QuotaTableEntry& lhs, const QuotaTableEntry& rhs);
114
115 struct STORAGE_EXPORT_PRIVATE OriginInfoTableEntry {
116 OriginInfoTableEntry();
117 OriginInfoTableEntry(
118 const GURL& origin,
119 StorageType type,
120 int used_count,
121 const base::Time& last_access_time,
122 const base::Time& last_modified_time);
123 GURL origin;
124 StorageType type;
125 int used_count;
126 base::Time last_access_time;
127 base::Time last_modified_time;
128 };
129 friend STORAGE_EXPORT_PRIVATE bool operator <( 142 friend STORAGE_EXPORT_PRIVATE bool operator <(
130 const OriginInfoTableEntry& lhs, const OriginInfoTableEntry& rhs); 143 const OriginInfoTableEntry& lhs, const OriginInfoTableEntry& rhs);
131 144
132 // Structures used for CreateSchema. 145 // Structures used for CreateSchema.
133 struct TableSchema { 146 struct TableSchema {
134 const char* table_name; 147 const char* table_name;
135 const char* columns; 148 const char* columns;
136 }; 149 };
137 struct IndexSchema { 150 struct IndexSchema {
138 const char* index_name; 151 const char* index_name;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 201
189 static const TableSchema kTables[]; 202 static const TableSchema kTables[];
190 static const IndexSchema kIndexes[]; 203 static const IndexSchema kIndexes[];
191 204
192 DISALLOW_COPY_AND_ASSIGN(QuotaDatabase); 205 DISALLOW_COPY_AND_ASSIGN(QuotaDatabase);
193 }; 206 };
194 207
195 } // namespace storage 208 } // namespace storage
196 209
197 #endif // STORAGE_BROWSER_QUOTA_QUOTA_DATABASE_H_ 210 #endif // STORAGE_BROWSER_QUOTA_QUOTA_DATABASE_H_
OLDNEW
« no previous file with comments | « content/browser/quota/quota_manager_unittest.cc ('k') | storage/browser/quota/quota_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698