Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1312)

Unified Diff: storage/browser/quota/quota_manager.cc

Issue 1498003003: Remove kint64max. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: INT64_MAX Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « storage/browser/quota/quota_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: storage/browser/quota/quota_manager.cc
diff --git a/storage/browser/quota/quota_manager.cc b/storage/browser/quota/quota_manager.cc
index 7e3b6beb8b899e8d68e0cf1202e7056f0ca49a3c..abd72607e8fe58428a6e14ccc041678c127d4f31 100644
--- a/storage/browser/quota/quota_manager.cc
+++ b/storage/browser/quota/quota_manager.cc
@@ -6,6 +6,7 @@
#include <algorithm>
#include <functional>
+#include <limits>
#include "base/bind.h"
#include "base/bind_helpers.h"
@@ -37,10 +38,10 @@ namespace storage {
namespace {
-const int64 kMBytes = 1024 * 1024;
+const int64_t kMBytes = 1024 * 1024;
const int kMinutesInMilliSeconds = 60 * 1000;
-const int64 kReportHistogramInterval = 60 * 60 * 1000; // 1 hour
+const int64_t kReportHistogramInterval = 60 * 60 * 1000; // 1 hour
const double kTemporaryQuotaRatioToAvail = 1.0 / 3.0; // 33%
} // namespace
@@ -48,9 +49,9 @@ const double kTemporaryQuotaRatioToAvail = 1.0 / 3.0; // 33%
// Arbitrary for now, but must be reasonably small so that
// in-memory databases can fit.
// TODO(kinuko): Refer SysInfo::AmountOfPhysicalMemory() to determine this.
-const int64 QuotaManager::kIncognitoDefaultQuotaLimit = 100 * kMBytes;
+const int64_t QuotaManager::kIncognitoDefaultQuotaLimit = 100 * kMBytes;
-const int64 QuotaManager::kNoLimit = kint64max;
+const int64_t QuotaManager::kNoLimit = INT64_MAX;
const int QuotaManager::kPerHostTemporaryPortion = 5; // 20%
@@ -58,7 +59,7 @@ const int QuotaManager::kPerHostTemporaryPortion = 5; // 20%
// 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 QuotaManager::kPerHostPersistentQuotaLimit = 10 * 1024 * kMBytes;
+const int64_t QuotaManager::kPerHostPersistentQuotaLimit = 10 * 1024 * kMBytes;
const char QuotaManager::kDatabaseName[] = "QuotaManager";
@@ -69,7 +70,7 @@ const int QuotaManager::kThresholdOfErrorsToBeBlacklisted = 3;
// TODO(kinuko): This should be like 10% of the actual disk space.
// For now we simply use a constant as getting the disk size needs
// platform-dependent code. (http://crbug.com/178976)
-int64 QuotaManager::kMinimumPreserveForSystem = 1024 * kMBytes;
+int64_t QuotaManager::kMinimumPreserveForSystem = 1024 * kMBytes;
const int QuotaManager::kEvictionIntervalInMilliSeconds =
30 * kMinutesInMilliSeconds;
@@ -84,7 +85,7 @@ const char QuotaManager::kEvictedOriginTimeSinceAccessHistogram[] =
// 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 QuotaManager::kSyncableStorageDefaultHostQuota = 500 * kMBytes;
+int64_t QuotaManager::kSyncableStorageDefaultHostQuota = 500 * kMBytes;
namespace {
@@ -108,7 +109,7 @@ void CountOriginType(const std::set<GURL>& origins,
}
}
-bool SetTemporaryGlobalOverrideQuotaOnDBThread(int64* new_quota,
+bool SetTemporaryGlobalOverrideQuotaOnDBThread(int64_t* new_quota,
QuotaDatabase* database) {
DCHECK(database);
if (!database->SetQuotaConfigValue(
@@ -120,7 +121,7 @@ bool SetTemporaryGlobalOverrideQuotaOnDBThread(int64* new_quota,
}
bool GetPersistentHostQuotaOnDBThread(const std::string& host,
- int64* quota,
+ int64_t* quota,
QuotaDatabase* database) {
DCHECK(database);
database->GetHostQuota(host, kStorageTypePersistent, quota);
@@ -128,7 +129,7 @@ bool GetPersistentHostQuotaOnDBThread(const std::string& host,
}
bool SetPersistentHostQuotaOnDBThread(const std::string& host,
- int64* new_quota,
+ int64_t* new_quota,
QuotaDatabase* database) {
DCHECK(database);
if (database->SetHostQuota(host, kStorageTypePersistent, *new_quota))
@@ -137,8 +138,8 @@ bool SetPersistentHostQuotaOnDBThread(const std::string& host,
return false;
}
-bool InitializeOnDBThread(int64* temporary_quota_override,
- int64* desired_available_space,
+bool InitializeOnDBThread(int64_t* temporary_quota_override,
+ int64_t* desired_available_space,
QuotaDatabase* database) {
DCHECK(database);
database->GetQuotaConfigValue(QuotaDatabase::kTemporaryQuotaOverrideKey,
@@ -226,7 +227,7 @@ bool UpdateModifiedTimeOnDBThread(const GURL& origin,
return database->SetOriginLastModifiedTime(origin, type, modified_time);
}
-int64 CallSystemGetAmountOfFreeDiskSpace(const base::FilePath& profile_path) {
+int64_t CallSystemGetAmountOfFreeDiskSpace(const base::FilePath& profile_path) {
// crbug.com/349708
TRACE_EVENT0("io", "CallSystemGetAmountOfFreeDiskSpace");
@@ -238,11 +239,12 @@ int64 CallSystemGetAmountOfFreeDiskSpace(const base::FilePath& profile_path) {
return base::SysInfo::AmountOfFreeDiskSpace(profile_path);
}
-int64 CalculateTemporaryGlobalQuota(int64 global_limited_usage,
- int64 available_space) {
+int64_t CalculateTemporaryGlobalQuota(int64_t global_limited_usage,
+ int64_t available_space) {
DCHECK_GE(global_limited_usage, 0);
- int64 avail_space = available_space;
- if (avail_space < kint64max - global_limited_usage) {
+ int64_t avail_space = available_space;
+ if (avail_space <
+ std::numeric_limits<int64_t>::max() - global_limited_usage) {
// We basically calculate the temporary quota by
// [available_space + space_used_for_temp] * kTempQuotaRatio,
// but make sure we'll have no overflow.
@@ -265,8 +267,9 @@ void DispatchTemporaryGlobalQuotaCallback(
usage_and_quota.available_disk_space));
}
-int64 CalculateQuotaWithDiskSpace(
- int64 available_disk_space, int64 usage, int64 quota) {
+int64_t CalculateQuotaWithDiskSpace(int64_t available_disk_space,
+ int64_t usage,
+ int64_t quota) {
if (available_disk_space < QuotaManager::kMinimumPreserveForSystem) {
LOG(WARNING)
<< "Running out of disk space for profile."
@@ -286,11 +289,11 @@ int64 CalculateQuotaWithDiskSpace(
return quota;
}
-int64 CalculateTemporaryHostQuota(int64 host_usage,
- int64 global_quota,
- int64 global_limited_usage) {
+int64_t CalculateTemporaryHostQuota(int64_t host_usage,
+ int64_t global_quota,
+ int64_t global_limited_usage) {
DCHECK_GE(global_limited_usage, 0);
- int64 host_quota = global_quota / QuotaManager::kPerHostTemporaryPortion;
+ int64_t host_quota = global_quota / QuotaManager::kPerHostTemporaryPortion;
if (global_limited_usage > global_quota)
host_quota = std::min(host_quota, host_usage);
return host_quota;
@@ -309,8 +312,8 @@ void DispatchUsageAndQuotaForWebApps(
return;
}
- int64 usage = usage_and_quota.usage;
- int64 quota = usage_and_quota.quota;
+ int64_t usage = usage_and_quota.usage;
+ int64_t quota = usage_and_quota.quota;
if (type == kStorageTypeTemporary && !is_unlimited) {
quota = CalculateTemporaryHostQuota(
@@ -348,16 +351,14 @@ UsageAndQuota::UsageAndQuota()
available_disk_space(0) {
}
-UsageAndQuota::UsageAndQuota(
- int64 usage,
- int64 global_limited_usage,
- int64 quota,
- int64 available_disk_space)
+UsageAndQuota::UsageAndQuota(int64_t usage,
+ int64_t global_limited_usage,
+ int64_t quota,
+ int64_t available_disk_space)
: usage(usage),
global_limited_usage(global_limited_usage),
quota(quota),
- available_disk_space(available_disk_space) {
-}
+ available_disk_space(available_disk_space) {}
class UsageAndQuotaCallbackDispatcher
: public QuotaTask,
@@ -380,22 +381,22 @@ class UsageAndQuotaCallbackDispatcher
Start();
}
- void set_usage(int64 usage) {
+ void set_usage(int64_t usage) {
usage_and_quota_.usage = usage;
has_usage_ = true;
}
- void set_global_limited_usage(int64 global_limited_usage) {
+ void set_global_limited_usage(int64_t global_limited_usage) {
usage_and_quota_.global_limited_usage = global_limited_usage;
has_global_limited_usage_ = true;
}
- void set_quota(int64 quota) {
+ void set_quota(int64_t quota) {
usage_and_quota_.quota = quota;
has_quota_ = true;
}
- void set_available_disk_space(int64 available_disk_space) {
+ void set_available_disk_space(int64_t available_disk_space) {
usage_and_quota_.available_disk_space = available_disk_space;
has_available_disk_space_ = true;
}
@@ -430,28 +431,28 @@ class UsageAndQuotaCallbackDispatcher
}
private:
- void DidGetHostUsage(int64 usage) {
+ void DidGetHostUsage(int64_t usage) {
if (status_ == kQuotaStatusUnknown)
status_ = kQuotaStatusOk;
usage_and_quota_.usage = usage;
CheckCompleted();
}
- void DidGetGlobalLimitedUsage(int64 limited_usage) {
+ void DidGetGlobalLimitedUsage(int64_t limited_usage) {
if (status_ == kQuotaStatusUnknown)
status_ = kQuotaStatusOk;
usage_and_quota_.global_limited_usage = limited_usage;
CheckCompleted();
}
- void DidGetQuota(QuotaStatusCode status, int64 quota) {
+ void DidGetQuota(QuotaStatusCode status, int64_t quota) {
if (status_ == kQuotaStatusUnknown || status_ == kQuotaStatusOk)
status_ = status;
usage_and_quota_.quota = quota;
CheckCompleted();
}
- void DidGetAvailableSpace(QuotaStatusCode status, int64 space) {
+ void DidGetAvailableSpace(QuotaStatusCode status, int64_t space) {
// crbug.com/349708
TRACE_EVENT0(
"io", "UsageAndQuotaCallbackDispatcher::DidGetAvailableSpace");
@@ -555,18 +556,18 @@ class QuotaManager::GetUsageInfoTask : public QuotaTask {
private:
void AddEntries(StorageType type, UsageTracker* tracker) {
- std::map<std::string, int64> host_usage;
+ std::map<std::string, int64_t> host_usage;
tracker->GetCachedHostsUsage(&host_usage);
- for (std::map<std::string, int64>::const_iterator iter = host_usage.begin();
- iter != host_usage.end();
- ++iter) {
+ for (std::map<std::string, int64_t>::const_iterator iter =
+ host_usage.begin();
+ iter != host_usage.end(); ++iter) {
entries_.push_back(UsageInfo(iter->first, type, iter->second));
}
if (--remaining_trackers_ == 0)
CallCompleted();
}
- void DidGetGlobalUsage(StorageType type, int64, int64) {
+ void DidGetGlobalUsage(StorageType type, int64_t, int64_t) {
DCHECK(manager()->GetUsageTracker(type));
AddEntries(type, manager()->GetUsageTracker(type));
}
@@ -964,9 +965,10 @@ void QuotaManager::NotifyStorageAccessed(
NotifyStorageAccessedInternal(client_id, origin, type, base::Time::Now());
}
-void QuotaManager::NotifyStorageModified(
- QuotaClient::ID client_id,
- const GURL& origin, StorageType type, int64 delta) {
+void QuotaManager::NotifyStorageModified(QuotaClient::ID client_id,
+ const GURL& origin,
+ StorageType type,
+ int64_t delta) {
DCHECK(origin == origin.GetOrigin());
NotifyStorageModifiedInternal(client_id, origin, type, delta,
base::Time::Now());
@@ -1059,7 +1061,8 @@ void QuotaManager::GetTemporaryGlobalQuota(const QuotaCallback& callback) {
}
void QuotaManager::SetTemporaryGlobalOverrideQuota(
- int64 new_quota, const QuotaCallback& callback) {
+ int64_t new_quota,
+ const QuotaCallback& callback) {
LazyInitialize();
if (new_quota < 0) {
@@ -1074,7 +1077,7 @@ void QuotaManager::SetTemporaryGlobalOverrideQuota(
return;
}
- int64* new_quota_ptr = new int64(new_quota);
+ int64_t* new_quota_ptr = new int64_t(new_quota);
PostTaskAndReplyWithResultForDBThread(
FROM_HERE,
base::Bind(&SetTemporaryGlobalOverrideQuotaOnDBThread,
@@ -1099,7 +1102,7 @@ void QuotaManager::GetPersistentHostQuota(const std::string& host,
if (!persistent_host_quota_callbacks_.Add(host, callback))
return;
- int64* quota_ptr = new int64(0);
+ int64_t* quota_ptr = new int64_t(0);
PostTaskAndReplyWithResultForDBThread(
FROM_HERE,
base::Bind(&GetPersistentHostQuotaOnDBThread,
@@ -1112,7 +1115,7 @@ void QuotaManager::GetPersistentHostQuota(const std::string& host,
}
void QuotaManager::SetPersistentHostQuota(const std::string& host,
- int64 new_quota,
+ int64_t new_quota,
const QuotaCallback& callback) {
LazyInitialize();
if (host.empty()) {
@@ -1136,7 +1139,7 @@ void QuotaManager::SetPersistentHostQuota(const std::string& host,
return;
}
- int64* new_quota_ptr = new int64(new_quota);
+ int64_t* new_quota_ptr = new int64_t(new_quota);
PostTaskAndReplyWithResultForDBThread(
FROM_HERE,
base::Bind(&SetPersistentHostQuotaOnDBThread,
@@ -1189,12 +1192,12 @@ void QuotaManager::GetStatistics(
std::map<std::string, std::string>* statistics) {
DCHECK(statistics);
if (temporary_storage_evictor_) {
- std::map<std::string, int64> stats;
+ std::map<std::string, int64_t> stats;
temporary_storage_evictor_->GetStatistics(&stats);
- for (std::map<std::string, int64>::iterator p = stats.begin();
- p != stats.end();
- ++p)
+ for (std::map<std::string, int64_t>::iterator p = stats.begin();
+ p != stats.end(); ++p) {
(*statistics)[p->first] = base::Int64ToString(p->second);
+ }
}
}
@@ -1307,8 +1310,8 @@ void QuotaManager::LazyInitialize() {
clients_, kStorageTypeSyncable, special_storage_policy_.get(),
storage_monitor_.get()));
- int64* temporary_quota_override = new int64(-1);
- int64* desired_available_space = new int64(-1);
+ int64_t* temporary_quota_override = new int64_t(-1);
+ int64_t* desired_available_space = new int64_t(-1);
PostTaskAndReplyWithResultForDBThread(
FROM_HERE,
base::Bind(&InitializeOnDBThread,
@@ -1369,12 +1372,11 @@ void QuotaManager::NotifyStorageAccessedInternal(
weak_factory_.GetWeakPtr()));
}
-void QuotaManager::NotifyStorageModifiedInternal(
- QuotaClient::ID client_id,
- const GURL& origin,
- StorageType type,
- int64 delta,
- base::Time modified_time) {
+void QuotaManager::NotifyStorageModifiedInternal(QuotaClient::ID client_id,
+ const GURL& origin,
+ StorageType type,
+ int64_t delta,
+ base::Time modified_time) {
LazyInitialize();
DCHECK(GetUsageTracker(type));
GetUsageTracker(type)->UpdateUsageCache(client_id, origin, delta);
@@ -1478,8 +1480,8 @@ void QuotaManager::ReportHistogram() {
}
void QuotaManager::DidGetTemporaryGlobalUsageForHistogram(
- int64 usage,
- int64 unlimited_usage) {
+ int64_t usage,
+ int64_t unlimited_usage) {
UMA_HISTOGRAM_MBYTES("Quota.GlobalUsageOfTemporaryStorage", usage);
std::set<GURL> origins;
@@ -1502,8 +1504,8 @@ void QuotaManager::DidGetTemporaryGlobalUsageForHistogram(
}
void QuotaManager::DidGetPersistentGlobalUsageForHistogram(
- int64 usage,
- int64 unlimited_usage) {
+ int64_t usage,
+ int64_t unlimited_usage) {
UMA_HISTOGRAM_MBYTES("Quota.GlobalUsageOfPersistentStorage", usage);
std::set<GURL> origins;
@@ -1558,7 +1560,7 @@ void QuotaManager::DidGetEvictionOrigin(const GetOriginCallback& callback,
void QuotaManager::GetEvictionOrigin(StorageType type,
const std::set<GURL>& extra_exceptions,
- int64 global_quota,
+ int64_t global_quota,
const GetOriginCallback& callback) {
LazyInitialize();
// This must not be called while there's an in-flight task.
@@ -1570,7 +1572,7 @@ void QuotaManager::GetEvictionOrigin(StorageType type,
weak_factory_.GetWeakPtr(), callback);
if (type == kStorageTypeTemporary && temporary_storage_eviction_policy_) {
- std::map<GURL, int64> usage_map;
+ std::map<GURL, int64_t> usage_map;
// The cached origins are populated by the prior call to
// GetUsageAndQuotaForEviction().
GetUsageTracker(kStorageTypeTemporary)->GetCachedOriginsUsage(&usage_map);
@@ -1641,7 +1643,7 @@ void QuotaManager::GetLRUOrigin(StorageType type,
void QuotaManager::DidSetTemporaryGlobalOverrideQuota(
const QuotaCallback& callback,
- const int64* new_quota,
+ const int64_t* new_quota,
bool success) {
QuotaStatusCode status = kQuotaErrorInvalidAccess;
DidDatabaseWork(success);
@@ -1657,7 +1659,7 @@ void QuotaManager::DidSetTemporaryGlobalOverrideQuota(
}
void QuotaManager::DidGetPersistentHostQuota(const std::string& host,
- const int64* quota,
+ const int64_t* quota,
bool success) {
DidDatabaseWork(success);
persistent_host_quota_callbacks_.Run(host, kQuotaStatusOk, *quota);
@@ -1665,14 +1667,14 @@ void QuotaManager::DidGetPersistentHostQuota(const std::string& host,
void QuotaManager::DidSetPersistentHostQuota(const std::string& host,
const QuotaCallback& callback,
- const int64* new_quota,
+ const int64_t* new_quota,
bool success) {
DidDatabaseWork(success);
callback.Run(success ? kQuotaStatusOk : kQuotaErrorInvalidAccess, *new_quota);
}
-void QuotaManager::DidInitialize(int64* temporary_quota_override,
- int64* desired_available_space,
+void QuotaManager::DidInitialize(int64_t* temporary_quota_override,
+ int64_t* desired_available_space,
bool success) {
temporary_quota_override_ = *temporary_quota_override;
desired_available_space_ = *desired_available_space;
@@ -1698,8 +1700,8 @@ void QuotaManager::DidGetLRUOrigin(const GURL* origin,
lru_origin_callback_.Reset();
}
-void QuotaManager::DidGetInitialTemporaryGlobalQuota(
- QuotaStatusCode status, int64 quota_unused) {
+void QuotaManager::DidGetInitialTemporaryGlobalQuota(QuotaStatusCode status,
+ int64_t quota_unused) {
if (eviction_disabled_)
return;
@@ -1721,7 +1723,7 @@ void QuotaManager::DidInitializeTemporaryOriginsInfo(bool success) {
StartEviction();
}
-void QuotaManager::DidGetAvailableSpace(int64 space) {
+void QuotaManager::DidGetAvailableSpace(int64_t space) {
// crbug.com/349708
TRACE_EVENT1("io", "QuotaManager::DidGetAvailableSpace",
"n_callbacks", available_space_callbacks_.size());
« no previous file with comments | « storage/browser/quota/quota_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698