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