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 STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_H_ | 5 #ifndef STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_H_ |
6 #define STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_H_ | 6 #define STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <deque> | 10 #include <deque> |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 namespace storage { | 53 namespace storage { |
54 | 54 |
55 class QuotaDatabase; | 55 class QuotaDatabase; |
56 class QuotaManagerProxy; | 56 class QuotaManagerProxy; |
57 class QuotaTemporaryStorageEvictor; | 57 class QuotaTemporaryStorageEvictor; |
58 class StorageMonitor; | 58 class StorageMonitor; |
59 class UsageTracker; | 59 class UsageTracker; |
60 | 60 |
61 struct QuotaManagerDeleter; | 61 struct QuotaManagerDeleter; |
62 | 62 |
63 struct STORAGE_EXPORT UsageAndQuota { | 63 struct STORAGE_EXPORT XUsageAndQuota { |
64 int64_t usage; | 64 int64_t usage; |
65 int64_t global_limited_usage; | 65 int64_t global_limited_usage; |
66 int64_t quota; | 66 int64_t quota; |
67 int64_t available_disk_space; | 67 int64_t available_disk_space; |
68 | 68 |
69 UsageAndQuota(); | 69 XUsageAndQuota(); |
70 UsageAndQuota(int64_t usage, | 70 XUsageAndQuota(int64_t usage, |
71 int64_t global_limited_usage, | 71 int64_t global_limited_usage, |
72 int64_t quota, | 72 int64_t quota, |
73 int64_t available_disk_space); | 73 int64_t available_disk_space); |
74 }; | 74 }; |
75 | 75 |
76 // TODO(calamity): Use this in the temporary storage eviction path. | 76 // TODO(calamity): Use this in the temporary storage eviction path. |
77 // An interface for deciding which origin's storage should be evicted when the | 77 // An interface for deciding which origin's storage should be evicted when the |
78 // quota is exceeded. | 78 // quota is exceeded. |
79 class STORAGE_EXPORT QuotaEvictionPolicy { | 79 class STORAGE_EXPORT QuotaEvictionPolicy { |
80 public: | 80 public: |
81 virtual ~QuotaEvictionPolicy() {} | 81 virtual ~QuotaEvictionPolicy() {} |
82 | 82 |
83 // Returns the next origin to evict. It might return an empty GURL when there | 83 // Returns the next origin to evict. It might return an empty GURL when there |
84 // are no evictable origins. | 84 // are no evictable origins. |
85 virtual void GetEvictionOrigin( | 85 virtual void GetEvictionOrigin( |
86 const scoped_refptr<SpecialStoragePolicy>& special_storage_policy, | 86 const scoped_refptr<SpecialStoragePolicy>& special_storage_policy, |
87 const std::set<GURL>& exceptions, | 87 const std::set<GURL>& exceptions, |
88 const std::map<GURL, int64_t>& usage_map, | 88 const std::map<GURL, int64_t>& usage_map, |
89 int64_t global_quota, | 89 int64_t global_quota, |
90 const GetOriginCallback& callback) = 0; | 90 const GetOriginCallback& callback) = 0; |
91 }; | 91 }; |
92 | 92 |
93 // An interface called by QuotaTemporaryStorageEvictor. | 93 // An interface called by QuotaTemporaryStorageEvictor. |
94 class STORAGE_EXPORT QuotaEvictionHandler { | 94 class STORAGE_EXPORT QuotaEvictionHandler { |
95 public: | 95 public: |
96 using EvictOriginDataCallback = StatusCallback; | 96 using EvictOriginDataCallback = StatusCallback; |
97 using UsageAndQuotaCallback = base::Callback< | 97 using XUsageAndQuotaCallback = base::Callback< |
98 void(QuotaStatusCode status, const UsageAndQuota& usage_and_quota)>; | 98 void(QuotaStatusCode status, const XUsageAndQuota& usage_and_quota)>; |
99 using VolumeInfoCallback = base::Callback< | 99 using VolumeInfoCallback = base::Callback< |
100 void(bool success, uint64_t available_space, uint64_t total_space)>; | 100 void(bool success, uint64_t available_space, uint64_t total_space)>; |
101 | 101 |
102 // Returns next origin to evict. It might return an empty GURL when there are | 102 // Returns next origin to evict. It might return an empty GURL when there are |
103 // no evictable origins. | 103 // no evictable origins. |
104 virtual void GetEvictionOrigin(StorageType type, | 104 virtual void GetEvictionOrigin(StorageType type, |
105 const std::set<GURL>& extra_exceptions, | 105 const std::set<GURL>& extra_exceptions, |
106 int64_t global_quota, | 106 int64_t global_quota, |
107 const GetOriginCallback& callback) = 0; | 107 const GetOriginCallback& callback) = 0; |
108 | 108 |
109 virtual void EvictOriginData( | 109 virtual void EvictOriginData( |
110 const GURL& origin, | 110 const GURL& origin, |
111 StorageType type, | 111 StorageType type, |
112 const EvictOriginDataCallback& callback) = 0; | 112 const EvictOriginDataCallback& callback) = 0; |
113 | 113 |
114 virtual void AsyncGetVolumeInfo(const VolumeInfoCallback& callback) = 0; | 114 virtual void AsyncGetVolumeInfo(const VolumeInfoCallback& callback) = 0; |
115 virtual void GetUsageAndQuotaForEviction( | 115 virtual void GetUsageAndQuotaForEviction( |
116 const UsageAndQuotaCallback& callback) = 0; | 116 const XUsageAndQuotaCallback& callback) = 0; |
117 | 117 |
118 protected: | 118 protected: |
119 virtual ~QuotaEvictionHandler() {} | 119 virtual ~QuotaEvictionHandler() {} |
120 }; | 120 }; |
121 | 121 |
122 struct UsageInfo { | 122 struct UsageInfo { |
123 UsageInfo(const std::string& host, StorageType type, int64_t usage) | 123 UsageInfo(const std::string& host, StorageType type, int64_t usage) |
124 : host(host), type(type), usage(usage) {} | 124 : host(host), type(type), usage(usage) {} |
125 std::string host; | 125 std::string host; |
126 StorageType type; | 126 StorageType type; |
127 int64_t usage; | 127 int64_t usage; |
128 }; | 128 }; |
129 | 129 |
130 // todo: new file temporary_pool_config | |
131 // Configuration parameters the storage lib embedder must provide | |
132 // to the QuotaManager. | |
133 struct TemporaryStorageConfiguration { | |
michaeln
2016/07/27 19:57:47
wdyt about the set of config params?
| |
134 TemporaryStorageConfiguration() {} | |
135 | |
136 // The target size of the shared pool of disk space the quota system allows | |
jsbell
2016/07/27 20:18:30
Possibly extend this comment with a concrete examp
michaeln
2016/07/28 02:06:28
Done.
| |
137 // for use by by websites using HTML5 storage apis. This is not a hard limit, | |
138 // it serves as the basis for computing the quota of an individual site. | |
139 int64_t pool_size = 0; | |
jsbell
2016/07/27 20:18:30
nit: document units
Some of these are bytes, some
michaeln
2016/07/28 02:06:28
Done.
| |
140 | |
141 // The amount of space that must remain available on the storage | |
142 // volume. As the volume approaches this limit, the quota system gets | |
143 // more aggressive about evicting data and disallowing new data. | |
144 int64_t must_remain_available = 0; | |
145 | |
146 // The target number of sites that will be sharing the larger pool. | |
147 // Nominally, an individual site is allowed to use up to | |
148 // pool_size / per_host_portion. | |
149 int per_host_portion = 5; | |
jsbell
2016/07/27 20:18:30
Given that we use this as a divisor, should probab
michaeln
2016/07/28 02:06:27
switched to a number of bytes value
| |
150 | |
151 // The quota system querries the embedder for the TemporaryPoolConfiguration, | |
152 // but will rate limit the frequency of the querries to no more than once | |
153 // per refresh interval. | |
154 base::TimeDelta refresh_interval = base::TimeDelta::Max(); | |
155 }; | |
156 | |
157 // Function type used to return the temp storage config in response to a | |
158 // GetTemporaryStorageConfigurationFunc invocation. | |
159 using TemporaryStorageConfigurationCallback = | |
160 base::Callback<void(const TemporaryStorageConfiguration&)>; | |
161 | |
162 // Function type used to query the embedder about the temporary pool . | |
163 // configuration. This function is invoked on the UI thread. | |
164 using GetTemporaryStorageConfigurationFunc = base::Callback< | |
165 void(const base::FilePath& profile_path, bool is_incognito, | |
166 TemporaryStorageConfigurationCallback callback)>; | |
167 | |
130 // The quota manager class. This class is instantiated per profile and | 168 // The quota manager class. This class is instantiated per profile and |
131 // held by the profile. With the exception of the constructor and the | 169 // held by the profile. With the exception of the constructor and the |
132 // proxy() method, all methods should only be called on the IO thread. | 170 // proxy() method, all methods should only be called on the IO thread. |
133 class STORAGE_EXPORT QuotaManager | 171 class STORAGE_EXPORT QuotaManager |
134 : public QuotaTaskObserver, | 172 : public QuotaTaskObserver, |
135 public QuotaEvictionHandler, | 173 public QuotaEvictionHandler, |
136 public base::RefCountedThreadSafe<QuotaManager, QuotaManagerDeleter> { | 174 public base::RefCountedThreadSafe<QuotaManager, QuotaManagerDeleter> { |
137 public: | 175 public: |
138 typedef base::Callback<void(QuotaStatusCode, | 176 typedef base::Callback<void(QuotaStatusCode, |
139 int64_t /* usage */, | 177 int64_t /* usage */, |
140 int64_t /* quota */)> GetUsageAndQuotaCallback; | 178 int64_t /* quota */)> GetUsageAndQuotaCallback; |
141 | 179 |
142 static const int64_t kIncognitoDefaultQuotaLimit; | 180 static const int64_t kIncognitoDefaultQuotaLimit; |
143 static const int64_t kNoLimit; | 181 static const int64_t kNoLimit; |
144 | 182 |
145 QuotaManager( | 183 QuotaManager( |
146 bool is_incognito, | 184 bool is_incognito, |
147 const base::FilePath& profile_path, | 185 const base::FilePath& profile_path, |
148 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread, | 186 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread, |
149 const scoped_refptr<base::SequencedTaskRunner>& db_thread, | 187 const scoped_refptr<base::SequencedTaskRunner>& db_thread, |
150 const scoped_refptr<SpecialStoragePolicy>& special_storage_policy); | 188 const scoped_refptr<SpecialStoragePolicy>& special_storage_policy, |
189 GetTemporaryStorageConfigurationFunc get_storage_config_function); | |
190 | |
191 const TemporaryStorageConfiguration& storage_config() { | |
192 return storage_config_; | |
193 } | |
194 void SetTemporaryStorageConfiguration( | |
195 const TemporaryStorageConfiguration& storage_config); | |
151 | 196 |
152 // Returns a proxy object that can be used on any thread. | 197 // Returns a proxy object that can be used on any thread. |
153 QuotaManagerProxy* proxy() { return proxy_.get(); } | 198 QuotaManagerProxy* proxy() { return proxy_.get(); } |
154 | 199 |
155 // Called by clients or webapps. Returns usage per host. | 200 // Called by clients or webapps. Returns usage per host. |
156 void GetUsageInfo(const GetUsageInfoCallback& callback); | 201 void GetUsageInfo(const GetUsageInfoCallback& callback); |
157 | 202 |
158 // Called by Web Apps. | 203 // Called by Web Apps. |
159 // This method is declared as virtual to allow test code to override it. | 204 // This method is declared as virtual to allow test code to override it. |
160 virtual void GetUsageAndQuotaForWebApps( | 205 virtual void GetUsageAndQuotaForWebApps( |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 virtual void DeleteOriginData(const GURL& origin, | 261 virtual void DeleteOriginData(const GURL& origin, |
217 StorageType type, | 262 StorageType type, |
218 int quota_client_mask, | 263 int quota_client_mask, |
219 const StatusCallback& callback); | 264 const StatusCallback& callback); |
220 void DeleteHostData(const std::string& host, | 265 void DeleteHostData(const std::string& host, |
221 StorageType type, | 266 StorageType type, |
222 int quota_client_mask, | 267 int quota_client_mask, |
223 const StatusCallback& callback); | 268 const StatusCallback& callback); |
224 | 269 |
225 // Called by UI and internal modules. | 270 // Called by UI and internal modules. |
226 void GetAvailableSpace(const AvailableSpaceCallback& callback); | 271 void xGetAvailableSpace(const AvailableSpaceCallback& callback); |
227 void GetTemporaryGlobalQuota(const QuotaCallback& callback); | 272 void GetTemporaryGlobalQuota(const QuotaCallback& callback); |
228 | 273 |
229 // Ok to call with NULL callback. | |
230 void SetTemporaryGlobalOverrideQuota(int64_t new_quota, | |
231 const QuotaCallback& callback); | |
232 | |
233 void GetPersistentHostQuota(const std::string& host, | 274 void GetPersistentHostQuota(const std::string& host, |
234 const QuotaCallback& callback); | 275 const QuotaCallback& callback); |
235 void SetPersistentHostQuota(const std::string& host, | 276 void SetPersistentHostQuota(const std::string& host, |
236 int64_t new_quota, | 277 int64_t new_quota, |
237 const QuotaCallback& callback); | 278 const QuotaCallback& callback); |
238 void GetGlobalUsage(StorageType type, const GlobalUsageCallback& callback); | 279 void GetGlobalUsage(StorageType type, const GlobalUsageCallback& callback); |
239 void GetHostUsage(const std::string& host, StorageType type, | 280 void GetHostUsage(const std::string& host, StorageType type, |
240 const UsageCallback& callback); | 281 const UsageCallback& callback); |
241 void GetHostUsage(const std::string& host, StorageType type, | 282 void GetHostUsage(const std::string& host, StorageType type, |
242 QuotaClient::ID client_id, | 283 QuotaClient::ID client_id, |
243 const UsageCallback& callback); | 284 const UsageCallback& callback); |
244 | 285 |
245 bool IsTrackingHostUsage(StorageType type, QuotaClient::ID client_id) const; | 286 bool IsTrackingHostUsage(StorageType type, QuotaClient::ID client_id) const; |
246 | 287 |
247 void GetStatistics(std::map<std::string, std::string>* statistics); | 288 void GetStatistics(std::map<std::string, std::string>* statistics); |
248 | 289 |
249 bool IsStorageUnlimited(const GURL& origin, StorageType type) const; | 290 bool IsStorageUnlimited(const GURL& origin, StorageType type) const; |
250 | 291 |
251 bool CanQueryDiskSize(const GURL& origin) const { | 292 bool CanQueryDiskSize(const GURL& origin) const { |
293 // TODO: not currently used? | |
252 return special_storage_policy_.get() && | 294 return special_storage_policy_.get() && |
253 special_storage_policy_->CanQueryDiskSize(origin); | 295 special_storage_policy_->CanQueryDiskSize(origin); |
254 } | 296 } |
255 | 297 |
256 virtual void GetOriginsModifiedSince(StorageType type, | 298 virtual void GetOriginsModifiedSince(StorageType type, |
257 base::Time modified_since, | 299 base::Time modified_since, |
258 const GetOriginsCallback& callback); | 300 const GetOriginsCallback& callback); |
259 | 301 |
260 bool ResetUsageTracker(StorageType type); | 302 bool ResetUsageTracker(StorageType type); |
261 | 303 |
262 // Used to register/deregister observers that wish to monitor storage events. | 304 // Used to register/deregister observers that wish to monitor storage events. |
263 void AddStorageObserver(StorageObserver* observer, | 305 void AddStorageObserver(StorageObserver* observer, |
264 const StorageObserver::MonitorParams& params); | 306 const StorageObserver::MonitorParams& params); |
265 void RemoveStorageObserver(StorageObserver* observer); | 307 void RemoveStorageObserver(StorageObserver* observer); |
266 void RemoveStorageObserverForFilter(StorageObserver* observer, | 308 void RemoveStorageObserverForFilter(StorageObserver* observer, |
267 const StorageObserver::Filter& filter); | 309 const StorageObserver::Filter& filter); |
268 | 310 |
311 static bool GetVolumeInfo(const base::FilePath& path, | |
312 uint64_t* available_space, | |
313 uint64_t* total_size); | |
314 | |
269 // Determines the portion of the temp pool that can be | 315 // Determines the portion of the temp pool that can be |
270 // utilized by a single host (ie. 5 for 20%). | 316 // utilized by a single host (ie. 5 for 20%). |
271 static const int kPerHostTemporaryPortion; | 317 static const int kPerHostTemporaryPortion; |
272 | 318 |
273 static const int64_t kPerHostPersistentQuotaLimit; | 319 static const int64_t kPerHostPersistentQuotaLimit; |
274 | 320 |
275 static const char kDatabaseName[]; | 321 static const char kDatabaseName[]; |
276 | 322 |
277 static const int kThresholdOfErrorsToBeBlacklisted; | 323 static const int kThresholdOfErrorsToBeBlacklisted; |
278 | 324 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
326 typedef base::Callback<void(const QuotaTableEntries&)> | 372 typedef base::Callback<void(const QuotaTableEntries&)> |
327 DumpQuotaTableCallback; | 373 DumpQuotaTableCallback; |
328 typedef base::Callback<void(const OriginInfoTableEntries&)> | 374 typedef base::Callback<void(const OriginInfoTableEntries&)> |
329 DumpOriginInfoTableCallback; | 375 DumpOriginInfoTableCallback; |
330 | 376 |
331 typedef CallbackQueue<base::Closure> ClosureQueue; | 377 typedef CallbackQueue<base::Closure> ClosureQueue; |
332 typedef CallbackQueue<AvailableSpaceCallback, QuotaStatusCode, int64_t> | 378 typedef CallbackQueue<AvailableSpaceCallback, QuotaStatusCode, int64_t> |
333 AvailableSpaceCallbackQueue; | 379 AvailableSpaceCallbackQueue; |
334 typedef CallbackQueueMap<QuotaCallback, std::string, QuotaStatusCode, int64_t> | 380 typedef CallbackQueueMap<QuotaCallback, std::string, QuotaStatusCode, int64_t> |
335 HostQuotaCallbackMap; | 381 HostQuotaCallbackMap; |
336 | 382 using TemporaryConfigCallbackQueue = |
383 CallbackQueue<TemporaryStorageConfigurationCallback, | |
384 const TemporaryStorageConfiguration&>; | |
337 struct EvictionContext { | 385 struct EvictionContext { |
338 EvictionContext(); | 386 EvictionContext(); |
339 virtual ~EvictionContext(); | 387 virtual ~EvictionContext(); |
340 GURL evicted_origin; | 388 GURL evicted_origin; |
341 StorageType evicted_type; | 389 StorageType evicted_type; |
342 | 390 |
343 EvictOriginDataCallback evict_origin_data_callback; | 391 EvictOriginDataCallback evict_origin_data_callback; |
344 }; | 392 }; |
345 | 393 |
346 typedef QuotaEvictionHandler::UsageAndQuotaCallback | |
347 UsageAndQuotaDispatcherCallback; | |
348 | |
349 // This initialization method is lazily called on the IO thread | 394 // This initialization method is lazily called on the IO thread |
350 // when the first quota manager API is called. | 395 // when the first quota manager API is called. |
351 // Initialize must be called after all quota clients are added to the | 396 // Initialize must be called after all quota clients are added to the |
352 // manager by RegisterStorage. | 397 // manager by RegisterStorage. |
353 void LazyInitialize(); | 398 void LazyInitialize(); |
354 | 399 |
355 // Called by clients via proxy. | 400 // Called by clients via proxy. |
356 // Registers a quota client to the manager. | 401 // Registers a quota client to the manager. |
357 // The client must remain valid until OnQuotaManagerDestored is called. | 402 // The client must remain valid until OnQuotaManagerDestored is called. |
358 void RegisterClient(QuotaClient* client); | 403 void RegisterClient(QuotaClient* client); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
407 | 452 |
408 // QuotaEvictionHandler. | 453 // QuotaEvictionHandler. |
409 void GetEvictionOrigin(StorageType type, | 454 void GetEvictionOrigin(StorageType type, |
410 const std::set<GURL>& extra_exceptions, | 455 const std::set<GURL>& extra_exceptions, |
411 int64_t global_quota, | 456 int64_t global_quota, |
412 const GetOriginCallback& callback) override; | 457 const GetOriginCallback& callback) override; |
413 void EvictOriginData(const GURL& origin, | 458 void EvictOriginData(const GURL& origin, |
414 StorageType type, | 459 StorageType type, |
415 const EvictOriginDataCallback& callback) override; | 460 const EvictOriginDataCallback& callback) override; |
416 void GetUsageAndQuotaForEviction( | 461 void GetUsageAndQuotaForEviction( |
417 const UsageAndQuotaCallback& callback) override; | 462 const XUsageAndQuotaCallback& callback) override; |
418 void AsyncGetVolumeInfo(const VolumeInfoCallback& callback) override; | 463 void AsyncGetVolumeInfo(const VolumeInfoCallback& callback) override; |
419 | 464 |
420 void DidGetVolumeInfo( | 465 void DidGetVolumeInfo( |
421 const VolumeInfoCallback& callback, | 466 const VolumeInfoCallback& callback, |
422 uint64_t* available_space, uint64_t* total_space, bool success); | 467 uint64_t* available_space, uint64_t* total_space, bool success); |
423 | 468 |
424 void GetLRUOrigin(StorageType type, const GetOriginCallback& callback); | 469 void GetLRUOrigin(StorageType type, const GetOriginCallback& callback); |
425 | 470 |
426 void DidSetTemporaryGlobalOverrideQuota(const QuotaCallback& callback, | |
427 const int64_t* new_quota, | |
428 bool success); | |
429 void DidGetPersistentHostQuota(const std::string& host, | 471 void DidGetPersistentHostQuota(const std::string& host, |
430 const int64_t* quota, | 472 const int64_t* quota, |
431 bool success); | 473 bool success); |
432 void DidSetPersistentHostQuota(const std::string& host, | 474 void DidSetPersistentHostQuota(const std::string& host, |
433 const QuotaCallback& callback, | 475 const QuotaCallback& callback, |
434 const int64_t* new_quota, | 476 const int64_t* new_quota, |
435 bool success); | 477 bool success); |
436 void DidInitialize(int64_t* temporary_quota_override, | |
437 int64_t* desired_available_space, | |
438 bool success); | |
439 void DidGetLRUOrigin(const GURL* origin, | 478 void DidGetLRUOrigin(const GURL* origin, |
440 bool success); | 479 bool success); |
441 void DidGetInitialTemporaryGlobalQuota(base::TimeTicks start_ticks, | 480 void DidGetInitialTemporaryGlobalQuota(base::TimeTicks start_ticks, |
442 QuotaStatusCode status, | 481 QuotaStatusCode status, |
443 int64_t quota_unused); | 482 int64_t quota_unused); |
444 void DidInitializeTemporaryOriginsInfo(bool success); | 483 void DidInitializeTemporaryOriginsInfo(bool success); |
445 void DidGetAvailableSpace(int64_t space); | 484 void DidGetAvailableSpace(int64_t space); |
485 void GetTemporaryStorageConfig( | |
486 const TemporaryStorageConfigurationCallback& callback); | |
487 void DidGetTemporaryStorageConfig( | |
488 const TemporaryStorageConfiguration& storage_config); | |
489 | |
446 void DidDatabaseWork(bool success); | 490 void DidDatabaseWork(bool success); |
447 | 491 |
448 void DeleteOnCorrectThread() const; | 492 void DeleteOnCorrectThread() const; |
449 | 493 |
450 void PostTaskAndReplyWithResultForDBThread( | 494 void PostTaskAndReplyWithResultForDBThread( |
451 const tracked_objects::Location& from_here, | 495 const tracked_objects::Location& from_here, |
452 const base::Callback<bool(QuotaDatabase*)>& task, | 496 const base::Callback<bool(QuotaDatabase*)>& task, |
453 const base::Callback<void(bool)>& reply); | 497 const base::Callback<void(bool)>& reply); |
454 | 498 |
455 static int64_t CallGetAmountOfFreeDiskSpace( | 499 static int64_t CallGetAmountOfFreeDiskSpace( |
456 GetVolumeInfoFn get_vol_info_fn, | 500 GetVolumeInfoFn get_vol_info_fn, |
457 const base::FilePath& profile_path); | 501 const base::FilePath& profile_path); |
458 static bool GetVolumeInfo(const base::FilePath& path, | |
459 uint64_t* available_space, | |
460 uint64_t* total_size); | |
461 | 502 |
462 const bool is_incognito_; | 503 const bool is_incognito_; |
463 const base::FilePath profile_path_; | 504 const base::FilePath profile_path_; |
464 | 505 |
465 scoped_refptr<QuotaManagerProxy> proxy_; | 506 scoped_refptr<QuotaManagerProxy> proxy_; |
466 bool db_disabled_; | 507 bool db_disabled_; |
467 bool eviction_disabled_; | 508 bool eviction_disabled_; |
468 scoped_refptr<base::SingleThreadTaskRunner> io_thread_; | 509 scoped_refptr<base::SingleThreadTaskRunner> io_thread_; |
469 scoped_refptr<base::SequencedTaskRunner> db_thread_; | 510 scoped_refptr<base::SequencedTaskRunner> db_thread_; |
470 mutable std::unique_ptr<QuotaDatabase> database_; | 511 mutable std::unique_ptr<QuotaDatabase> database_; |
471 | 512 |
513 GetTemporaryStorageConfigurationFunc get_config_function_; | |
514 scoped_refptr<base::TaskRunner> get_config_task_runner_; | |
515 TemporaryStorageConfiguration storage_config_; | |
516 base::TimeTicks storage_config_timestamp_; | |
517 TemporaryConfigCallbackQueue storage_config_callbacks_; | |
518 | |
472 GetOriginCallback lru_origin_callback_; | 519 GetOriginCallback lru_origin_callback_; |
473 std::set<GURL> access_notified_origins_; | 520 std::set<GURL> access_notified_origins_; |
474 | 521 |
475 QuotaClientList clients_; | 522 QuotaClientList clients_; |
476 | 523 |
477 std::unique_ptr<UsageTracker> temporary_usage_tracker_; | 524 std::unique_ptr<UsageTracker> temporary_usage_tracker_; |
478 std::unique_ptr<UsageTracker> persistent_usage_tracker_; | 525 std::unique_ptr<UsageTracker> persistent_usage_tracker_; |
479 std::unique_ptr<UsageTracker> syncable_usage_tracker_; | 526 std::unique_ptr<UsageTracker> syncable_usage_tracker_; |
480 // TODO(michaeln): Need a way to clear the cache, drop and | 527 // TODO(michaeln): Need a way to clear the cache, drop and |
481 // reinstantiate the trackers when they're not handling requests. | 528 // reinstantiate the trackers when they're not handling requests. |
482 | 529 |
483 std::unique_ptr<QuotaTemporaryStorageEvictor> temporary_storage_evictor_; | 530 std::unique_ptr<QuotaTemporaryStorageEvictor> temporary_storage_evictor_; |
484 EvictionContext eviction_context_; | 531 EvictionContext eviction_context_; |
485 std::unique_ptr<QuotaEvictionPolicy> temporary_storage_eviction_policy_; | 532 std::unique_ptr<QuotaEvictionPolicy> temporary_storage_eviction_policy_; |
486 bool is_getting_eviction_origin_; | 533 bool is_getting_eviction_origin_; |
487 | 534 |
488 ClosureQueue db_initialization_callbacks_; | |
489 AvailableSpaceCallbackQueue available_space_callbacks_; | 535 AvailableSpaceCallbackQueue available_space_callbacks_; |
490 HostQuotaCallbackMap persistent_host_quota_callbacks_; | 536 HostQuotaCallbackMap persistent_host_quota_callbacks_; |
491 | 537 |
492 bool temporary_quota_initialized_; | |
493 int64_t temporary_quota_override_; | |
494 int64_t desired_available_space_; | |
495 | |
496 // Map from origin to count. | 538 // Map from origin to count. |
497 std::map<GURL, int> origins_in_use_; | 539 std::map<GURL, int> origins_in_use_; |
498 // Map from origin to error count. | 540 // Map from origin to error count. |
499 std::map<GURL, int> origins_in_error_; | 541 std::map<GURL, int> origins_in_error_; |
500 | 542 |
501 scoped_refptr<SpecialStoragePolicy> special_storage_policy_; | 543 scoped_refptr<SpecialStoragePolicy> special_storage_policy_; |
502 | 544 |
503 base::RepeatingTimer histogram_timer_; | 545 base::RepeatingTimer histogram_timer_; |
504 | 546 |
505 // Pointer to the function used to get volume information. This is | 547 // Pointer to the function used to get volume information. This is |
(...skipping 10 matching lines...) Expand all Loading... | |
516 | 558 |
517 struct QuotaManagerDeleter { | 559 struct QuotaManagerDeleter { |
518 static void Destruct(const QuotaManager* manager) { | 560 static void Destruct(const QuotaManager* manager) { |
519 manager->DeleteOnCorrectThread(); | 561 manager->DeleteOnCorrectThread(); |
520 } | 562 } |
521 }; | 563 }; |
522 | 564 |
523 } // namespace storage | 565 } // namespace storage |
524 | 566 |
525 #endif // STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_H_ | 567 #endif // STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_H_ |
OLD | NEW |