| Index: content/browser/quota/quota_manager_unittest.cc
|
| diff --git a/content/browser/quota/quota_manager_unittest.cc b/content/browser/quota/quota_manager_unittest.cc
|
| index abe4635be9cbc6bc0ece94c07c9a832e55d39434..80889ba8b30c356b48883c9d85fe11a4b405c23c 100644
|
| --- a/content/browser/quota/quota_manager_unittest.cc
|
| +++ b/content/browser/quota/quota_manager_unittest.cc
|
| @@ -2,6 +2,9 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include <stddef.h>
|
| +#include <stdint.h>
|
| +
|
| #include <algorithm>
|
| #include <set>
|
| #include <sstream>
|
| @@ -10,6 +13,7 @@
|
| #include "base/bind.h"
|
| #include "base/files/file_util.h"
|
| #include "base/files/scoped_temp_dir.h"
|
| +#include "base/macros.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/memory/weak_ptr.h"
|
| #include "base/run_loop.h"
|
| @@ -54,15 +58,16 @@ const StorageType kSync = kStorageTypeSyncable;
|
|
|
| const int kAllClients = QuotaClient::kAllClientsMask;
|
|
|
| -const int64 kAvailableSpaceForApp = 13377331U;
|
| +const int64_t kAvailableSpaceForApp = 13377331U;
|
|
|
| -const int64 kMinimumPreserveForSystem = QuotaManager::kMinimumPreserveForSystem;
|
| +const int64_t kMinimumPreserveForSystem =
|
| + QuotaManager::kMinimumPreserveForSystem;
|
| const int kPerHostTemporaryPortion = QuotaManager::kPerHostTemporaryPortion;
|
|
|
| const GURL kTestEvictionOrigin = GURL("http://test.eviction.policy/result");
|
|
|
| // Returns a deterministic value for the amount of available disk space.
|
| -int64 GetAvailableDiskSpaceForTest(const base::FilePath&) {
|
| +int64_t GetAvailableDiskSpaceForTest(const base::FilePath&) {
|
| return kAvailableSpaceForApp + kMinimumPreserveForSystem;
|
| }
|
|
|
| @@ -75,8 +80,8 @@ class TestEvictionPolicy : public storage::QuotaEvictionPolicy {
|
| void GetEvictionOrigin(const scoped_refptr<storage::SpecialStoragePolicy>&
|
| special_storage_policy,
|
| const std::set<GURL>& exceptions,
|
| - const std::map<GURL, int64>& usage_map,
|
| - int64 global_quota,
|
| + const std::map<GURL, int64_t>& usage_map,
|
| + int64_t global_quota,
|
| const storage::GetOriginCallback& callback) override {
|
| callback.Run(kTestEvictionOrigin);
|
| }
|
| @@ -168,7 +173,7 @@ class QuotaManagerTest : public testing::Test {
|
| weak_factory_.GetWeakPtr()));
|
| }
|
|
|
| - void SetTemporaryGlobalQuota(int64 new_quota) {
|
| + void SetTemporaryGlobalQuota(int64_t new_quota) {
|
| quota_status_ = kQuotaStatusUnknown;
|
| quota_ = -1;
|
| quota_manager_->SetTemporaryGlobalOverrideQuota(
|
| @@ -186,7 +191,7 @@ class QuotaManagerTest : public testing::Test {
|
| weak_factory_.GetWeakPtr()));
|
| }
|
|
|
| - void SetPersistentHostQuota(const std::string& host, int64 new_quota) {
|
| + void SetPersistentHostQuota(const std::string& host, int64_t new_quota) {
|
| quota_status_ = kQuotaStatusUnknown;
|
| quota_ = -1;
|
| quota_manager_->SetPersistentHostQuota(
|
| @@ -347,38 +352,35 @@ class QuotaManagerTest : public testing::Test {
|
| usage_info_.insert(usage_info_.begin(), entries.begin(), entries.end());
|
| }
|
|
|
| - void DidGetUsageAndQuota(QuotaStatusCode status, int64 usage, int64 quota) {
|
| + void DidGetUsageAndQuota(QuotaStatusCode status,
|
| + int64_t usage,
|
| + int64_t quota) {
|
| quota_status_ = status;
|
| usage_ = usage;
|
| quota_ = quota;
|
| }
|
|
|
| - void DidGetQuota(QuotaStatusCode status,
|
| - int64 quota) {
|
| + void DidGetQuota(QuotaStatusCode status, int64_t quota) {
|
| quota_status_ = status;
|
| quota_ = quota;
|
| }
|
|
|
| - void DidGetAvailableSpace(QuotaStatusCode status, int64 available_space) {
|
| + void DidGetAvailableSpace(QuotaStatusCode status, int64_t available_space) {
|
| quota_status_ = status;
|
| available_space_ = available_space;
|
| }
|
|
|
| - void DidGetHostQuota(QuotaStatusCode status,
|
| - int64 quota) {
|
| + void DidGetHostQuota(QuotaStatusCode status, int64_t quota) {
|
| quota_status_ = status;
|
| quota_ = quota;
|
| }
|
|
|
| - void DidGetGlobalUsage(int64 usage,
|
| - int64 unlimited_usage) {
|
| + void DidGetGlobalUsage(int64_t usage, int64_t unlimited_usage) {
|
| usage_ = usage;
|
| unlimited_usage_ = unlimited_usage;
|
| }
|
|
|
| - void DidGetHostUsage(int64 usage) {
|
| - usage_ = usage;
|
| - }
|
| + void DidGetHostUsage(int64_t usage) { usage_ = usage; }
|
|
|
| void StatusCallback(QuotaStatusCode status) {
|
| ++status_callback_count_;
|
| @@ -414,8 +416,9 @@ class QuotaManagerTest : public testing::Test {
|
|
|
| void set_additional_callback_count(int c) { additional_callback_count_ = c; }
|
| int additional_callback_count() const { return additional_callback_count_; }
|
| - void DidGetUsageAndQuotaAdditional(
|
| - QuotaStatusCode status, int64 usage, int64 quota) {
|
| + void DidGetUsageAndQuotaAdditional(QuotaStatusCode status,
|
| + int64_t usage,
|
| + int64_t quota) {
|
| ++additional_callback_count_;
|
| }
|
|
|
| @@ -430,11 +433,11 @@ class QuotaManagerTest : public testing::Test {
|
|
|
| QuotaStatusCode status() const { return quota_status_; }
|
| const UsageInfoEntries& usage_info() const { return usage_info_; }
|
| - int64 usage() const { return usage_; }
|
| - int64 limited_usage() const { return limited_usage_; }
|
| - int64 unlimited_usage() const { return unlimited_usage_; }
|
| - int64 quota() const { return quota_; }
|
| - int64 available_space() const { return available_space_; }
|
| + int64_t usage() const { return usage_; }
|
| + int64_t limited_usage() const { return limited_usage_; }
|
| + int64_t unlimited_usage() const { return unlimited_usage_; }
|
| + int64_t quota() const { return quota_; }
|
| + int64_t available_space() const { return available_space_; }
|
| const GURL& eviction_origin() const { return eviction_origin_; }
|
| const std::set<GURL>& modified_origins() const { return modified_origins_; }
|
| StorageType modified_origins_type() const { return modified_origins_type_; }
|
| @@ -460,11 +463,11 @@ class QuotaManagerTest : public testing::Test {
|
|
|
| QuotaStatusCode quota_status_;
|
| UsageInfoEntries usage_info_;
|
| - int64 usage_;
|
| - int64 limited_usage_;
|
| - int64 unlimited_usage_;
|
| - int64 quota_;
|
| - int64 available_space_;
|
| + int64_t usage_;
|
| + int64_t limited_usage_;
|
| + int64_t unlimited_usage_;
|
| + int64_t quota_;
|
| + int64_t available_space_;
|
| GURL eviction_origin_;
|
| std::set<GURL> modified_origins_;
|
| StorageType modified_origins_type_;
|
| @@ -539,7 +542,7 @@ TEST_F(QuotaManagerTest, GetUsageAndQuota_Simple) {
|
| EXPECT_EQ(kQuotaStatusOk, status());
|
| EXPECT_EQ(10, usage());
|
| EXPECT_LE(0, quota());
|
| - int64 quota_returned_for_foo = quota();
|
| + int64_t quota_returned_for_foo = quota();
|
|
|
| GetUsageAndQuotaForWebApps(GURL("http://bar.com/"), kTemp);
|
| base::RunLoop().RunUntilIdle();
|
| @@ -666,7 +669,7 @@ TEST_F(QuotaManagerTest, GetUsage_MultipleClients) {
|
| RegisterClient(CreateClient(kData2, arraysize(kData2),
|
| QuotaClient::kDatabase));
|
|
|
| - const int64 kTempQuotaBase =
|
| + const int64_t kTempQuotaBase =
|
| GetAvailableDiskSpaceForTest(base::FilePath()) / kPerHostTemporaryPortion;
|
|
|
| GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp);
|
| @@ -1255,15 +1258,15 @@ TEST_F(QuotaManagerTest, GetUsage_WithDeleteOrigin) {
|
|
|
| GetGlobalUsage(kTemp);
|
| base::RunLoop().RunUntilIdle();
|
| - int64 predelete_global_tmp = usage();
|
| + int64_t predelete_global_tmp = usage();
|
|
|
| GetHostUsage("foo.com", kTemp);
|
| base::RunLoop().RunUntilIdle();
|
| - int64 predelete_host_tmp = usage();
|
| + int64_t predelete_host_tmp = usage();
|
|
|
| GetHostUsage("foo.com", kPerm);
|
| base::RunLoop().RunUntilIdle();
|
| - int64 predelete_host_pers = usage();
|
| + int64_t predelete_host_pers = usage();
|
|
|
| DeleteClientOriginData(client, GURL("http://foo.com/"),
|
| kTemp);
|
| @@ -1322,15 +1325,15 @@ TEST_F(QuotaManagerTest, EvictOriginData) {
|
|
|
| GetGlobalUsage(kTemp);
|
| base::RunLoop().RunUntilIdle();
|
| - int64 predelete_global_tmp = usage();
|
| + int64_t predelete_global_tmp = usage();
|
|
|
| GetHostUsage("foo.com", kTemp);
|
| base::RunLoop().RunUntilIdle();
|
| - int64 predelete_host_tmp = usage();
|
| + int64_t predelete_host_tmp = usage();
|
|
|
| GetHostUsage("foo.com", kPerm);
|
| base::RunLoop().RunUntilIdle();
|
| - int64 predelete_host_pers = usage();
|
| + int64_t predelete_host_pers = usage();
|
|
|
| for (size_t i = 0; i < arraysize(kData1); ++i)
|
| quota_manager()->NotifyStorageAccessed(QuotaClient::kUnknown,
|
| @@ -1447,15 +1450,15 @@ TEST_F(QuotaManagerTest, EvictOriginDataWithDeletionError) {
|
|
|
| GetGlobalUsage(kTemp);
|
| base::RunLoop().RunUntilIdle();
|
| - int64 predelete_global_tmp = usage();
|
| + int64_t predelete_global_tmp = usage();
|
|
|
| GetHostUsage("foo.com", kTemp);
|
| base::RunLoop().RunUntilIdle();
|
| - int64 predelete_host_tmp = usage();
|
| + int64_t predelete_host_tmp = usage();
|
|
|
| GetHostUsage("foo.com", kPerm);
|
| base::RunLoop().RunUntilIdle();
|
| - int64 predelete_host_pers = usage();
|
| + int64_t predelete_host_pers = usage();
|
|
|
| for (size_t i = 0; i < arraysize(kData); ++i)
|
| NotifyStorageAccessed(client, GURL(kData[i].origin), kData[i].type);
|
| @@ -1552,15 +1555,15 @@ TEST_F(QuotaManagerTest, DeleteHostDataSimple) {
|
|
|
| GetGlobalUsage(kTemp);
|
| base::RunLoop().RunUntilIdle();
|
| - const int64 predelete_global_tmp = usage();
|
| + const int64_t predelete_global_tmp = usage();
|
|
|
| GetHostUsage("foo.com", kTemp);
|
| base::RunLoop().RunUntilIdle();
|
| - int64 predelete_host_tmp = usage();
|
| + int64_t predelete_host_tmp = usage();
|
|
|
| GetHostUsage("foo.com", kPerm);
|
| base::RunLoop().RunUntilIdle();
|
| - int64 predelete_host_pers = usage();
|
| + int64_t predelete_host_pers = usage();
|
|
|
| DeleteHostData(std::string(), kTemp, kAllClients);
|
| base::RunLoop().RunUntilIdle();
|
| @@ -1618,23 +1621,23 @@ TEST_F(QuotaManagerTest, DeleteHostDataMultiple) {
|
|
|
| GetGlobalUsage(kTemp);
|
| base::RunLoop().RunUntilIdle();
|
| - const int64 predelete_global_tmp = usage();
|
| + const int64_t predelete_global_tmp = usage();
|
|
|
| GetHostUsage("foo.com", kTemp);
|
| base::RunLoop().RunUntilIdle();
|
| - const int64 predelete_foo_tmp = usage();
|
| + const int64_t predelete_foo_tmp = usage();
|
|
|
| GetHostUsage("bar.com", kTemp);
|
| base::RunLoop().RunUntilIdle();
|
| - const int64 predelete_bar_tmp = usage();
|
| + const int64_t predelete_bar_tmp = usage();
|
|
|
| GetHostUsage("foo.com", kPerm);
|
| base::RunLoop().RunUntilIdle();
|
| - const int64 predelete_foo_pers = usage();
|
| + const int64_t predelete_foo_pers = usage();
|
|
|
| GetHostUsage("bar.com", kPerm);
|
| base::RunLoop().RunUntilIdle();
|
| - const int64 predelete_bar_pers = usage();
|
| + const int64_t predelete_bar_pers = usage();
|
|
|
| reset_status_callback_count();
|
| DeleteHostData("foo.com", kTemp, kAllClients);
|
| @@ -1706,23 +1709,23 @@ TEST_F(QuotaManagerTest, DeleteOriginDataMultiple) {
|
|
|
| GetGlobalUsage(kTemp);
|
| base::RunLoop().RunUntilIdle();
|
| - const int64 predelete_global_tmp = usage();
|
| + const int64_t predelete_global_tmp = usage();
|
|
|
| GetHostUsage("foo.com", kTemp);
|
| base::RunLoop().RunUntilIdle();
|
| - const int64 predelete_foo_tmp = usage();
|
| + const int64_t predelete_foo_tmp = usage();
|
|
|
| GetHostUsage("bar.com", kTemp);
|
| base::RunLoop().RunUntilIdle();
|
| - const int64 predelete_bar_tmp = usage();
|
| + const int64_t predelete_bar_tmp = usage();
|
|
|
| GetHostUsage("foo.com", kPerm);
|
| base::RunLoop().RunUntilIdle();
|
| - const int64 predelete_foo_pers = usage();
|
| + const int64_t predelete_foo_pers = usage();
|
|
|
| GetHostUsage("bar.com", kPerm);
|
| base::RunLoop().RunUntilIdle();
|
| - const int64 predelete_bar_pers = usage();
|
| + const int64_t predelete_bar_pers = usage();
|
|
|
| for (size_t i = 0; i < arraysize(kData1); ++i)
|
| quota_manager()->NotifyStorageAccessed(QuotaClient::kUnknown,
|
| @@ -2074,7 +2077,7 @@ TEST_F(QuotaManagerTest, DeleteSpecificClientTypeSingleOrigin) {
|
|
|
| GetHostUsage("foo.com", kTemp);
|
| base::RunLoop().RunUntilIdle();
|
| - const int64 predelete_foo_tmp = usage();
|
| + const int64_t predelete_foo_tmp = usage();
|
|
|
| DeleteOriginData(GURL("http://foo.com/"), kTemp, QuotaClient::kFileSystem);
|
| base::RunLoop().RunUntilIdle();
|
| @@ -2130,7 +2133,7 @@ TEST_F(QuotaManagerTest, DeleteSpecificClientTypeSingleHost) {
|
|
|
| GetHostUsage("foo.com", kTemp);
|
| base::RunLoop().RunUntilIdle();
|
| - const int64 predelete_foo_tmp = usage();
|
| + const int64_t predelete_foo_tmp = usage();
|
|
|
| DeleteHostData("foo.com", kTemp, QuotaClient::kFileSystem);
|
| base::RunLoop().RunUntilIdle();
|
| @@ -2185,7 +2188,7 @@ TEST_F(QuotaManagerTest, DeleteMultipleClientTypesSingleOrigin) {
|
|
|
| GetHostUsage("foo.com", kTemp);
|
| base::RunLoop().RunUntilIdle();
|
| - const int64 predelete_foo_tmp = usage();
|
| + const int64_t predelete_foo_tmp = usage();
|
|
|
| DeleteOriginData(GURL("http://foo.com/"), kTemp,
|
| QuotaClient::kFileSystem | QuotaClient::kDatabase);
|
| @@ -2230,7 +2233,7 @@ TEST_F(QuotaManagerTest, DeleteMultipleClientTypesSingleHost) {
|
|
|
| GetHostUsage("foo.com", kTemp);
|
| base::RunLoop().RunUntilIdle();
|
| - const int64 predelete_foo_tmp = usage();
|
| + const int64_t predelete_foo_tmp = usage();
|
|
|
| DeleteHostData("foo.com", kTemp,
|
| QuotaClient::kFileSystem | QuotaClient::kAppcache);
|
| @@ -2268,8 +2271,9 @@ TEST_F(QuotaManagerTest, GetUsageAndQuota_Incognito) {
|
| base::RunLoop().RunUntilIdle();
|
| EXPECT_EQ(kQuotaStatusOk, status());
|
| EXPECT_EQ(10, usage());
|
| - EXPECT_LE(std::min(static_cast<int64>(100 / kPerHostTemporaryPortion),
|
| - QuotaManager::kIncognitoDefaultQuotaLimit), quota());
|
| + EXPECT_LE(std::min(static_cast<int64_t>(100 / kPerHostTemporaryPortion),
|
| + QuotaManager::kIncognitoDefaultQuotaLimit),
|
| + quota());
|
|
|
| mock_special_storage_policy()->AddUnlimited(GURL("http://foo.com/"));
|
| GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kPerm);
|
|
|