| 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> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <utility> | 13 #include <utility> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/basictypes.h" | 16 #include "base/basictypes.h" |
| 17 #include "base/callback.h" | 17 #include "base/callback.h" |
| 18 #include "base/containers/scoped_ptr_map.h" | |
| 19 #include "base/files/file_path.h" | 18 #include "base/files/file_path.h" |
| 20 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
| 21 #include "base/memory/scoped_ptr.h" | 20 #include "base/memory/scoped_ptr.h" |
| 21 #include "base/memory/scoped_vector.h" |
| 22 #include "base/memory/weak_ptr.h" | 22 #include "base/memory/weak_ptr.h" |
| 23 #include "base/sequenced_task_runner_helpers.h" | 23 #include "base/sequenced_task_runner_helpers.h" |
| 24 #include "storage/browser/quota/quota_callbacks.h" | 24 #include "storage/browser/quota/quota_callbacks.h" |
| 25 #include "storage/browser/quota/quota_client.h" | 25 #include "storage/browser/quota/quota_client.h" |
| 26 #include "storage/browser/quota/quota_database.h" | 26 #include "storage/browser/quota/quota_database.h" |
| 27 #include "storage/browser/quota/quota_task.h" | 27 #include "storage/browser/quota/quota_task.h" |
| 28 #include "storage/browser/quota/special_storage_policy.h" | 28 #include "storage/browser/quota/special_storage_policy.h" |
| 29 #include "storage/browser/quota/storage_observer.h" | 29 #include "storage/browser/quota/storage_observer.h" |
| 30 #include "storage/browser/storage_browser_export.h" | 30 #include "storage/browser/storage_browser_export.h" |
| 31 | 31 |
| (...skipping 267 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 | 389 |
| 388 // QuotaEvictionHandler. | 390 // QuotaEvictionHandler. |
| 389 void GetEvictionOrigin(StorageType type, | 391 void GetEvictionOrigin(StorageType type, |
| 390 const GetOriginCallback& callback) override; | 392 const GetOriginCallback& callback) override; |
| 391 void EvictOriginData(const GURL& origin, | 393 void EvictOriginData(const GURL& origin, |
| 392 StorageType type, | 394 StorageType type, |
| 393 const EvictOriginDataCallback& callback) override; | 395 const EvictOriginDataCallback& callback) override; |
| 394 void GetUsageAndQuotaForEviction( | 396 void GetUsageAndQuotaForEviction( |
| 395 const UsageAndQuotaCallback& callback) override; | 397 const UsageAndQuotaCallback& callback) override; |
| 396 | 398 |
| 397 void GetLRUOrigin(StorageType type, const GetOriginCallback& callback); | |
| 398 | |
| 399 void DidSetTemporaryGlobalOverrideQuota(const QuotaCallback& callback, | 399 void DidSetTemporaryGlobalOverrideQuota(const QuotaCallback& callback, |
| 400 const int64* new_quota, | 400 const int64* new_quota, |
| 401 bool success); | 401 bool success); |
| 402 void DidGetPersistentHostQuota(const std::string& host, | 402 void DidGetPersistentHostQuota(const std::string& host, |
| 403 const int64* quota, | 403 const int64* quota, |
| 404 bool success); | 404 bool success); |
| 405 void DidSetPersistentHostQuota(const std::string& host, | 405 void DidSetPersistentHostQuota(const std::string& host, |
| 406 const QuotaCallback& callback, | 406 const QuotaCallback& callback, |
| 407 const int64* new_quota, | 407 const int64* new_quota, |
| 408 bool success); | 408 bool success); |
| 409 void DidInitialize(int64* temporary_quota_override, | 409 void DidInitialize(int64* temporary_quota_override, |
| 410 int64* desired_available_space, | 410 int64* desired_available_space, |
| 411 bool success); | 411 bool success); |
| 412 void DidGetLRUOrigin(const GURL* origin, | |
| 413 bool success); | |
| 414 void DidGetInitialTemporaryGlobalQuota(QuotaStatusCode status, | 412 void DidGetInitialTemporaryGlobalQuota(QuotaStatusCode status, |
| 415 int64 quota_unused); | 413 int64 quota_unused); |
| 416 void DidInitializeTemporaryOriginsInfo(bool success); | 414 void DidInitializeTemporaryOriginsInfo(bool success); |
| 417 void DidGetAvailableSpace(int64 space); | 415 void DidGetAvailableSpace(int64 space); |
| 418 void DidDatabaseWork(bool success); | 416 void DidDatabaseWork(bool success); |
| 419 | 417 |
| 420 void DeleteOnCorrectThread() const; | 418 void DeleteOnCorrectThread() const; |
| 421 | 419 |
| 422 void PostTaskAndReplyWithResultForDBThread( | 420 void PostTaskAndReplyWithResultForDBThread( |
| 423 const tracked_objects::Location& from_here, | 421 const tracked_objects::Location& from_here, |
| 424 const base::Callback<bool(QuotaDatabase*)>& task, | 422 const base::Callback<bool(QuotaDatabase*)>& task, |
| 425 const base::Callback<void(bool)>& reply); | 423 const base::Callback<void(bool)>& reply); |
| 426 | 424 |
| 427 const bool is_incognito_; | 425 const bool is_incognito_; |
| 428 const base::FilePath profile_path_; | 426 const base::FilePath profile_path_; |
| 429 | 427 |
| 430 scoped_refptr<QuotaManagerProxy> proxy_; | 428 scoped_refptr<QuotaManagerProxy> proxy_; |
| 431 bool db_disabled_; | 429 bool db_disabled_; |
| 432 bool eviction_disabled_; | 430 bool eviction_disabled_; |
| 433 scoped_refptr<base::SingleThreadTaskRunner> io_thread_; | 431 scoped_refptr<base::SingleThreadTaskRunner> io_thread_; |
| 434 scoped_refptr<base::SequencedTaskRunner> db_thread_; | 432 scoped_refptr<base::SequencedTaskRunner> db_thread_; |
| 435 mutable scoped_ptr<QuotaDatabase> database_; | 433 mutable scoped_ptr<QuotaDatabase> database_; |
| 436 | 434 |
| 437 GetOriginCallback lru_origin_callback_; | |
| 438 std::set<GURL> access_notified_origins_; | 435 std::set<GURL> access_notified_origins_; |
| 439 | 436 |
| 440 QuotaClientList clients_; | 437 QuotaClientList clients_; |
| 441 | 438 |
| 442 scoped_ptr<UsageTracker> temporary_usage_tracker_; | 439 scoped_ptr<UsageTracker> temporary_usage_tracker_; |
| 443 scoped_ptr<UsageTracker> persistent_usage_tracker_; | 440 scoped_ptr<UsageTracker> persistent_usage_tracker_; |
| 444 scoped_ptr<UsageTracker> syncable_usage_tracker_; | 441 scoped_ptr<UsageTracker> syncable_usage_tracker_; |
| 445 // TODO(michaeln): Need a way to clear the cache, drop and | 442 // TODO(michaeln): Need a way to clear the cache, drop and |
| 446 // reinstantiate the trackers when they're not handling requests. | 443 // reinstantiate the trackers when they're not handling requests. |
| 447 | 444 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 466 | 463 |
| 467 base::RepeatingTimer<QuotaManager> histogram_timer_; | 464 base::RepeatingTimer<QuotaManager> histogram_timer_; |
| 468 | 465 |
| 469 // Pointer to the function used to get the available disk space. This is | 466 // Pointer to the function used to get the available disk space. This is |
| 470 // overwritten by QuotaManagerTest in order to attain a deterministic reported | 467 // overwritten by QuotaManagerTest in order to attain a deterministic reported |
| 471 // value. The default value points to base::SysInfo::AmountOfFreeDiskSpace. | 468 // value. The default value points to base::SysInfo::AmountOfFreeDiskSpace. |
| 472 GetAvailableDiskSpaceFn get_disk_space_fn_; | 469 GetAvailableDiskSpaceFn get_disk_space_fn_; |
| 473 | 470 |
| 474 scoped_ptr<StorageMonitor> storage_monitor_; | 471 scoped_ptr<StorageMonitor> storage_monitor_; |
| 475 | 472 |
| 476 base::ScopedPtrMap<StorageType, scoped_ptr<QuotaEvictionPolicy>> | 473 ScopedVector<QuotaEvictionPolicy> eviction_policy_map_; |
| 477 eviction_policy_map_; | |
| 478 | 474 |
| 479 bool is_getting_eviction_origin_; | 475 bool is_getting_eviction_origin_; |
| 480 | 476 |
| 481 base::WeakPtrFactory<QuotaManager> weak_factory_; | 477 base::WeakPtrFactory<QuotaManager> weak_factory_; |
| 482 | 478 |
| 483 DISALLOW_COPY_AND_ASSIGN(QuotaManager); | 479 DISALLOW_COPY_AND_ASSIGN(QuotaManager); |
| 484 }; | 480 }; |
| 485 | 481 |
| 486 struct QuotaManagerDeleter { | 482 struct QuotaManagerDeleter { |
| 487 static void Destruct(const QuotaManager* manager) { | 483 static void Destruct(const QuotaManager* manager) { |
| 488 manager->DeleteOnCorrectThread(); | 484 manager->DeleteOnCorrectThread(); |
| 489 } | 485 } |
| 490 }; | 486 }; |
| 491 | 487 |
| 492 } // namespace storage | 488 } // namespace storage |
| 493 | 489 |
| 494 #endif // STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_H_ | 490 #endif // STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_H_ |
| OLD | NEW |