Commit d855d13a authored by Jarryd's avatar Jarryd Committed by Commit Bot

Quota: Make const variables constexpr.

Change-Id: Ie758db5d7cd3d29c51be8b15ef8c724243d9eaa7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2276495
Commit-Queue: Jarryd Goodman <jarrydg@chromium.org>
Auto-Submit: Jarryd Goodman <jarrydg@chromium.org>
Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#786051}
parent b988cfa5
......@@ -49,47 +49,24 @@ namespace storage {
namespace {
const int64_t kMBytes = 1024 * 1024;
const int kMinutesInMilliSeconds = 60 * 1000;
const int64_t kReportHistogramInterval = 60 * 60 * 1000; // 1 hour
constexpr int64_t kReportHistogramInterval = 60 * 60 * 1000; // 1 hour
// Take action on write errors if there is <= 2% disk space
// available.
const double kStoragePressureThresholdRatio = 2;
constexpr double kStoragePressureThresholdRatio = 2;
// Limit how frequently QuotaManager polls for free disk space when
// only using that information to identify storage pressure.
const base::TimeDelta kStoragePressureCheckDiskStatsInterval =
constexpr base::TimeDelta kStoragePressureCheckDiskStatsInterval =
base::TimeDelta::FromMinutes(5);
} // namespace
const int64_t QuotaManager::kNoLimit = INT64_MAX;
// Cap size for per-host persistent quota determined by the histogram.
// This is a bit lax value because the histogram says nothing about per-host
// persistent storage usage and we determined by global persistent storage
// usage that is less than 10GB for almost all users.
const int64_t QuotaManager::kPerHostPersistentQuotaLimit = 10 * 1024 * kMBytes;
// Heuristics: assuming average cloud server allows a few Gigs storage
// on the server side and the storage needs to be shared for user data
// and by multiple apps.
int64_t QuotaManager::kSyncableStorageDefaultHostQuota = 500 * kMBytes;
const char QuotaManager::kDatabaseName[] = "QuotaManager";
const int QuotaManager::kThresholdOfErrorsToBeBlacklisted = 3;
const int QuotaManager::kEvictionIntervalInMilliSeconds =
30 * kMinutesInMilliSeconds;
const char QuotaManager::kDaysBetweenRepeatedOriginEvictionsHistogram[] =
"Quota.DaysBetweenRepeatedOriginEvictions";
const char QuotaManager::kEvictedOriginAccessedCountHistogram[] =
"Quota.EvictedOriginAccessCount";
const char QuotaManager::kEvictedOriginDaysSinceAccessHistogram[] =
"Quota.EvictedOriginDaysSinceAccess";
namespace {
bool IsSupportedType(StorageType type) {
......@@ -208,6 +185,15 @@ void DidGetUsageAndQuotaStripBreakdown(
} // namespace
constexpr int64_t QuotaManager::kNoLimit;
constexpr int64_t QuotaManager::kPerHostPersistentQuotaLimit;
constexpr int QuotaManager::kEvictionIntervalInMilliSeconds;
constexpr int QuotaManager::kThresholdOfErrorsToBeBlacklisted;
constexpr char QuotaManager::kDatabaseName[];
constexpr char QuotaManager::kDaysBetweenRepeatedOriginEvictionsHistogram[];
constexpr char QuotaManager::kEvictedOriginAccessedCountHistogram[];
constexpr char QuotaManager::kEvictedOriginDaysSinceAccessHistogram[];
class QuotaManager::UsageAndQuotaInfoGatherer : public QuotaTask {
public:
UsageAndQuotaInfoGatherer(QuotaManager* manager,
......
......@@ -121,7 +121,9 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) QuotaManager
int64_t quota,
blink::mojom::UsageBreakdownPtr usage_breakdown)>;
static const int64_t kNoLimit;
static constexpr int64_t kNoLimit = INT64_MAX;
static constexpr int64_t kMBytes = 1024 * 1024;
static constexpr int kMinutesInMilliSeconds = 60 * 1000;
QuotaManager(bool is_incognito,
const base::FilePath& profile_path,
......@@ -249,13 +251,23 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) QuotaManager
void SetStoragePressureCallback(
base::RepeatingCallback<void(url::Origin)> storage_pressure_callback);
static const int64_t kPerHostPersistentQuotaLimit;
static const char kDatabaseName[];
static const int kThresholdOfErrorsToBeBlacklisted;
static const int kEvictionIntervalInMilliSeconds;
static const char kDaysBetweenRepeatedOriginEvictionsHistogram[];
static const char kEvictedOriginAccessedCountHistogram[];
static const char kEvictedOriginDaysSinceAccessHistogram[];
// Cap size for per-host persistent quota determined by the histogram.
// This is a bit lax value because the histogram says nothing about per-host
// persistent storage usage and we determined by global persistent storage
// usage that is less than 10GB for almost all users.
static constexpr int64_t kPerHostPersistentQuotaLimit = 10 * 1024 * kMBytes;
static constexpr int kEvictionIntervalInMilliSeconds =
30 * kMinutesInMilliSeconds;
static constexpr int kThresholdOfErrorsToBeBlacklisted = 3;
static constexpr char kDatabaseName[] = "QuotaManager";
static constexpr char kDaysBetweenRepeatedOriginEvictionsHistogram[] =
"Quota.DaysBetweenRepeatedOriginEvictions";
static constexpr char kEvictedOriginAccessedCountHistogram[] =
"Quota.EvictedOriginAccessCount";
static constexpr char kEvictedOriginDaysSinceAccessHistogram[] =
"Quota.EvictedOriginDaysSinceAccess";
// Kept non-const so that test code can change the value.
// TODO(kinuko): Make this a real const value and add a proper way to set
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment