OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 WEBKIT_QUOTA_QUOTA_MANAGER_H_ | 5 #ifndef WEBKIT_QUOTA_QUOTA_MANAGER_H_ |
6 #define WEBKIT_QUOTA_QUOTA_MANAGER_H_ | 6 #define WEBKIT_QUOTA_QUOTA_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <deque> | 9 #include <deque> |
10 #include <list> | 10 #include <list> |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 void GetHostUsage(const std::string& host, StorageType type, | 134 void GetHostUsage(const std::string& host, StorageType type, |
135 HostUsageCallback* callback); | 135 HostUsageCallback* callback); |
136 | 136 |
137 void GetStatistics(std::map<std::string, std::string>* statistics); | 137 void GetStatistics(std::map<std::string, std::string>* statistics); |
138 | 138 |
139 bool IsStorageUnlimited(const GURL& origin) const { | 139 bool IsStorageUnlimited(const GURL& origin) const { |
140 return special_storage_policy_.get() && | 140 return special_storage_policy_.get() && |
141 special_storage_policy_->IsStorageUnlimited(origin); | 141 special_storage_policy_->IsStorageUnlimited(origin); |
142 } | 142 } |
143 | 143 |
| 144 void GetOriginsModifiedSince( |
| 145 StorageType type, |
| 146 base::Time modified_since, |
| 147 GetOriginsCallback* callback); |
| 148 |
144 // Used to determine the total size of the temp pool. | 149 // Used to determine the total size of the temp pool. |
145 static const int64 kTemporaryStorageQuotaDefaultSize; | 150 static const int64 kTemporaryStorageQuotaDefaultSize; |
146 static const int64 kTemporaryStorageQuotaMaxSize; | 151 static const int64 kTemporaryStorageQuotaMaxSize; |
147 static const int64 kIncognitoDefaultTemporaryQuota; | 152 static const int64 kIncognitoDefaultTemporaryQuota; |
148 | 153 |
149 // Determines the portion of the temp pool that can be | 154 // Determines the portion of the temp pool that can be |
150 // utilized by a single host (ie. 5 for 20%). | 155 // utilized by a single host (ie. 5 for 20%). |
151 static const int kPerHostTemporaryPortion; | 156 static const int kPerHostTemporaryPortion; |
152 | 157 |
153 static const char kDatabaseName[]; | 158 static const char kDatabaseName[]; |
154 | 159 |
155 static const int kThresholdOfErrorsToBeBlacklisted; | 160 static const int kThresholdOfErrorsToBeBlacklisted; |
156 | 161 |
157 static const int kEvictionIntervalInMilliSeconds; | 162 static const int kEvictionIntervalInMilliSeconds; |
158 | 163 |
159 private: | 164 private: |
160 class DatabaseTaskBase; | 165 class DatabaseTaskBase; |
161 class InitializeTask; | 166 class InitializeTask; |
162 class TemporaryGlobalQuotaUpdateTask; | 167 class TemporaryGlobalQuotaUpdateTask; |
163 class PersistentHostQuotaQueryTask; | 168 class PersistentHostQuotaQueryTask; |
164 class PersistentHostQuotaUpdateTask; | 169 class PersistentHostQuotaUpdateTask; |
165 class GetLRUOriginTask; | 170 class GetLRUOriginTask; |
166 class OriginDeletionDatabaseTask; | 171 class OriginDeletionDatabaseTask; |
167 class TemporaryOriginsRegistrationTask; | 172 class TemporaryOriginsRegistrationTask; |
168 class OriginAccessRecordDatabaseTask; | 173 class OriginAccessRecordDatabaseTask; |
| 174 class OriginModifyRecordDatabaseTask; |
| 175 class OriginsModifiedSinceRetrieveTask; |
169 | 176 |
170 class UsageAndQuotaDispatcherTask; | 177 class UsageAndQuotaDispatcherTask; |
171 class UsageAndQuotaDispatcherTaskForTemporary; | 178 class UsageAndQuotaDispatcherTaskForTemporary; |
172 class UsageAndQuotaDispatcherTaskForPersistent; | 179 class UsageAndQuotaDispatcherTaskForPersistent; |
173 | 180 |
174 class AvailableSpaceQueryTask; | 181 class AvailableSpaceQueryTask; |
175 class DumpQuotaTableTask; | 182 class DumpQuotaTableTask; |
176 class DumpLastAccessTimeTableTask; | 183 class DumpOriginInfoTableTask; |
177 | 184 |
178 typedef QuotaDatabase::QuotaTableEntry QuotaTableEntry; | 185 typedef QuotaDatabase::QuotaTableEntry QuotaTableEntry; |
179 typedef QuotaDatabase::LastAccessTimeTableEntry LastAccessTimeTableEntry; | 186 typedef QuotaDatabase::OriginInfoTableEntry OriginInfoTableEntry; |
180 typedef std::vector<QuotaTableEntry> QuotaTableEntries; | 187 typedef std::vector<QuotaTableEntry> QuotaTableEntries; |
181 typedef std::vector<LastAccessTimeTableEntry> LastAccessTimeTableEntries; | 188 typedef std::vector<OriginInfoTableEntry> OriginInfoTableEntries; |
182 | 189 |
183 typedef Callback1<const QuotaTableEntries&>::Type DumpQuotaTableCallback; | 190 typedef Callback1<const QuotaTableEntries&>::Type DumpQuotaTableCallback; |
184 typedef Callback1<const LastAccessTimeTableEntries&>::Type | 191 typedef Callback1<const OriginInfoTableEntries&>::Type |
185 DumpLastAccessTimeTableCallback; | 192 DumpOriginInfoTableCallback; |
186 | 193 |
187 struct EvictionContext { | 194 struct EvictionContext { |
188 EvictionContext() | 195 EvictionContext() |
189 : evicted_type(kStorageTypeUnknown), | 196 : evicted_type(kStorageTypeUnknown), |
190 num_eviction_requested_clients(0), | 197 num_eviction_requested_clients(0), |
191 num_evicted_clients(0), | 198 num_evicted_clients(0), |
192 num_eviction_error(0), | 199 num_eviction_error(0), |
193 usage(0), | 200 usage(0), |
194 unlimited_usage(0), | 201 unlimited_usage(0), |
195 quota(0) {} | 202 quota(0) {} |
(...skipping 12 matching lines...) Expand all Loading... |
208 int64 usage; | 215 int64 usage; |
209 int64 unlimited_usage; | 216 int64 unlimited_usage; |
210 int64 quota; | 217 int64 quota; |
211 }; | 218 }; |
212 | 219 |
213 typedef std::pair<std::string, StorageType> HostAndType; | 220 typedef std::pair<std::string, StorageType> HostAndType; |
214 typedef std::map<HostAndType, UsageAndQuotaDispatcherTask*> | 221 typedef std::map<HostAndType, UsageAndQuotaDispatcherTask*> |
215 UsageAndQuotaDispatcherTaskMap; | 222 UsageAndQuotaDispatcherTaskMap; |
216 | 223 |
217 friend struct QuotaManagerDeleter; | 224 friend struct QuotaManagerDeleter; |
| 225 friend class MockStorageClient; |
218 friend class QuotaManagerProxy; | 226 friend class QuotaManagerProxy; |
219 friend class QuotaManagerTest; | 227 friend class QuotaManagerTest; |
220 friend class QuotaTemporaryStorageEvictor; | 228 friend class QuotaTemporaryStorageEvictor; |
221 | 229 |
222 // This initialization method is lazily called on the IO thread | 230 // This initialization method is lazily called on the IO thread |
223 // when the first quota manager API is called. | 231 // when the first quota manager API is called. |
224 // Initialize must be called after all quota clients are added to the | 232 // Initialize must be called after all quota clients are added to the |
225 // manager by RegisterStorage. | 233 // manager by RegisterStorage. |
226 void LazyInitialize(); | 234 void LazyInitialize(); |
227 | 235 |
228 // Called by clients via proxy. | 236 // Called by clients via proxy. |
229 // Registers a quota client to the manager. | 237 // Registers a quota client to the manager. |
230 // The client must remain valid until OnQuotaManagerDestored is called. | 238 // The client must remain valid until OnQuotaManagerDestored is called. |
231 void RegisterClient(QuotaClient* client); | 239 void RegisterClient(QuotaClient* client); |
232 | 240 |
233 UsageTracker* GetUsageTracker(StorageType type) const; | 241 UsageTracker* GetUsageTracker(StorageType type) const; |
234 | 242 |
235 // Extract cached origins list from the usage tracker. | 243 // Extract cached origins list from the usage tracker. |
236 // (Might return empty list if no origin is tracked by the tracker.) | 244 // (Might return empty list if no origin is tracked by the tracker.) |
237 void GetCachedOrigins(StorageType type, std::set<GURL>* origins); | 245 void GetCachedOrigins(StorageType type, std::set<GURL>* origins); |
238 | 246 |
239 // This internal method is separately defined mainly for testing. | 247 // These internal methods are separately defined mainly for testing. |
240 void NotifyStorageAccessedInternal( | 248 void NotifyStorageAccessedInternal( |
241 QuotaClient::ID client_id, | 249 QuotaClient::ID client_id, |
242 const GURL& origin, | 250 const GURL& origin, |
243 StorageType type, | 251 StorageType type, |
244 base::Time accessed_time); | 252 base::Time accessed_time); |
| 253 void NotifyStorageModifiedInternal( |
| 254 QuotaClient::ID client_id, |
| 255 const GURL& origin, |
| 256 StorageType type, |
| 257 int64 delta, |
| 258 base::Time modified_time); |
245 | 259 |
246 void DumpQuotaTable(DumpQuotaTableCallback* callback); | 260 void DumpQuotaTable(DumpQuotaTableCallback* callback); |
247 void DumpLastAccessTimeTable(DumpLastAccessTimeTableCallback* callback); | 261 void DumpOriginInfoTable(DumpOriginInfoTableCallback* callback); |
248 | 262 |
249 // Methods for eviction logic. | 263 // Methods for eviction logic. |
250 void StartEviction(); | 264 void StartEviction(); |
251 void DeleteOriginFromDatabase(const GURL& origin, StorageType type); | 265 void DeleteOriginFromDatabase(const GURL& origin, StorageType type); |
252 | 266 |
253 void DidOriginDataEvicted(QuotaStatusCode status); | 267 void DidOriginDataEvicted(QuotaStatusCode status); |
254 void DidGetAvailableSpaceForEviction( | 268 void DidGetAvailableSpaceForEviction( |
255 QuotaStatusCode status, | 269 QuotaStatusCode status, |
256 int64 available_space); | 270 int64 available_space); |
257 void DidGetGlobalQuotaForEviction( | 271 void DidGetGlobalQuotaForEviction( |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 | 368 |
355 QuotaManager* manager_; // only accessed on the io thread | 369 QuotaManager* manager_; // only accessed on the io thread |
356 scoped_refptr<base::MessageLoopProxy> io_thread_; | 370 scoped_refptr<base::MessageLoopProxy> io_thread_; |
357 | 371 |
358 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); | 372 DISALLOW_COPY_AND_ASSIGN(QuotaManagerProxy); |
359 }; | 373 }; |
360 | 374 |
361 } // namespace quota | 375 } // namespace quota |
362 | 376 |
363 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ | 377 #endif // WEBKIT_QUOTA_QUOTA_MANAGER_H_ |
OLD | NEW |