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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 int64 quota; | 62 int64 quota; |
| 63 int64 available_disk_space; | 63 int64 available_disk_space; |
| 64 | 64 |
| 65 UsageAndQuota(); | 65 UsageAndQuota(); |
| 66 UsageAndQuota(int64 usage, | 66 UsageAndQuota(int64 usage, |
| 67 int64 global_limited_usage, | 67 int64 global_limited_usage, |
| 68 int64 quota, | 68 int64 quota, |
| 69 int64 available_disk_space); | 69 int64 available_disk_space); |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 // TODO(calamity): Use this in the temporary storage eviction path. | |
| 73 // An interface for deciding which origin's temporary storage should be evicted | |
| 74 // when the quota is exceeded. | |
| 75 class STORAGE_EXPORT QuotaEvictionPolicy { | |
| 76 public: | |
| 77 // Returns the next origin to evict. It might return an empty GURL when there | |
| 78 // are no evictable origins. | |
| 79 virtual void GetEvictionOrigin( | |
| 80 const scoped_refptr<SpecialStoragePolicy>& special_storage_policy, | |
| 81 const std::map<GURL, int64>& usage_map, | |
| 82 int64 global_quota, | |
| 83 const GetOriginCallback& callback) = 0; | |
| 84 | |
| 85 protected: | |
| 86 ~QuotaEvictionPolicy() {} | |
|
michaeln
2015/08/26 23:32:37
Should this dtor be virtual and/or public?
What's
calamity
2015/08/27 05:05:01
Oops. Yes, this destructor doesn't need to be defi
| |
| 87 }; | |
| 88 | |
| 72 // An interface called by QuotaTemporaryStorageEvictor. | 89 // An interface called by QuotaTemporaryStorageEvictor. |
| 73 class STORAGE_EXPORT QuotaEvictionHandler { | 90 class STORAGE_EXPORT QuotaEvictionHandler { |
| 74 public: | 91 public: |
| 75 typedef base::Callback<void(const GURL&)> GetLRUOriginCallback; | |
| 76 typedef StatusCallback EvictOriginDataCallback; | 92 typedef StatusCallback EvictOriginDataCallback; |
| 77 typedef base::Callback<void(QuotaStatusCode status, | 93 typedef base::Callback<void(QuotaStatusCode status, |
| 78 const UsageAndQuota& usage_and_quota)> | 94 const UsageAndQuota& usage_and_quota)> |
| 79 UsageAndQuotaCallback; | 95 UsageAndQuotaCallback; |
| 80 | 96 |
| 81 // Returns the least recently used origin. It might return empty | 97 // Returns next origin to evict. It might return an empty GURL when there are |
| 82 // GURL when there are no evictable origins. | 98 // no evictable origins. |
| 83 virtual void GetLRUOrigin( | 99 virtual void GetEvictionOrigin(StorageType type, |
| 84 StorageType type, | 100 const GetOriginCallback& callback) = 0; |
| 85 const GetLRUOriginCallback& callback) = 0; | |
| 86 | 101 |
| 87 virtual void EvictOriginData( | 102 virtual void EvictOriginData( |
| 88 const GURL& origin, | 103 const GURL& origin, |
| 89 StorageType type, | 104 StorageType type, |
| 90 const EvictOriginDataCallback& callback) = 0; | 105 const EvictOriginDataCallback& callback) = 0; |
| 91 | 106 |
| 92 virtual void GetUsageAndQuotaForEviction( | 107 virtual void GetUsageAndQuotaForEviction( |
| 93 const UsageAndQuotaCallback& callback) = 0; | 108 const UsageAndQuotaCallback& callback) = 0; |
| 94 | 109 |
| 95 protected: | 110 protected: |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 | 370 |
| 356 void DidOriginDataEvicted(QuotaStatusCode status); | 371 void DidOriginDataEvicted(QuotaStatusCode status); |
| 357 | 372 |
| 358 void ReportHistogram(); | 373 void ReportHistogram(); |
| 359 void DidGetTemporaryGlobalUsageForHistogram(int64 usage, | 374 void DidGetTemporaryGlobalUsageForHistogram(int64 usage, |
| 360 int64 unlimited_usage); | 375 int64 unlimited_usage); |
| 361 void DidGetPersistentGlobalUsageForHistogram(int64 usage, | 376 void DidGetPersistentGlobalUsageForHistogram(int64 usage, |
| 362 int64 unlimited_usage); | 377 int64 unlimited_usage); |
| 363 | 378 |
| 364 // QuotaEvictionHandler. | 379 // QuotaEvictionHandler. |
| 365 void GetLRUOrigin(StorageType type, | 380 void GetEvictionOrigin(StorageType type, |
| 366 const GetLRUOriginCallback& callback) override; | 381 const GetOriginCallback& callback) override; |
| 367 void EvictOriginData(const GURL& origin, | 382 void EvictOriginData(const GURL& origin, |
| 368 StorageType type, | 383 StorageType type, |
| 369 const EvictOriginDataCallback& callback) override; | 384 const EvictOriginDataCallback& callback) override; |
| 370 void GetUsageAndQuotaForEviction( | 385 void GetUsageAndQuotaForEviction( |
| 371 const UsageAndQuotaCallback& callback) override; | 386 const UsageAndQuotaCallback& callback) override; |
| 372 | 387 |
| 388 void GetLRUOrigin(StorageType type, const GetOriginCallback& callback); | |
| 389 | |
| 373 void DidSetTemporaryGlobalOverrideQuota(const QuotaCallback& callback, | 390 void DidSetTemporaryGlobalOverrideQuota(const QuotaCallback& callback, |
| 374 const int64* new_quota, | 391 const int64* new_quota, |
| 375 bool success); | 392 bool success); |
| 376 void DidGetPersistentHostQuota(const std::string& host, | 393 void DidGetPersistentHostQuota(const std::string& host, |
| 377 const int64* quota, | 394 const int64* quota, |
| 378 bool success); | 395 bool success); |
| 379 void DidSetPersistentHostQuota(const std::string& host, | 396 void DidSetPersistentHostQuota(const std::string& host, |
| 380 const QuotaCallback& callback, | 397 const QuotaCallback& callback, |
| 381 const int64* new_quota, | 398 const int64* new_quota, |
| 382 bool success); | 399 bool success); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 401 const bool is_incognito_; | 418 const bool is_incognito_; |
| 402 const base::FilePath profile_path_; | 419 const base::FilePath profile_path_; |
| 403 | 420 |
| 404 scoped_refptr<QuotaManagerProxy> proxy_; | 421 scoped_refptr<QuotaManagerProxy> proxy_; |
| 405 bool db_disabled_; | 422 bool db_disabled_; |
| 406 bool eviction_disabled_; | 423 bool eviction_disabled_; |
| 407 scoped_refptr<base::SingleThreadTaskRunner> io_thread_; | 424 scoped_refptr<base::SingleThreadTaskRunner> io_thread_; |
| 408 scoped_refptr<base::SequencedTaskRunner> db_thread_; | 425 scoped_refptr<base::SequencedTaskRunner> db_thread_; |
| 409 mutable scoped_ptr<QuotaDatabase> database_; | 426 mutable scoped_ptr<QuotaDatabase> database_; |
| 410 | 427 |
| 411 GetLRUOriginCallback lru_origin_callback_; | 428 GetOriginCallback lru_origin_callback_; |
| 412 std::set<GURL> access_notified_origins_; | 429 std::set<GURL> access_notified_origins_; |
| 413 | 430 |
| 414 QuotaClientList clients_; | 431 QuotaClientList clients_; |
| 415 | 432 |
| 416 scoped_ptr<UsageTracker> temporary_usage_tracker_; | 433 scoped_ptr<UsageTracker> temporary_usage_tracker_; |
| 417 scoped_ptr<UsageTracker> persistent_usage_tracker_; | 434 scoped_ptr<UsageTracker> persistent_usage_tracker_; |
| 418 scoped_ptr<UsageTracker> syncable_usage_tracker_; | 435 scoped_ptr<UsageTracker> syncable_usage_tracker_; |
| 419 // TODO(michaeln): Need a way to clear the cache, drop and | 436 // TODO(michaeln): Need a way to clear the cache, drop and |
| 420 // reinstantiate the trackers when they're not handling requests. | 437 // reinstantiate the trackers when they're not handling requests. |
| 421 | 438 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 454 | 471 |
| 455 struct QuotaManagerDeleter { | 472 struct QuotaManagerDeleter { |
| 456 static void Destruct(const QuotaManager* manager) { | 473 static void Destruct(const QuotaManager* manager) { |
| 457 manager->DeleteOnCorrectThread(); | 474 manager->DeleteOnCorrectThread(); |
| 458 } | 475 } |
| 459 }; | 476 }; |
| 460 | 477 |
| 461 } // namespace storage | 478 } // namespace storage |
| 462 | 479 |
| 463 #endif // STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_H_ | 480 #endif // STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_H_ |
| OLD | NEW |