| OLD | NEW | 
| (Empty) |  | 
 |   1 // Copyright 2016 The Chromium Authors. All rights reserved. | 
 |   2 // Use of this source code is governed by a BSD-style license that can be | 
 |   3 // found in the LICENSE file. | 
 |   4  | 
 |   5 #ifndef STORAGE_BROWSER_QUOTA_QUOTA_SETTINGS_H_ | 
 |   6 #define STORAGE_BROWSER_QUOTA_QUOTA_SETTINGS_H_ | 
 |   7  | 
 |   8 #include <stdint.h> | 
 |   9  | 
 |  10 #include "base/callback.h" | 
 |  11 #include "base/files/file_path.h" | 
 |  12 #include "base/optional.h" | 
 |  13 #include "base/time/time.h" | 
 |  14 #include "storage/browser/storage_browser_export.h" | 
 |  15  | 
 |  16 namespace storage { | 
 |  17  | 
 |  18 // Settings the storage lib embedder must provide to the QuotaManager. | 
 |  19 struct QuotaSettings { | 
 |  20   QuotaSettings() = default; | 
 |  21   QuotaSettings(int64_t pool_size, | 
 |  22                 int64_t per_host_quota, | 
 |  23                 int64_t should_remain_available, | 
 |  24                 int64_t must_remain_available) | 
 |  25       : pool_size(pool_size), | 
 |  26         per_host_quota(per_host_quota), | 
 |  27         should_remain_available(should_remain_available), | 
 |  28         must_remain_available(must_remain_available) {} | 
 |  29  | 
 |  30   // The target size in bytes of the shared pool of disk space the quota | 
 |  31   // system allows for use by websites using HTML5 storage apis, for | 
 |  32   // example an embedder may use 50% of the total volume size. | 
 |  33   int64_t pool_size = 0; | 
 |  34  | 
 |  35   // The amount in bytes of the pool an individual site may consume. The | 
 |  36   // value must be less than or equal to the pool_size. | 
 |  37   int64_t per_host_quota = 0; | 
 |  38  | 
 |  39   // The amount of space that should remain available on the storage | 
 |  40   // volume. As the volume approaches this limit, the quota system gets | 
 |  41   // more aggressive about evicting data. | 
 |  42   int64_t should_remain_available = 0; | 
 |  43  | 
 |  44   // The amount of space that must remain available on the storage | 
 |  45   // volume. As the volume approaches this limit, the quota system gets | 
 |  46   // very aggressive about disallowing new data. | 
 |  47   int64_t must_remain_available = 0; | 
 |  48  | 
 |  49   // The quota system querries the embedder for the QuataSettings, | 
 |  50   // but will rate limit the frequency of the querries to no more than once | 
 |  51   // per refresh interval. | 
 |  52   base::TimeDelta refresh_interval = base::TimeDelta::Max(); | 
 |  53 }; | 
 |  54  | 
 |  55 // Function type used to return the settings in response to a | 
 |  56 // GetQuotaSettingsFunc invocation. If the embedder cannot | 
 |  57 // produce a settings values, base::nullopt can be returned. | 
 |  58 using OptionalQuotaSettingsCallback = | 
 |  59     base::Callback<void(base::Optional<QuotaSettings>)>; | 
 |  60  | 
 |  61 // Function type used to query the embedder about the quota manager settings. | 
 |  62 // This function is invoked on the UI thread. | 
 |  63 using GetQuotaSettingsFunc = | 
 |  64     base::Callback<void(const OptionalQuotaSettingsCallback& callback)>; | 
 |  65  | 
 |  66 // Returns settings based on the size of the volume containing the storage | 
 |  67 // partition and a guestimate of the size required for the OS. The refresh | 
 |  68 // interval is 60 seconds to accomodate changes to the size of the volume. | 
 |  69 // Except, in the case of incognito, the poolize and quota values are based | 
 |  70 // on the amount of physical memory and the rerfresh interval is max'd out. | 
 |  71 STORAGE_EXPORT | 
 |  72 base::Optional<storage::QuotaSettings> CalculateNominalDynamicSettings( | 
 |  73     const base::FilePath& partition_path, | 
 |  74     bool is_incognito); | 
 |  75  | 
 |  76 // Returns settings with a poolsize of zero and no per host quota. | 
 |  77 inline QuotaSettings GetNoQuotaSettings() { | 
 |  78   return QuotaSettings(); | 
 |  79 } | 
 |  80  | 
 |  81 // Returns settings that provide given |per_host_quota| and a total poolsize of | 
 |  82 // five times that. | 
 |  83 inline QuotaSettings GetHardCodedSettings(int64_t per_host_quota) { | 
 |  84   return QuotaSettings(per_host_quota * 5, per_host_quota, | 
 |  85                        per_host_quota, per_host_quota); | 
 |  86 } | 
 |  87  | 
 |  88 }  // namespace storage | 
 |  89  | 
 |  90 #endif  // STORAGE_BROWSER_QUOTA_QUOTA_MANAGER_H_ | 
| OLD | NEW |