Chromium Code Reviews| Index: storage/browser/quota/quota_manager.h |
| diff --git a/storage/browser/quota/quota_manager.h b/storage/browser/quota/quota_manager.h |
| index a1ef11d2a55fbdeb64aa37463f469d6fa92ef775..b0ab6b11e190229fb67b5e9e0c956ff7c536bb41 100644 |
| --- a/storage/browser/quota/quota_manager.h |
| +++ b/storage/browser/quota/quota_manager.h |
| @@ -60,14 +60,14 @@ class UsageTracker; |
| struct QuotaManagerDeleter; |
| -struct STORAGE_EXPORT UsageAndQuota { |
| +struct STORAGE_EXPORT XUsageAndQuota { |
| int64_t usage; |
| int64_t global_limited_usage; |
| int64_t quota; |
| int64_t available_disk_space; |
| - UsageAndQuota(); |
| - UsageAndQuota(int64_t usage, |
| + XUsageAndQuota(); |
| + XUsageAndQuota(int64_t usage, |
| int64_t global_limited_usage, |
| int64_t quota, |
| int64_t available_disk_space); |
| @@ -94,8 +94,8 @@ class STORAGE_EXPORT QuotaEvictionPolicy { |
| class STORAGE_EXPORT QuotaEvictionHandler { |
| public: |
| using EvictOriginDataCallback = StatusCallback; |
| - using UsageAndQuotaCallback = base::Callback< |
| - void(QuotaStatusCode status, const UsageAndQuota& usage_and_quota)>; |
| + using XUsageAndQuotaCallback = base::Callback< |
| + void(QuotaStatusCode status, const XUsageAndQuota& usage_and_quota)>; |
| using VolumeInfoCallback = base::Callback< |
| void(bool success, uint64_t available_space, uint64_t total_space)>; |
| @@ -113,7 +113,7 @@ class STORAGE_EXPORT QuotaEvictionHandler { |
| virtual void AsyncGetVolumeInfo(const VolumeInfoCallback& callback) = 0; |
| virtual void GetUsageAndQuotaForEviction( |
| - const UsageAndQuotaCallback& callback) = 0; |
| + const XUsageAndQuotaCallback& callback) = 0; |
| protected: |
| virtual ~QuotaEvictionHandler() {} |
| @@ -127,6 +127,44 @@ struct UsageInfo { |
| int64_t usage; |
| }; |
| +// todo: new file temporary_pool_config |
| +// Configuration parameters the storage lib embedder must provide |
| +// to the QuotaManager. |
| +struct TemporaryStorageConfiguration { |
|
michaeln
2016/07/27 19:57:47
wdyt about the set of config params?
|
| + TemporaryStorageConfiguration() {} |
| + |
| + // 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.
|
| + // for use by by websites using HTML5 storage apis. This is not a hard limit, |
| + // it serves as the basis for computing the quota of an individual site. |
| + 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.
|
| + |
| + // The amount of space that must remain available on the storage |
| + // volume. As the volume approaches this limit, the quota system gets |
| + // more aggressive about evicting data and disallowing new data. |
| + int64_t must_remain_available = 0; |
| + |
| + // The target number of sites that will be sharing the larger pool. |
| + // Nominally, an individual site is allowed to use up to |
| + // pool_size / per_host_portion. |
| + 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
|
| + |
| + // The quota system querries the embedder for the TemporaryPoolConfiguration, |
| + // but will rate limit the frequency of the querries to no more than once |
| + // per refresh interval. |
| + base::TimeDelta refresh_interval = base::TimeDelta::Max(); |
| +}; |
| + |
| +// Function type used to return the temp storage config in response to a |
| +// GetTemporaryStorageConfigurationFunc invocation. |
| +using TemporaryStorageConfigurationCallback = |
| + base::Callback<void(const TemporaryStorageConfiguration&)>; |
| + |
| +// Function type used to query the embedder about the temporary pool . |
| +// configuration. This function is invoked on the UI thread. |
| +using GetTemporaryStorageConfigurationFunc = base::Callback< |
| + void(const base::FilePath& profile_path, bool is_incognito, |
| + TemporaryStorageConfigurationCallback callback)>; |
| + |
| // The quota manager class. This class is instantiated per profile and |
| // held by the profile. With the exception of the constructor and the |
| // proxy() method, all methods should only be called on the IO thread. |
| @@ -147,7 +185,14 @@ class STORAGE_EXPORT QuotaManager |
| const base::FilePath& profile_path, |
| const scoped_refptr<base::SingleThreadTaskRunner>& io_thread, |
| const scoped_refptr<base::SequencedTaskRunner>& db_thread, |
| - const scoped_refptr<SpecialStoragePolicy>& special_storage_policy); |
| + const scoped_refptr<SpecialStoragePolicy>& special_storage_policy, |
| + GetTemporaryStorageConfigurationFunc get_storage_config_function); |
| + |
| + const TemporaryStorageConfiguration& storage_config() { |
| + return storage_config_; |
| + } |
| + void SetTemporaryStorageConfiguration( |
| + const TemporaryStorageConfiguration& storage_config); |
| // Returns a proxy object that can be used on any thread. |
| QuotaManagerProxy* proxy() { return proxy_.get(); } |
| @@ -223,13 +268,9 @@ class STORAGE_EXPORT QuotaManager |
| const StatusCallback& callback); |
| // Called by UI and internal modules. |
| - void GetAvailableSpace(const AvailableSpaceCallback& callback); |
| + void xGetAvailableSpace(const AvailableSpaceCallback& callback); |
| void GetTemporaryGlobalQuota(const QuotaCallback& callback); |
| - // Ok to call with NULL callback. |
| - void SetTemporaryGlobalOverrideQuota(int64_t new_quota, |
| - const QuotaCallback& callback); |
| - |
| void GetPersistentHostQuota(const std::string& host, |
| const QuotaCallback& callback); |
| void SetPersistentHostQuota(const std::string& host, |
| @@ -249,6 +290,7 @@ class STORAGE_EXPORT QuotaManager |
| bool IsStorageUnlimited(const GURL& origin, StorageType type) const; |
| bool CanQueryDiskSize(const GURL& origin) const { |
| + // TODO: not currently used? |
| return special_storage_policy_.get() && |
| special_storage_policy_->CanQueryDiskSize(origin); |
| } |
| @@ -266,6 +308,10 @@ class STORAGE_EXPORT QuotaManager |
| void RemoveStorageObserverForFilter(StorageObserver* observer, |
| const StorageObserver::Filter& filter); |
| + static bool GetVolumeInfo(const base::FilePath& path, |
| + uint64_t* available_space, |
| + uint64_t* total_size); |
| + |
| // Determines the portion of the temp pool that can be |
| // utilized by a single host (ie. 5 for 20%). |
| static const int kPerHostTemporaryPortion; |
| @@ -333,7 +379,9 @@ class STORAGE_EXPORT QuotaManager |
| AvailableSpaceCallbackQueue; |
| typedef CallbackQueueMap<QuotaCallback, std::string, QuotaStatusCode, int64_t> |
| HostQuotaCallbackMap; |
| - |
| + using TemporaryConfigCallbackQueue = |
| + CallbackQueue<TemporaryStorageConfigurationCallback, |
| + const TemporaryStorageConfiguration&>; |
| struct EvictionContext { |
| EvictionContext(); |
| virtual ~EvictionContext(); |
| @@ -343,9 +391,6 @@ class STORAGE_EXPORT QuotaManager |
| EvictOriginDataCallback evict_origin_data_callback; |
| }; |
| - typedef QuotaEvictionHandler::UsageAndQuotaCallback |
| - UsageAndQuotaDispatcherCallback; |
| - |
| // This initialization method is lazily called on the IO thread |
| // when the first quota manager API is called. |
| // Initialize must be called after all quota clients are added to the |
| @@ -414,7 +459,7 @@ class STORAGE_EXPORT QuotaManager |
| StorageType type, |
| const EvictOriginDataCallback& callback) override; |
| void GetUsageAndQuotaForEviction( |
| - const UsageAndQuotaCallback& callback) override; |
| + const XUsageAndQuotaCallback& callback) override; |
| void AsyncGetVolumeInfo(const VolumeInfoCallback& callback) override; |
| void DidGetVolumeInfo( |
| @@ -423,9 +468,6 @@ class STORAGE_EXPORT QuotaManager |
| void GetLRUOrigin(StorageType type, const GetOriginCallback& callback); |
| - void DidSetTemporaryGlobalOverrideQuota(const QuotaCallback& callback, |
| - const int64_t* new_quota, |
| - bool success); |
| void DidGetPersistentHostQuota(const std::string& host, |
| const int64_t* quota, |
| bool success); |
| @@ -433,9 +475,6 @@ class STORAGE_EXPORT QuotaManager |
| const QuotaCallback& callback, |
| const int64_t* new_quota, |
| bool success); |
| - void DidInitialize(int64_t* temporary_quota_override, |
| - int64_t* desired_available_space, |
| - bool success); |
| void DidGetLRUOrigin(const GURL* origin, |
| bool success); |
| void DidGetInitialTemporaryGlobalQuota(base::TimeTicks start_ticks, |
| @@ -443,6 +482,11 @@ class STORAGE_EXPORT QuotaManager |
| int64_t quota_unused); |
| void DidInitializeTemporaryOriginsInfo(bool success); |
| void DidGetAvailableSpace(int64_t space); |
| + void GetTemporaryStorageConfig( |
| + const TemporaryStorageConfigurationCallback& callback); |
| + void DidGetTemporaryStorageConfig( |
| + const TemporaryStorageConfiguration& storage_config); |
| + |
| void DidDatabaseWork(bool success); |
| void DeleteOnCorrectThread() const; |
| @@ -455,9 +499,6 @@ class STORAGE_EXPORT QuotaManager |
| static int64_t CallGetAmountOfFreeDiskSpace( |
| GetVolumeInfoFn get_vol_info_fn, |
| const base::FilePath& profile_path); |
| - static bool GetVolumeInfo(const base::FilePath& path, |
| - uint64_t* available_space, |
| - uint64_t* total_size); |
| const bool is_incognito_; |
| const base::FilePath profile_path_; |
| @@ -469,6 +510,12 @@ class STORAGE_EXPORT QuotaManager |
| scoped_refptr<base::SequencedTaskRunner> db_thread_; |
| mutable std::unique_ptr<QuotaDatabase> database_; |
| + GetTemporaryStorageConfigurationFunc get_config_function_; |
| + scoped_refptr<base::TaskRunner> get_config_task_runner_; |
| + TemporaryStorageConfiguration storage_config_; |
| + base::TimeTicks storage_config_timestamp_; |
| + TemporaryConfigCallbackQueue storage_config_callbacks_; |
| + |
| GetOriginCallback lru_origin_callback_; |
| std::set<GURL> access_notified_origins_; |
| @@ -485,14 +532,9 @@ class STORAGE_EXPORT QuotaManager |
| std::unique_ptr<QuotaEvictionPolicy> temporary_storage_eviction_policy_; |
| bool is_getting_eviction_origin_; |
| - ClosureQueue db_initialization_callbacks_; |
| AvailableSpaceCallbackQueue available_space_callbacks_; |
| HostQuotaCallbackMap persistent_host_quota_callbacks_; |
| - bool temporary_quota_initialized_; |
| - int64_t temporary_quota_override_; |
| - int64_t desired_available_space_; |
| - |
| // Map from origin to count. |
| std::map<GURL, int> origins_in_use_; |
| // Map from origin to error count. |