Chromium Code Reviews| 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 <deque> | 8 #include <deque> |
| 9 #include <list> | 9 #include <list> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 return origins_in_use_.find(origin) != origins_in_use_.end(); | 193 return origins_in_use_.find(origin) != origins_in_use_.end(); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void SetUsageCacheEnabled(QuotaClient::ID client_id, | 196 void SetUsageCacheEnabled(QuotaClient::ID client_id, |
| 197 const GURL& origin, | 197 const GURL& origin, |
| 198 StorageType type, | 198 StorageType type, |
| 199 bool enabled); | 199 bool enabled); |
| 200 | 200 |
| 201 // Set the eviction policy to use when choosing an origin to evict. | 201 // Set the eviction policy to use when choosing an origin to evict. |
| 202 void SetQuotaEvictionPolicy(StorageType type, | 202 void SetQuotaEvictionPolicy(StorageType type, |
| 203 scoped_ptr<QuotaEvictionPolicy> policy); | 203 scoped_ptr<QuotaEvictionPolicy> policy); |
|
raymes
2015/09/22 07:02:42
(I should've noticed this in the other CL too) I t
calamity
2015/09/24 06:50:31
I just sent out a CL that hooks it all up. Also, i
| |
| 204 | 204 |
| 205 // DeleteOriginData and DeleteHostData (surprisingly enough) delete data of a | 205 // DeleteOriginData and DeleteHostData (surprisingly enough) delete data of a |
| 206 // particular StorageType associated with either a specific origin or set of | 206 // particular StorageType associated with either a specific origin or set of |
| 207 // origins. Each method additionally requires a |quota_client_mask| which | 207 // origins. Each method additionally requires a |quota_client_mask| which |
| 208 // specifies the types of QuotaClients to delete from the origin. This is | 208 // specifies the types of QuotaClients to delete from the origin. This is |
| 209 // specified by the caller as a bitmask built from QuotaClient::IDs. Setting | 209 // specified by the caller as a bitmask built from QuotaClient::IDs. Setting |
| 210 // the mask to QuotaClient::kAllClientsMask will remove all clients from the | 210 // the mask to QuotaClient::kAllClientsMask will remove all clients from the |
| 211 // origin, regardless of type. | 211 // origin, regardless of type. |
| 212 virtual void DeleteOriginData(const GURL& origin, | 212 virtual void DeleteOriginData(const GURL& origin, |
| 213 StorageType type, | 213 StorageType type, |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 | 299 |
| 300 class GetUsageInfoTask; | 300 class GetUsageInfoTask; |
| 301 | 301 |
| 302 class OriginDataDeleter; | 302 class OriginDataDeleter; |
| 303 class HostDataDeleter; | 303 class HostDataDeleter; |
| 304 | 304 |
| 305 class GetModifiedSinceHelper; | 305 class GetModifiedSinceHelper; |
| 306 class DumpQuotaTableHelper; | 306 class DumpQuotaTableHelper; |
| 307 class DumpOriginInfoTableHelper; | 307 class DumpOriginInfoTableHelper; |
| 308 | 308 |
| 309 class LRUOriginEvictionPolicy; | |
| 310 | |
| 309 typedef QuotaDatabase::QuotaTableEntry QuotaTableEntry; | 311 typedef QuotaDatabase::QuotaTableEntry QuotaTableEntry; |
| 310 typedef QuotaDatabase::OriginInfoTableEntry OriginInfoTableEntry; | 312 typedef QuotaDatabase::OriginInfoTableEntry OriginInfoTableEntry; |
| 311 typedef std::vector<QuotaTableEntry> QuotaTableEntries; | 313 typedef std::vector<QuotaTableEntry> QuotaTableEntries; |
| 312 typedef std::vector<OriginInfoTableEntry> OriginInfoTableEntries; | 314 typedef std::vector<OriginInfoTableEntry> OriginInfoTableEntries; |
| 313 | 315 |
| 314 // Function pointer type used to store the function which returns the | 316 // Function pointer type used to store the function which returns the |
| 315 // available disk space for the disk containing the given FilePath. | 317 // available disk space for the disk containing the given FilePath. |
| 316 typedef int64 (*GetAvailableDiskSpaceFn)(const base::FilePath&); | 318 typedef int64 (*GetAvailableDiskSpaceFn)(const base::FilePath&); |
| 317 | 319 |
| 318 typedef base::Callback<void(const QuotaTableEntries&)> | 320 typedef base::Callback<void(const QuotaTableEntries&)> |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 402 void DidGetPersistentHostQuota(const std::string& host, | 404 void DidGetPersistentHostQuota(const std::string& host, |
| 403 const int64* quota, | 405 const int64* quota, |
| 404 bool success); | 406 bool success); |
| 405 void DidSetPersistentHostQuota(const std::string& host, | 407 void DidSetPersistentHostQuota(const std::string& host, |
| 406 const QuotaCallback& callback, | 408 const QuotaCallback& callback, |
| 407 const int64* new_quota, | 409 const int64* new_quota, |
| 408 bool success); | 410 bool success); |
| 409 void DidInitialize(int64* temporary_quota_override, | 411 void DidInitialize(int64* temporary_quota_override, |
| 410 int64* desired_available_space, | 412 int64* desired_available_space, |
| 411 bool success); | 413 bool success); |
| 412 void DidGetLRUOrigin(const GURL* origin, | |
| 413 bool success); | |
| 414 void DidGetInitialTemporaryGlobalQuota(QuotaStatusCode status, | 414 void DidGetInitialTemporaryGlobalQuota(QuotaStatusCode status, |
| 415 int64 quota_unused); | 415 int64 quota_unused); |
| 416 void DidInitializeTemporaryOriginsInfo(bool success); | 416 void DidInitializeTemporaryOriginsInfo(bool success); |
| 417 void DidGetAvailableSpace(int64 space); | 417 void DidGetAvailableSpace(int64 space); |
| 418 void DidDatabaseWork(bool success); | 418 void DidDatabaseWork(bool success); |
| 419 | 419 |
| 420 void DeleteOnCorrectThread() const; | 420 void DeleteOnCorrectThread() const; |
| 421 | 421 |
| 422 void PostTaskAndReplyWithResultForDBThread( | 422 void PostTaskAndReplyWithResultForDBThread( |
| 423 const tracked_objects::Location& from_here, | 423 const tracked_objects::Location& from_here, |
| 424 const base::Callback<bool(QuotaDatabase*)>& task, | 424 const base::Callback<bool(QuotaDatabase*)>& task, |
| 425 const base::Callback<void(bool)>& reply); | 425 const base::Callback<void(bool)>& reply); |
| 426 | 426 |
| 427 const bool is_incognito_; | 427 const bool is_incognito_; |
| 428 const base::FilePath profile_path_; | 428 const base::FilePath profile_path_; |
| 429 | 429 |
| 430 scoped_refptr<QuotaManagerProxy> proxy_; | 430 scoped_refptr<QuotaManagerProxy> proxy_; |
| 431 bool db_disabled_; | 431 bool db_disabled_; |
| 432 bool eviction_disabled_; | 432 bool eviction_disabled_; |
| 433 scoped_refptr<base::SingleThreadTaskRunner> io_thread_; | 433 scoped_refptr<base::SingleThreadTaskRunner> io_thread_; |
| 434 scoped_refptr<base::SequencedTaskRunner> db_thread_; | 434 scoped_refptr<base::SequencedTaskRunner> db_thread_; |
| 435 mutable scoped_ptr<QuotaDatabase> database_; | 435 mutable scoped_ptr<QuotaDatabase> database_; |
| 436 | 436 |
| 437 GetOriginCallback lru_origin_callback_; | |
| 438 std::set<GURL> access_notified_origins_; | 437 std::set<GURL> access_notified_origins_; |
| 439 | 438 |
| 440 QuotaClientList clients_; | 439 QuotaClientList clients_; |
| 441 | 440 |
| 442 scoped_ptr<UsageTracker> temporary_usage_tracker_; | 441 scoped_ptr<UsageTracker> temporary_usage_tracker_; |
| 443 scoped_ptr<UsageTracker> persistent_usage_tracker_; | 442 scoped_ptr<UsageTracker> persistent_usage_tracker_; |
| 444 scoped_ptr<UsageTracker> syncable_usage_tracker_; | 443 scoped_ptr<UsageTracker> syncable_usage_tracker_; |
| 445 // TODO(michaeln): Need a way to clear the cache, drop and | 444 // TODO(michaeln): Need a way to clear the cache, drop and |
| 446 // reinstantiate the trackers when they're not handling requests. | 445 // reinstantiate the trackers when they're not handling requests. |
| 447 | 446 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 467 base::RepeatingTimer<QuotaManager> histogram_timer_; | 466 base::RepeatingTimer<QuotaManager> histogram_timer_; |
| 468 | 467 |
| 469 // Pointer to the function used to get the available disk space. This is | 468 // Pointer to the function used to get the available disk space. This is |
| 470 // overwritten by QuotaManagerTest in order to attain a deterministic reported | 469 // overwritten by QuotaManagerTest in order to attain a deterministic reported |
| 471 // value. The default value points to base::SysInfo::AmountOfFreeDiskSpace. | 470 // value. The default value points to base::SysInfo::AmountOfFreeDiskSpace. |
| 472 GetAvailableDiskSpaceFn get_disk_space_fn_; | 471 GetAvailableDiskSpaceFn get_disk_space_fn_; |
| 473 | 472 |
| 474 scoped_ptr<StorageMonitor> storage_monitor_; | 473 scoped_ptr<StorageMonitor> storage_monitor_; |
| 475 | 474 |
| 476 base::ScopedPtrMap<StorageType, scoped_ptr<QuotaEvictionPolicy>> | 475 base::ScopedPtrMap<StorageType, scoped_ptr<QuotaEvictionPolicy>> |
| 477 eviction_policy_map_; | 476 eviction_policy_map_; |
|
raymes
2015/09/22 06:58:58
(I should have picked this up in the other CL) Con
calamity
2015/09/24 06:50:31
Done.
| |
| 478 | 477 |
| 479 bool is_getting_eviction_origin_; | 478 bool is_getting_eviction_origin_; |
| 480 | 479 |
| 481 base::WeakPtrFactory<QuotaManager> weak_factory_; | 480 base::WeakPtrFactory<QuotaManager> weak_factory_; |
| 482 | 481 |
| 483 DISALLOW_COPY_AND_ASSIGN(QuotaManager); | 482 DISALLOW_COPY_AND_ASSIGN(QuotaManager); |
| 484 }; | 483 }; |
| 485 | 484 |
| 486 struct QuotaManagerDeleter { | 485 struct QuotaManagerDeleter { |
| 487 static void Destruct(const QuotaManager* manager) { | 486 static void Destruct(const QuotaManager* manager) { |
| 488 manager->DeleteOnCorrectThread(); | 487 manager->DeleteOnCorrectThread(); |
| 489 } | 488 } |
| 490 }; | 489 }; |
| 491 | 490 |
| 492 } // namespace storage | 491 } // namespace storage |
| 493 | 492 |
| 494 #endif // STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_H_ | 493 #endif // STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_H_ |
| OLD | NEW |