| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> |
| 6 #include <stdint.h> |
| 7 |
| 5 #include <algorithm> | 8 #include <algorithm> |
| 6 #include <set> | 9 #include <set> |
| 7 #include <sstream> | 10 #include <sstream> |
| 8 #include <vector> | 11 #include <vector> |
| 9 | 12 |
| 10 #include "base/bind.h" | 13 #include "base/bind.h" |
| 11 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
| 12 #include "base/files/scoped_temp_dir.h" | 15 #include "base/files/scoped_temp_dir.h" |
| 16 #include "base/macros.h" |
| 13 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 15 #include "base/run_loop.h" | 19 #include "base/run_loop.h" |
| 16 #include "base/stl_util.h" | 20 #include "base/stl_util.h" |
| 17 #include "base/sys_info.h" | 21 #include "base/sys_info.h" |
| 18 #include "base/test/histogram_tester.h" | 22 #include "base/test/histogram_tester.h" |
| 19 #include "base/thread_task_runner_handle.h" | 23 #include "base/thread_task_runner_handle.h" |
| 20 #include "base/time/time.h" | 24 #include "base/time/time.h" |
| 21 #include "content/public/test/mock_special_storage_policy.h" | 25 #include "content/public/test/mock_special_storage_policy.h" |
| 22 #include "content/public/test/mock_storage_client.h" | 26 #include "content/public/test/mock_storage_client.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 47 | 51 |
| 48 namespace { | 52 namespace { |
| 49 | 53 |
| 50 // For shorter names. | 54 // For shorter names. |
| 51 const StorageType kTemp = kStorageTypeTemporary; | 55 const StorageType kTemp = kStorageTypeTemporary; |
| 52 const StorageType kPerm = kStorageTypePersistent; | 56 const StorageType kPerm = kStorageTypePersistent; |
| 53 const StorageType kSync = kStorageTypeSyncable; | 57 const StorageType kSync = kStorageTypeSyncable; |
| 54 | 58 |
| 55 const int kAllClients = QuotaClient::kAllClientsMask; | 59 const int kAllClients = QuotaClient::kAllClientsMask; |
| 56 | 60 |
| 57 const int64 kAvailableSpaceForApp = 13377331U; | 61 const int64_t kAvailableSpaceForApp = 13377331U; |
| 58 | 62 |
| 59 const int64 kMinimumPreserveForSystem = QuotaManager::kMinimumPreserveForSystem; | 63 const int64_t kMinimumPreserveForSystem = |
| 64 QuotaManager::kMinimumPreserveForSystem; |
| 60 const int kPerHostTemporaryPortion = QuotaManager::kPerHostTemporaryPortion; | 65 const int kPerHostTemporaryPortion = QuotaManager::kPerHostTemporaryPortion; |
| 61 | 66 |
| 62 const GURL kTestEvictionOrigin = GURL("http://test.eviction.policy/result"); | 67 const GURL kTestEvictionOrigin = GURL("http://test.eviction.policy/result"); |
| 63 | 68 |
| 64 // Returns a deterministic value for the amount of available disk space. | 69 // Returns a deterministic value for the amount of available disk space. |
| 65 int64 GetAvailableDiskSpaceForTest(const base::FilePath&) { | 70 int64_t GetAvailableDiskSpaceForTest(const base::FilePath&) { |
| 66 return kAvailableSpaceForApp + kMinimumPreserveForSystem; | 71 return kAvailableSpaceForApp + kMinimumPreserveForSystem; |
| 67 } | 72 } |
| 68 | 73 |
| 69 class TestEvictionPolicy : public storage::QuotaEvictionPolicy { | 74 class TestEvictionPolicy : public storage::QuotaEvictionPolicy { |
| 70 public: | 75 public: |
| 71 TestEvictionPolicy() {} | 76 TestEvictionPolicy() {} |
| 72 ~TestEvictionPolicy() override {} | 77 ~TestEvictionPolicy() override {} |
| 73 | 78 |
| 74 // Overridden from storage::QuotaEvictionPolicy: | 79 // Overridden from storage::QuotaEvictionPolicy: |
| 75 void GetEvictionOrigin(const scoped_refptr<storage::SpecialStoragePolicy>& | 80 void GetEvictionOrigin(const scoped_refptr<storage::SpecialStoragePolicy>& |
| 76 special_storage_policy, | 81 special_storage_policy, |
| 77 const std::set<GURL>& exceptions, | 82 const std::set<GURL>& exceptions, |
| 78 const std::map<GURL, int64>& usage_map, | 83 const std::map<GURL, int64_t>& usage_map, |
| 79 int64 global_quota, | 84 int64_t global_quota, |
| 80 const storage::GetOriginCallback& callback) override { | 85 const storage::GetOriginCallback& callback) override { |
| 81 callback.Run(kTestEvictionOrigin); | 86 callback.Run(kTestEvictionOrigin); |
| 82 } | 87 } |
| 83 }; | 88 }; |
| 84 | 89 |
| 85 } // namespace | 90 } // namespace |
| 86 | 91 |
| 87 class QuotaManagerTest : public testing::Test { | 92 class QuotaManagerTest : public testing::Test { |
| 88 protected: | 93 protected: |
| 89 typedef QuotaManager::QuotaTableEntry QuotaTableEntry; | 94 typedef QuotaManager::QuotaTableEntry QuotaTableEntry; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 } | 166 } |
| 162 | 167 |
| 163 void GetTemporaryGlobalQuota() { | 168 void GetTemporaryGlobalQuota() { |
| 164 quota_status_ = kQuotaStatusUnknown; | 169 quota_status_ = kQuotaStatusUnknown; |
| 165 quota_ = -1; | 170 quota_ = -1; |
| 166 quota_manager_->GetTemporaryGlobalQuota( | 171 quota_manager_->GetTemporaryGlobalQuota( |
| 167 base::Bind(&QuotaManagerTest::DidGetQuota, | 172 base::Bind(&QuotaManagerTest::DidGetQuota, |
| 168 weak_factory_.GetWeakPtr())); | 173 weak_factory_.GetWeakPtr())); |
| 169 } | 174 } |
| 170 | 175 |
| 171 void SetTemporaryGlobalQuota(int64 new_quota) { | 176 void SetTemporaryGlobalQuota(int64_t new_quota) { |
| 172 quota_status_ = kQuotaStatusUnknown; | 177 quota_status_ = kQuotaStatusUnknown; |
| 173 quota_ = -1; | 178 quota_ = -1; |
| 174 quota_manager_->SetTemporaryGlobalOverrideQuota( | 179 quota_manager_->SetTemporaryGlobalOverrideQuota( |
| 175 new_quota, | 180 new_quota, |
| 176 base::Bind(&QuotaManagerTest::DidGetQuota, | 181 base::Bind(&QuotaManagerTest::DidGetQuota, |
| 177 weak_factory_.GetWeakPtr())); | 182 weak_factory_.GetWeakPtr())); |
| 178 } | 183 } |
| 179 | 184 |
| 180 void GetPersistentHostQuota(const std::string& host) { | 185 void GetPersistentHostQuota(const std::string& host) { |
| 181 quota_status_ = kQuotaStatusUnknown; | 186 quota_status_ = kQuotaStatusUnknown; |
| 182 quota_ = -1; | 187 quota_ = -1; |
| 183 quota_manager_->GetPersistentHostQuota( | 188 quota_manager_->GetPersistentHostQuota( |
| 184 host, | 189 host, |
| 185 base::Bind(&QuotaManagerTest::DidGetHostQuota, | 190 base::Bind(&QuotaManagerTest::DidGetHostQuota, |
| 186 weak_factory_.GetWeakPtr())); | 191 weak_factory_.GetWeakPtr())); |
| 187 } | 192 } |
| 188 | 193 |
| 189 void SetPersistentHostQuota(const std::string& host, int64 new_quota) { | 194 void SetPersistentHostQuota(const std::string& host, int64_t new_quota) { |
| 190 quota_status_ = kQuotaStatusUnknown; | 195 quota_status_ = kQuotaStatusUnknown; |
| 191 quota_ = -1; | 196 quota_ = -1; |
| 192 quota_manager_->SetPersistentHostQuota( | 197 quota_manager_->SetPersistentHostQuota( |
| 193 host, new_quota, | 198 host, new_quota, |
| 194 base::Bind(&QuotaManagerTest::DidGetHostQuota, | 199 base::Bind(&QuotaManagerTest::DidGetHostQuota, |
| 195 weak_factory_.GetWeakPtr())); | 200 weak_factory_.GetWeakPtr())); |
| 196 } | 201 } |
| 197 | 202 |
| 198 void GetGlobalUsage(StorageType type) { | 203 void GetGlobalUsage(StorageType type) { |
| 199 usage_ = -1; | 204 usage_ = -1; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 origin_info_entries_.clear(); | 345 origin_info_entries_.clear(); |
| 341 quota_manager_->DumpOriginInfoTable( | 346 quota_manager_->DumpOriginInfoTable( |
| 342 base::Bind(&QuotaManagerTest::DidDumpOriginInfoTable, | 347 base::Bind(&QuotaManagerTest::DidDumpOriginInfoTable, |
| 343 weak_factory_.GetWeakPtr())); | 348 weak_factory_.GetWeakPtr())); |
| 344 } | 349 } |
| 345 | 350 |
| 346 void DidGetUsageInfo(const UsageInfoEntries& entries) { | 351 void DidGetUsageInfo(const UsageInfoEntries& entries) { |
| 347 usage_info_.insert(usage_info_.begin(), entries.begin(), entries.end()); | 352 usage_info_.insert(usage_info_.begin(), entries.begin(), entries.end()); |
| 348 } | 353 } |
| 349 | 354 |
| 350 void DidGetUsageAndQuota(QuotaStatusCode status, int64 usage, int64 quota) { | 355 void DidGetUsageAndQuota(QuotaStatusCode status, |
| 356 int64_t usage, |
| 357 int64_t quota) { |
| 351 quota_status_ = status; | 358 quota_status_ = status; |
| 352 usage_ = usage; | 359 usage_ = usage; |
| 353 quota_ = quota; | 360 quota_ = quota; |
| 354 } | 361 } |
| 355 | 362 |
| 356 void DidGetQuota(QuotaStatusCode status, | 363 void DidGetQuota(QuotaStatusCode status, int64_t quota) { |
| 357 int64 quota) { | |
| 358 quota_status_ = status; | 364 quota_status_ = status; |
| 359 quota_ = quota; | 365 quota_ = quota; |
| 360 } | 366 } |
| 361 | 367 |
| 362 void DidGetAvailableSpace(QuotaStatusCode status, int64 available_space) { | 368 void DidGetAvailableSpace(QuotaStatusCode status, int64_t available_space) { |
| 363 quota_status_ = status; | 369 quota_status_ = status; |
| 364 available_space_ = available_space; | 370 available_space_ = available_space; |
| 365 } | 371 } |
| 366 | 372 |
| 367 void DidGetHostQuota(QuotaStatusCode status, | 373 void DidGetHostQuota(QuotaStatusCode status, int64_t quota) { |
| 368 int64 quota) { | |
| 369 quota_status_ = status; | 374 quota_status_ = status; |
| 370 quota_ = quota; | 375 quota_ = quota; |
| 371 } | 376 } |
| 372 | 377 |
| 373 void DidGetGlobalUsage(int64 usage, | 378 void DidGetGlobalUsage(int64_t usage, int64_t unlimited_usage) { |
| 374 int64 unlimited_usage) { | |
| 375 usage_ = usage; | 379 usage_ = usage; |
| 376 unlimited_usage_ = unlimited_usage; | 380 unlimited_usage_ = unlimited_usage; |
| 377 } | 381 } |
| 378 | 382 |
| 379 void DidGetHostUsage(int64 usage) { | 383 void DidGetHostUsage(int64_t usage) { usage_ = usage; } |
| 380 usage_ = usage; | |
| 381 } | |
| 382 | 384 |
| 383 void StatusCallback(QuotaStatusCode status) { | 385 void StatusCallback(QuotaStatusCode status) { |
| 384 ++status_callback_count_; | 386 ++status_callback_count_; |
| 385 quota_status_ = status; | 387 quota_status_ = status; |
| 386 } | 388 } |
| 387 | 389 |
| 388 void DidGetUsageAndQuotaForEviction(QuotaStatusCode status, | 390 void DidGetUsageAndQuotaForEviction(QuotaStatusCode status, |
| 389 const UsageAndQuota& usage_and_quota) { | 391 const UsageAndQuota& usage_and_quota) { |
| 390 quota_status_ = status; | 392 quota_status_ = status; |
| 391 limited_usage_ = usage_and_quota.global_limited_usage; | 393 limited_usage_ = usage_and_quota.global_limited_usage; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 407 } | 409 } |
| 408 | 410 |
| 409 void DidDumpOriginInfoTable(const OriginInfoTableEntries& entries) { | 411 void DidDumpOriginInfoTable(const OriginInfoTableEntries& entries) { |
| 410 origin_info_entries_ = entries; | 412 origin_info_entries_ = entries; |
| 411 } | 413 } |
| 412 | 414 |
| 413 void GetUsage_WithModifyTestBody(const StorageType type); | 415 void GetUsage_WithModifyTestBody(const StorageType type); |
| 414 | 416 |
| 415 void set_additional_callback_count(int c) { additional_callback_count_ = c; } | 417 void set_additional_callback_count(int c) { additional_callback_count_ = c; } |
| 416 int additional_callback_count() const { return additional_callback_count_; } | 418 int additional_callback_count() const { return additional_callback_count_; } |
| 417 void DidGetUsageAndQuotaAdditional( | 419 void DidGetUsageAndQuotaAdditional(QuotaStatusCode status, |
| 418 QuotaStatusCode status, int64 usage, int64 quota) { | 420 int64_t usage, |
| 421 int64_t quota) { |
| 419 ++additional_callback_count_; | 422 ++additional_callback_count_; |
| 420 } | 423 } |
| 421 | 424 |
| 422 QuotaManager* quota_manager() const { return quota_manager_.get(); } | 425 QuotaManager* quota_manager() const { return quota_manager_.get(); } |
| 423 void set_quota_manager(QuotaManager* quota_manager) { | 426 void set_quota_manager(QuotaManager* quota_manager) { |
| 424 quota_manager_ = quota_manager; | 427 quota_manager_ = quota_manager; |
| 425 } | 428 } |
| 426 | 429 |
| 427 MockSpecialStoragePolicy* mock_special_storage_policy() const { | 430 MockSpecialStoragePolicy* mock_special_storage_policy() const { |
| 428 return mock_special_storage_policy_.get(); | 431 return mock_special_storage_policy_.get(); |
| 429 } | 432 } |
| 430 | 433 |
| 431 QuotaStatusCode status() const { return quota_status_; } | 434 QuotaStatusCode status() const { return quota_status_; } |
| 432 const UsageInfoEntries& usage_info() const { return usage_info_; } | 435 const UsageInfoEntries& usage_info() const { return usage_info_; } |
| 433 int64 usage() const { return usage_; } | 436 int64_t usage() const { return usage_; } |
| 434 int64 limited_usage() const { return limited_usage_; } | 437 int64_t limited_usage() const { return limited_usage_; } |
| 435 int64 unlimited_usage() const { return unlimited_usage_; } | 438 int64_t unlimited_usage() const { return unlimited_usage_; } |
| 436 int64 quota() const { return quota_; } | 439 int64_t quota() const { return quota_; } |
| 437 int64 available_space() const { return available_space_; } | 440 int64_t available_space() const { return available_space_; } |
| 438 const GURL& eviction_origin() const { return eviction_origin_; } | 441 const GURL& eviction_origin() const { return eviction_origin_; } |
| 439 const std::set<GURL>& modified_origins() const { return modified_origins_; } | 442 const std::set<GURL>& modified_origins() const { return modified_origins_; } |
| 440 StorageType modified_origins_type() const { return modified_origins_type_; } | 443 StorageType modified_origins_type() const { return modified_origins_type_; } |
| 441 const QuotaTableEntries& quota_entries() const { return quota_entries_; } | 444 const QuotaTableEntries& quota_entries() const { return quota_entries_; } |
| 442 const OriginInfoTableEntries& origin_info_entries() const { | 445 const OriginInfoTableEntries& origin_info_entries() const { |
| 443 return origin_info_entries_; | 446 return origin_info_entries_; |
| 444 } | 447 } |
| 445 base::FilePath profile_path() const { return data_dir_.path(); } | 448 base::FilePath profile_path() const { return data_dir_.path(); } |
| 446 int status_callback_count() const { return status_callback_count_; } | 449 int status_callback_count() const { return status_callback_count_; } |
| 447 void reset_status_callback_count() { status_callback_count_ = 0; } | 450 void reset_status_callback_count() { status_callback_count_ = 0; } |
| 448 | 451 |
| 449 private: | 452 private: |
| 450 base::Time IncrementMockTime() { | 453 base::Time IncrementMockTime() { |
| 451 ++mock_time_counter_; | 454 ++mock_time_counter_; |
| 452 return base::Time::FromDoubleT(mock_time_counter_ * 10.0); | 455 return base::Time::FromDoubleT(mock_time_counter_ * 10.0); |
| 453 } | 456 } |
| 454 | 457 |
| 455 base::MessageLoop message_loop_; | 458 base::MessageLoop message_loop_; |
| 456 base::ScopedTempDir data_dir_; | 459 base::ScopedTempDir data_dir_; |
| 457 | 460 |
| 458 scoped_refptr<QuotaManager> quota_manager_; | 461 scoped_refptr<QuotaManager> quota_manager_; |
| 459 scoped_refptr<MockSpecialStoragePolicy> mock_special_storage_policy_; | 462 scoped_refptr<MockSpecialStoragePolicy> mock_special_storage_policy_; |
| 460 | 463 |
| 461 QuotaStatusCode quota_status_; | 464 QuotaStatusCode quota_status_; |
| 462 UsageInfoEntries usage_info_; | 465 UsageInfoEntries usage_info_; |
| 463 int64 usage_; | 466 int64_t usage_; |
| 464 int64 limited_usage_; | 467 int64_t limited_usage_; |
| 465 int64 unlimited_usage_; | 468 int64_t unlimited_usage_; |
| 466 int64 quota_; | 469 int64_t quota_; |
| 467 int64 available_space_; | 470 int64_t available_space_; |
| 468 GURL eviction_origin_; | 471 GURL eviction_origin_; |
| 469 std::set<GURL> modified_origins_; | 472 std::set<GURL> modified_origins_; |
| 470 StorageType modified_origins_type_; | 473 StorageType modified_origins_type_; |
| 471 QuotaTableEntries quota_entries_; | 474 QuotaTableEntries quota_entries_; |
| 472 OriginInfoTableEntries origin_info_entries_; | 475 OriginInfoTableEntries origin_info_entries_; |
| 473 int status_callback_count_; | 476 int status_callback_count_; |
| 474 | 477 |
| 475 int additional_callback_count_; | 478 int additional_callback_count_; |
| 476 | 479 |
| 477 int mock_time_counter_; | 480 int mock_time_counter_; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 base::RunLoop().RunUntilIdle(); | 535 base::RunLoop().RunUntilIdle(); |
| 533 EXPECT_EQ(kQuotaStatusOk, status()); | 536 EXPECT_EQ(kQuotaStatusOk, status()); |
| 534 EXPECT_EQ(80, usage()); | 537 EXPECT_EQ(80, usage()); |
| 535 EXPECT_EQ(0, quota()); | 538 EXPECT_EQ(0, quota()); |
| 536 | 539 |
| 537 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); | 540 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); |
| 538 base::RunLoop().RunUntilIdle(); | 541 base::RunLoop().RunUntilIdle(); |
| 539 EXPECT_EQ(kQuotaStatusOk, status()); | 542 EXPECT_EQ(kQuotaStatusOk, status()); |
| 540 EXPECT_EQ(10, usage()); | 543 EXPECT_EQ(10, usage()); |
| 541 EXPECT_LE(0, quota()); | 544 EXPECT_LE(0, quota()); |
| 542 int64 quota_returned_for_foo = quota(); | 545 int64_t quota_returned_for_foo = quota(); |
| 543 | 546 |
| 544 GetUsageAndQuotaForWebApps(GURL("http://bar.com/"), kTemp); | 547 GetUsageAndQuotaForWebApps(GURL("http://bar.com/"), kTemp); |
| 545 base::RunLoop().RunUntilIdle(); | 548 base::RunLoop().RunUntilIdle(); |
| 546 EXPECT_EQ(kQuotaStatusOk, status()); | 549 EXPECT_EQ(kQuotaStatusOk, status()); |
| 547 EXPECT_EQ(0, usage()); | 550 EXPECT_EQ(0, usage()); |
| 548 EXPECT_EQ(quota_returned_for_foo, quota()); | 551 EXPECT_EQ(quota_returned_for_foo, quota()); |
| 549 } | 552 } |
| 550 | 553 |
| 551 TEST_F(QuotaManagerTest, GetUsage_NoClient) { | 554 TEST_F(QuotaManagerTest, GetUsage_NoClient) { |
| 552 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); | 555 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 { "http://unlimited/", kTemp, 512 }, | 662 { "http://unlimited/", kTemp, 512 }, |
| 660 { "http://installed/", kTemp, 1024 }, | 663 { "http://installed/", kTemp, 1024 }, |
| 661 }; | 664 }; |
| 662 mock_special_storage_policy()->AddUnlimited(GURL("http://unlimited/")); | 665 mock_special_storage_policy()->AddUnlimited(GURL("http://unlimited/")); |
| 663 mock_special_storage_policy()->GrantQueryDiskSize(GURL("http://installed/")); | 666 mock_special_storage_policy()->GrantQueryDiskSize(GURL("http://installed/")); |
| 664 RegisterClient(CreateClient(kData1, arraysize(kData1), | 667 RegisterClient(CreateClient(kData1, arraysize(kData1), |
| 665 QuotaClient::kFileSystem)); | 668 QuotaClient::kFileSystem)); |
| 666 RegisterClient(CreateClient(kData2, arraysize(kData2), | 669 RegisterClient(CreateClient(kData2, arraysize(kData2), |
| 667 QuotaClient::kDatabase)); | 670 QuotaClient::kDatabase)); |
| 668 | 671 |
| 669 const int64 kTempQuotaBase = | 672 const int64_t kTempQuotaBase = |
| 670 GetAvailableDiskSpaceForTest(base::FilePath()) / kPerHostTemporaryPortion; | 673 GetAvailableDiskSpaceForTest(base::FilePath()) / kPerHostTemporaryPortion; |
| 671 | 674 |
| 672 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); | 675 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); |
| 673 base::RunLoop().RunUntilIdle(); | 676 base::RunLoop().RunUntilIdle(); |
| 674 EXPECT_EQ(kQuotaStatusOk, status()); | 677 EXPECT_EQ(kQuotaStatusOk, status()); |
| 675 EXPECT_EQ(1 + 128, usage()); | 678 EXPECT_EQ(1 + 128, usage()); |
| 676 | 679 |
| 677 GetUsageAndQuotaForWebApps(GURL("http://bar.com/"), kPerm); | 680 GetUsageAndQuotaForWebApps(GURL("http://bar.com/"), kPerm); |
| 678 base::RunLoop().RunUntilIdle(); | 681 base::RunLoop().RunUntilIdle(); |
| 679 EXPECT_EQ(kQuotaStatusOk, status()); | 682 EXPECT_EQ(kQuotaStatusOk, status()); |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 { "http://foo.com:1/", kTemp, 20 }, | 1251 { "http://foo.com:1/", kTemp, 20 }, |
| 1249 { "http://foo.com/", kPerm, 300 }, | 1252 { "http://foo.com/", kPerm, 300 }, |
| 1250 { "http://bar.com/", kTemp, 4000 }, | 1253 { "http://bar.com/", kTemp, 4000 }, |
| 1251 }; | 1254 }; |
| 1252 MockStorageClient* client = CreateClient(kData, arraysize(kData), | 1255 MockStorageClient* client = CreateClient(kData, arraysize(kData), |
| 1253 QuotaClient::kFileSystem); | 1256 QuotaClient::kFileSystem); |
| 1254 RegisterClient(client); | 1257 RegisterClient(client); |
| 1255 | 1258 |
| 1256 GetGlobalUsage(kTemp); | 1259 GetGlobalUsage(kTemp); |
| 1257 base::RunLoop().RunUntilIdle(); | 1260 base::RunLoop().RunUntilIdle(); |
| 1258 int64 predelete_global_tmp = usage(); | 1261 int64_t predelete_global_tmp = usage(); |
| 1259 | 1262 |
| 1260 GetHostUsage("foo.com", kTemp); | 1263 GetHostUsage("foo.com", kTemp); |
| 1261 base::RunLoop().RunUntilIdle(); | 1264 base::RunLoop().RunUntilIdle(); |
| 1262 int64 predelete_host_tmp = usage(); | 1265 int64_t predelete_host_tmp = usage(); |
| 1263 | 1266 |
| 1264 GetHostUsage("foo.com", kPerm); | 1267 GetHostUsage("foo.com", kPerm); |
| 1265 base::RunLoop().RunUntilIdle(); | 1268 base::RunLoop().RunUntilIdle(); |
| 1266 int64 predelete_host_pers = usage(); | 1269 int64_t predelete_host_pers = usage(); |
| 1267 | 1270 |
| 1268 DeleteClientOriginData(client, GURL("http://foo.com/"), | 1271 DeleteClientOriginData(client, GURL("http://foo.com/"), |
| 1269 kTemp); | 1272 kTemp); |
| 1270 base::RunLoop().RunUntilIdle(); | 1273 base::RunLoop().RunUntilIdle(); |
| 1271 EXPECT_EQ(kQuotaStatusOk, status()); | 1274 EXPECT_EQ(kQuotaStatusOk, status()); |
| 1272 | 1275 |
| 1273 GetGlobalUsage(kTemp); | 1276 GetGlobalUsage(kTemp); |
| 1274 base::RunLoop().RunUntilIdle(); | 1277 base::RunLoop().RunUntilIdle(); |
| 1275 EXPECT_EQ(predelete_global_tmp - 1, usage()); | 1278 EXPECT_EQ(predelete_global_tmp - 1, usage()); |
| 1276 | 1279 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1315 }; | 1318 }; |
| 1316 MockStorageClient* client1 = CreateClient(kData1, arraysize(kData1), | 1319 MockStorageClient* client1 = CreateClient(kData1, arraysize(kData1), |
| 1317 QuotaClient::kFileSystem); | 1320 QuotaClient::kFileSystem); |
| 1318 MockStorageClient* client2 = CreateClient(kData2, arraysize(kData2), | 1321 MockStorageClient* client2 = CreateClient(kData2, arraysize(kData2), |
| 1319 QuotaClient::kDatabase); | 1322 QuotaClient::kDatabase); |
| 1320 RegisterClient(client1); | 1323 RegisterClient(client1); |
| 1321 RegisterClient(client2); | 1324 RegisterClient(client2); |
| 1322 | 1325 |
| 1323 GetGlobalUsage(kTemp); | 1326 GetGlobalUsage(kTemp); |
| 1324 base::RunLoop().RunUntilIdle(); | 1327 base::RunLoop().RunUntilIdle(); |
| 1325 int64 predelete_global_tmp = usage(); | 1328 int64_t predelete_global_tmp = usage(); |
| 1326 | 1329 |
| 1327 GetHostUsage("foo.com", kTemp); | 1330 GetHostUsage("foo.com", kTemp); |
| 1328 base::RunLoop().RunUntilIdle(); | 1331 base::RunLoop().RunUntilIdle(); |
| 1329 int64 predelete_host_tmp = usage(); | 1332 int64_t predelete_host_tmp = usage(); |
| 1330 | 1333 |
| 1331 GetHostUsage("foo.com", kPerm); | 1334 GetHostUsage("foo.com", kPerm); |
| 1332 base::RunLoop().RunUntilIdle(); | 1335 base::RunLoop().RunUntilIdle(); |
| 1333 int64 predelete_host_pers = usage(); | 1336 int64_t predelete_host_pers = usage(); |
| 1334 | 1337 |
| 1335 for (size_t i = 0; i < arraysize(kData1); ++i) | 1338 for (size_t i = 0; i < arraysize(kData1); ++i) |
| 1336 quota_manager()->NotifyStorageAccessed(QuotaClient::kUnknown, | 1339 quota_manager()->NotifyStorageAccessed(QuotaClient::kUnknown, |
| 1337 GURL(kData1[i].origin), kData1[i].type); | 1340 GURL(kData1[i].origin), kData1[i].type); |
| 1338 for (size_t i = 0; i < arraysize(kData2); ++i) | 1341 for (size_t i = 0; i < arraysize(kData2); ++i) |
| 1339 quota_manager()->NotifyStorageAccessed(QuotaClient::kUnknown, | 1342 quota_manager()->NotifyStorageAccessed(QuotaClient::kUnknown, |
| 1340 GURL(kData2[i].origin), kData2[i].type); | 1343 GURL(kData2[i].origin), kData2[i].type); |
| 1341 base::RunLoop().RunUntilIdle(); | 1344 base::RunLoop().RunUntilIdle(); |
| 1342 | 1345 |
| 1343 EvictOriginData(GURL("http://foo.com/"), kTemp); | 1346 EvictOriginData(GURL("http://foo.com/"), kTemp); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1440 { "http://foo.com/", kPerm, 300 }, | 1443 { "http://foo.com/", kPerm, 300 }, |
| 1441 { "http://bar.com/", kTemp, 4000 }, | 1444 { "http://bar.com/", kTemp, 4000 }, |
| 1442 }; | 1445 }; |
| 1443 static const int kNumberOfTemporaryOrigins = 3; | 1446 static const int kNumberOfTemporaryOrigins = 3; |
| 1444 MockStorageClient* client = CreateClient(kData, arraysize(kData), | 1447 MockStorageClient* client = CreateClient(kData, arraysize(kData), |
| 1445 QuotaClient::kFileSystem); | 1448 QuotaClient::kFileSystem); |
| 1446 RegisterClient(client); | 1449 RegisterClient(client); |
| 1447 | 1450 |
| 1448 GetGlobalUsage(kTemp); | 1451 GetGlobalUsage(kTemp); |
| 1449 base::RunLoop().RunUntilIdle(); | 1452 base::RunLoop().RunUntilIdle(); |
| 1450 int64 predelete_global_tmp = usage(); | 1453 int64_t predelete_global_tmp = usage(); |
| 1451 | 1454 |
| 1452 GetHostUsage("foo.com", kTemp); | 1455 GetHostUsage("foo.com", kTemp); |
| 1453 base::RunLoop().RunUntilIdle(); | 1456 base::RunLoop().RunUntilIdle(); |
| 1454 int64 predelete_host_tmp = usage(); | 1457 int64_t predelete_host_tmp = usage(); |
| 1455 | 1458 |
| 1456 GetHostUsage("foo.com", kPerm); | 1459 GetHostUsage("foo.com", kPerm); |
| 1457 base::RunLoop().RunUntilIdle(); | 1460 base::RunLoop().RunUntilIdle(); |
| 1458 int64 predelete_host_pers = usage(); | 1461 int64_t predelete_host_pers = usage(); |
| 1459 | 1462 |
| 1460 for (size_t i = 0; i < arraysize(kData); ++i) | 1463 for (size_t i = 0; i < arraysize(kData); ++i) |
| 1461 NotifyStorageAccessed(client, GURL(kData[i].origin), kData[i].type); | 1464 NotifyStorageAccessed(client, GURL(kData[i].origin), kData[i].type); |
| 1462 base::RunLoop().RunUntilIdle(); | 1465 base::RunLoop().RunUntilIdle(); |
| 1463 | 1466 |
| 1464 client->AddOriginToErrorSet(GURL("http://foo.com/"), kTemp); | 1467 client->AddOriginToErrorSet(GURL("http://foo.com/"), kTemp); |
| 1465 | 1468 |
| 1466 for (int i = 0; | 1469 for (int i = 0; |
| 1467 i < QuotaManager::kThresholdOfErrorsToBeBlacklisted + 1; | 1470 i < QuotaManager::kThresholdOfErrorsToBeBlacklisted + 1; |
| 1468 ++i) { | 1471 ++i) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1545 TEST_F(QuotaManagerTest, DeleteHostDataSimple) { | 1548 TEST_F(QuotaManagerTest, DeleteHostDataSimple) { |
| 1546 static const MockOriginData kData[] = { | 1549 static const MockOriginData kData[] = { |
| 1547 { "http://foo.com/", kTemp, 1 }, | 1550 { "http://foo.com/", kTemp, 1 }, |
| 1548 }; | 1551 }; |
| 1549 MockStorageClient* client = CreateClient(kData, arraysize(kData), | 1552 MockStorageClient* client = CreateClient(kData, arraysize(kData), |
| 1550 QuotaClient::kFileSystem); | 1553 QuotaClient::kFileSystem); |
| 1551 RegisterClient(client); | 1554 RegisterClient(client); |
| 1552 | 1555 |
| 1553 GetGlobalUsage(kTemp); | 1556 GetGlobalUsage(kTemp); |
| 1554 base::RunLoop().RunUntilIdle(); | 1557 base::RunLoop().RunUntilIdle(); |
| 1555 const int64 predelete_global_tmp = usage(); | 1558 const int64_t predelete_global_tmp = usage(); |
| 1556 | 1559 |
| 1557 GetHostUsage("foo.com", kTemp); | 1560 GetHostUsage("foo.com", kTemp); |
| 1558 base::RunLoop().RunUntilIdle(); | 1561 base::RunLoop().RunUntilIdle(); |
| 1559 int64 predelete_host_tmp = usage(); | 1562 int64_t predelete_host_tmp = usage(); |
| 1560 | 1563 |
| 1561 GetHostUsage("foo.com", kPerm); | 1564 GetHostUsage("foo.com", kPerm); |
| 1562 base::RunLoop().RunUntilIdle(); | 1565 base::RunLoop().RunUntilIdle(); |
| 1563 int64 predelete_host_pers = usage(); | 1566 int64_t predelete_host_pers = usage(); |
| 1564 | 1567 |
| 1565 DeleteHostData(std::string(), kTemp, kAllClients); | 1568 DeleteHostData(std::string(), kTemp, kAllClients); |
| 1566 base::RunLoop().RunUntilIdle(); | 1569 base::RunLoop().RunUntilIdle(); |
| 1567 EXPECT_EQ(kQuotaStatusOk, status()); | 1570 EXPECT_EQ(kQuotaStatusOk, status()); |
| 1568 | 1571 |
| 1569 GetGlobalUsage(kTemp); | 1572 GetGlobalUsage(kTemp); |
| 1570 base::RunLoop().RunUntilIdle(); | 1573 base::RunLoop().RunUntilIdle(); |
| 1571 EXPECT_EQ(predelete_global_tmp, usage()); | 1574 EXPECT_EQ(predelete_global_tmp, usage()); |
| 1572 | 1575 |
| 1573 GetHostUsage("foo.com", kTemp); | 1576 GetHostUsage("foo.com", kTemp); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1611 }; | 1614 }; |
| 1612 MockStorageClient* client1 = CreateClient(kData1, arraysize(kData1), | 1615 MockStorageClient* client1 = CreateClient(kData1, arraysize(kData1), |
| 1613 QuotaClient::kFileSystem); | 1616 QuotaClient::kFileSystem); |
| 1614 MockStorageClient* client2 = CreateClient(kData2, arraysize(kData2), | 1617 MockStorageClient* client2 = CreateClient(kData2, arraysize(kData2), |
| 1615 QuotaClient::kDatabase); | 1618 QuotaClient::kDatabase); |
| 1616 RegisterClient(client1); | 1619 RegisterClient(client1); |
| 1617 RegisterClient(client2); | 1620 RegisterClient(client2); |
| 1618 | 1621 |
| 1619 GetGlobalUsage(kTemp); | 1622 GetGlobalUsage(kTemp); |
| 1620 base::RunLoop().RunUntilIdle(); | 1623 base::RunLoop().RunUntilIdle(); |
| 1621 const int64 predelete_global_tmp = usage(); | 1624 const int64_t predelete_global_tmp = usage(); |
| 1622 | 1625 |
| 1623 GetHostUsage("foo.com", kTemp); | 1626 GetHostUsage("foo.com", kTemp); |
| 1624 base::RunLoop().RunUntilIdle(); | 1627 base::RunLoop().RunUntilIdle(); |
| 1625 const int64 predelete_foo_tmp = usage(); | 1628 const int64_t predelete_foo_tmp = usage(); |
| 1626 | 1629 |
| 1627 GetHostUsage("bar.com", kTemp); | 1630 GetHostUsage("bar.com", kTemp); |
| 1628 base::RunLoop().RunUntilIdle(); | 1631 base::RunLoop().RunUntilIdle(); |
| 1629 const int64 predelete_bar_tmp = usage(); | 1632 const int64_t predelete_bar_tmp = usage(); |
| 1630 | 1633 |
| 1631 GetHostUsage("foo.com", kPerm); | 1634 GetHostUsage("foo.com", kPerm); |
| 1632 base::RunLoop().RunUntilIdle(); | 1635 base::RunLoop().RunUntilIdle(); |
| 1633 const int64 predelete_foo_pers = usage(); | 1636 const int64_t predelete_foo_pers = usage(); |
| 1634 | 1637 |
| 1635 GetHostUsage("bar.com", kPerm); | 1638 GetHostUsage("bar.com", kPerm); |
| 1636 base::RunLoop().RunUntilIdle(); | 1639 base::RunLoop().RunUntilIdle(); |
| 1637 const int64 predelete_bar_pers = usage(); | 1640 const int64_t predelete_bar_pers = usage(); |
| 1638 | 1641 |
| 1639 reset_status_callback_count(); | 1642 reset_status_callback_count(); |
| 1640 DeleteHostData("foo.com", kTemp, kAllClients); | 1643 DeleteHostData("foo.com", kTemp, kAllClients); |
| 1641 DeleteHostData("bar.com", kTemp, kAllClients); | 1644 DeleteHostData("bar.com", kTemp, kAllClients); |
| 1642 DeleteHostData("foo.com", kTemp, kAllClients); | 1645 DeleteHostData("foo.com", kTemp, kAllClients); |
| 1643 base::RunLoop().RunUntilIdle(); | 1646 base::RunLoop().RunUntilIdle(); |
| 1644 | 1647 |
| 1645 EXPECT_EQ(3, status_callback_count()); | 1648 EXPECT_EQ(3, status_callback_count()); |
| 1646 | 1649 |
| 1647 DumpOriginInfoTable(); | 1650 DumpOriginInfoTable(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1699 }; | 1702 }; |
| 1700 MockStorageClient* client1 = CreateClient(kData1, arraysize(kData1), | 1703 MockStorageClient* client1 = CreateClient(kData1, arraysize(kData1), |
| 1701 QuotaClient::kFileSystem); | 1704 QuotaClient::kFileSystem); |
| 1702 MockStorageClient* client2 = CreateClient(kData2, arraysize(kData2), | 1705 MockStorageClient* client2 = CreateClient(kData2, arraysize(kData2), |
| 1703 QuotaClient::kDatabase); | 1706 QuotaClient::kDatabase); |
| 1704 RegisterClient(client1); | 1707 RegisterClient(client1); |
| 1705 RegisterClient(client2); | 1708 RegisterClient(client2); |
| 1706 | 1709 |
| 1707 GetGlobalUsage(kTemp); | 1710 GetGlobalUsage(kTemp); |
| 1708 base::RunLoop().RunUntilIdle(); | 1711 base::RunLoop().RunUntilIdle(); |
| 1709 const int64 predelete_global_tmp = usage(); | 1712 const int64_t predelete_global_tmp = usage(); |
| 1710 | 1713 |
| 1711 GetHostUsage("foo.com", kTemp); | 1714 GetHostUsage("foo.com", kTemp); |
| 1712 base::RunLoop().RunUntilIdle(); | 1715 base::RunLoop().RunUntilIdle(); |
| 1713 const int64 predelete_foo_tmp = usage(); | 1716 const int64_t predelete_foo_tmp = usage(); |
| 1714 | 1717 |
| 1715 GetHostUsage("bar.com", kTemp); | 1718 GetHostUsage("bar.com", kTemp); |
| 1716 base::RunLoop().RunUntilIdle(); | 1719 base::RunLoop().RunUntilIdle(); |
| 1717 const int64 predelete_bar_tmp = usage(); | 1720 const int64_t predelete_bar_tmp = usage(); |
| 1718 | 1721 |
| 1719 GetHostUsage("foo.com", kPerm); | 1722 GetHostUsage("foo.com", kPerm); |
| 1720 base::RunLoop().RunUntilIdle(); | 1723 base::RunLoop().RunUntilIdle(); |
| 1721 const int64 predelete_foo_pers = usage(); | 1724 const int64_t predelete_foo_pers = usage(); |
| 1722 | 1725 |
| 1723 GetHostUsage("bar.com", kPerm); | 1726 GetHostUsage("bar.com", kPerm); |
| 1724 base::RunLoop().RunUntilIdle(); | 1727 base::RunLoop().RunUntilIdle(); |
| 1725 const int64 predelete_bar_pers = usage(); | 1728 const int64_t predelete_bar_pers = usage(); |
| 1726 | 1729 |
| 1727 for (size_t i = 0; i < arraysize(kData1); ++i) | 1730 for (size_t i = 0; i < arraysize(kData1); ++i) |
| 1728 quota_manager()->NotifyStorageAccessed(QuotaClient::kUnknown, | 1731 quota_manager()->NotifyStorageAccessed(QuotaClient::kUnknown, |
| 1729 GURL(kData1[i].origin), kData1[i].type); | 1732 GURL(kData1[i].origin), kData1[i].type); |
| 1730 for (size_t i = 0; i < arraysize(kData2); ++i) | 1733 for (size_t i = 0; i < arraysize(kData2); ++i) |
| 1731 quota_manager()->NotifyStorageAccessed(QuotaClient::kUnknown, | 1734 quota_manager()->NotifyStorageAccessed(QuotaClient::kUnknown, |
| 1732 GURL(kData2[i].origin), kData2[i].type); | 1735 GURL(kData2[i].origin), kData2[i].type); |
| 1733 base::RunLoop().RunUntilIdle(); | 1736 base::RunLoop().RunUntilIdle(); |
| 1734 | 1737 |
| 1735 reset_status_callback_count(); | 1738 reset_status_callback_count(); |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2067 QuotaClient::kDatabase); | 2070 QuotaClient::kDatabase); |
| 2068 MockStorageClient* client4 = CreateClient(kData4, arraysize(kData4), | 2071 MockStorageClient* client4 = CreateClient(kData4, arraysize(kData4), |
| 2069 QuotaClient::kIndexedDatabase); | 2072 QuotaClient::kIndexedDatabase); |
| 2070 RegisterClient(client1); | 2073 RegisterClient(client1); |
| 2071 RegisterClient(client2); | 2074 RegisterClient(client2); |
| 2072 RegisterClient(client3); | 2075 RegisterClient(client3); |
| 2073 RegisterClient(client4); | 2076 RegisterClient(client4); |
| 2074 | 2077 |
| 2075 GetHostUsage("foo.com", kTemp); | 2078 GetHostUsage("foo.com", kTemp); |
| 2076 base::RunLoop().RunUntilIdle(); | 2079 base::RunLoop().RunUntilIdle(); |
| 2077 const int64 predelete_foo_tmp = usage(); | 2080 const int64_t predelete_foo_tmp = usage(); |
| 2078 | 2081 |
| 2079 DeleteOriginData(GURL("http://foo.com/"), kTemp, QuotaClient::kFileSystem); | 2082 DeleteOriginData(GURL("http://foo.com/"), kTemp, QuotaClient::kFileSystem); |
| 2080 base::RunLoop().RunUntilIdle(); | 2083 base::RunLoop().RunUntilIdle(); |
| 2081 GetHostUsage("foo.com", kTemp); | 2084 GetHostUsage("foo.com", kTemp); |
| 2082 base::RunLoop().RunUntilIdle(); | 2085 base::RunLoop().RunUntilIdle(); |
| 2083 EXPECT_EQ(predelete_foo_tmp - 1, usage()); | 2086 EXPECT_EQ(predelete_foo_tmp - 1, usage()); |
| 2084 | 2087 |
| 2085 DeleteOriginData(GURL("http://foo.com/"), kTemp, QuotaClient::kAppcache); | 2088 DeleteOriginData(GURL("http://foo.com/"), kTemp, QuotaClient::kAppcache); |
| 2086 base::RunLoop().RunUntilIdle(); | 2089 base::RunLoop().RunUntilIdle(); |
| 2087 GetHostUsage("foo.com", kTemp); | 2090 GetHostUsage("foo.com", kTemp); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2123 QuotaClient::kDatabase); | 2126 QuotaClient::kDatabase); |
| 2124 MockStorageClient* client4 = CreateClient(kData4, arraysize(kData4), | 2127 MockStorageClient* client4 = CreateClient(kData4, arraysize(kData4), |
| 2125 QuotaClient::kIndexedDatabase); | 2128 QuotaClient::kIndexedDatabase); |
| 2126 RegisterClient(client1); | 2129 RegisterClient(client1); |
| 2127 RegisterClient(client2); | 2130 RegisterClient(client2); |
| 2128 RegisterClient(client3); | 2131 RegisterClient(client3); |
| 2129 RegisterClient(client4); | 2132 RegisterClient(client4); |
| 2130 | 2133 |
| 2131 GetHostUsage("foo.com", kTemp); | 2134 GetHostUsage("foo.com", kTemp); |
| 2132 base::RunLoop().RunUntilIdle(); | 2135 base::RunLoop().RunUntilIdle(); |
| 2133 const int64 predelete_foo_tmp = usage(); | 2136 const int64_t predelete_foo_tmp = usage(); |
| 2134 | 2137 |
| 2135 DeleteHostData("foo.com", kTemp, QuotaClient::kFileSystem); | 2138 DeleteHostData("foo.com", kTemp, QuotaClient::kFileSystem); |
| 2136 base::RunLoop().RunUntilIdle(); | 2139 base::RunLoop().RunUntilIdle(); |
| 2137 GetHostUsage("foo.com", kTemp); | 2140 GetHostUsage("foo.com", kTemp); |
| 2138 base::RunLoop().RunUntilIdle(); | 2141 base::RunLoop().RunUntilIdle(); |
| 2139 EXPECT_EQ(predelete_foo_tmp - 1, usage()); | 2142 EXPECT_EQ(predelete_foo_tmp - 1, usage()); |
| 2140 | 2143 |
| 2141 DeleteHostData("foo.com", kTemp, QuotaClient::kAppcache); | 2144 DeleteHostData("foo.com", kTemp, QuotaClient::kAppcache); |
| 2142 base::RunLoop().RunUntilIdle(); | 2145 base::RunLoop().RunUntilIdle(); |
| 2143 GetHostUsage("foo.com", kTemp); | 2146 GetHostUsage("foo.com", kTemp); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2178 QuotaClient::kDatabase); | 2181 QuotaClient::kDatabase); |
| 2179 MockStorageClient* client4 = CreateClient(kData4, arraysize(kData4), | 2182 MockStorageClient* client4 = CreateClient(kData4, arraysize(kData4), |
| 2180 QuotaClient::kIndexedDatabase); | 2183 QuotaClient::kIndexedDatabase); |
| 2181 RegisterClient(client1); | 2184 RegisterClient(client1); |
| 2182 RegisterClient(client2); | 2185 RegisterClient(client2); |
| 2183 RegisterClient(client3); | 2186 RegisterClient(client3); |
| 2184 RegisterClient(client4); | 2187 RegisterClient(client4); |
| 2185 | 2188 |
| 2186 GetHostUsage("foo.com", kTemp); | 2189 GetHostUsage("foo.com", kTemp); |
| 2187 base::RunLoop().RunUntilIdle(); | 2190 base::RunLoop().RunUntilIdle(); |
| 2188 const int64 predelete_foo_tmp = usage(); | 2191 const int64_t predelete_foo_tmp = usage(); |
| 2189 | 2192 |
| 2190 DeleteOriginData(GURL("http://foo.com/"), kTemp, | 2193 DeleteOriginData(GURL("http://foo.com/"), kTemp, |
| 2191 QuotaClient::kFileSystem | QuotaClient::kDatabase); | 2194 QuotaClient::kFileSystem | QuotaClient::kDatabase); |
| 2192 base::RunLoop().RunUntilIdle(); | 2195 base::RunLoop().RunUntilIdle(); |
| 2193 GetHostUsage("foo.com", kTemp); | 2196 GetHostUsage("foo.com", kTemp); |
| 2194 base::RunLoop().RunUntilIdle(); | 2197 base::RunLoop().RunUntilIdle(); |
| 2195 EXPECT_EQ(predelete_foo_tmp - 4 - 1, usage()); | 2198 EXPECT_EQ(predelete_foo_tmp - 4 - 1, usage()); |
| 2196 | 2199 |
| 2197 DeleteOriginData(GURL("http://foo.com/"), kTemp, | 2200 DeleteOriginData(GURL("http://foo.com/"), kTemp, |
| 2198 QuotaClient::kAppcache | QuotaClient::kIndexedDatabase); | 2201 QuotaClient::kAppcache | QuotaClient::kIndexedDatabase); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2223 QuotaClient::kDatabase); | 2226 QuotaClient::kDatabase); |
| 2224 MockStorageClient* client4 = CreateClient(kData4, arraysize(kData4), | 2227 MockStorageClient* client4 = CreateClient(kData4, arraysize(kData4), |
| 2225 QuotaClient::kIndexedDatabase); | 2228 QuotaClient::kIndexedDatabase); |
| 2226 RegisterClient(client1); | 2229 RegisterClient(client1); |
| 2227 RegisterClient(client2); | 2230 RegisterClient(client2); |
| 2228 RegisterClient(client3); | 2231 RegisterClient(client3); |
| 2229 RegisterClient(client4); | 2232 RegisterClient(client4); |
| 2230 | 2233 |
| 2231 GetHostUsage("foo.com", kTemp); | 2234 GetHostUsage("foo.com", kTemp); |
| 2232 base::RunLoop().RunUntilIdle(); | 2235 base::RunLoop().RunUntilIdle(); |
| 2233 const int64 predelete_foo_tmp = usage(); | 2236 const int64_t predelete_foo_tmp = usage(); |
| 2234 | 2237 |
| 2235 DeleteHostData("foo.com", kTemp, | 2238 DeleteHostData("foo.com", kTemp, |
| 2236 QuotaClient::kFileSystem | QuotaClient::kAppcache); | 2239 QuotaClient::kFileSystem | QuotaClient::kAppcache); |
| 2237 base::RunLoop().RunUntilIdle(); | 2240 base::RunLoop().RunUntilIdle(); |
| 2238 GetHostUsage("foo.com", kTemp); | 2241 GetHostUsage("foo.com", kTemp); |
| 2239 base::RunLoop().RunUntilIdle(); | 2242 base::RunLoop().RunUntilIdle(); |
| 2240 EXPECT_EQ(predelete_foo_tmp - 2 - 1, usage()); | 2243 EXPECT_EQ(predelete_foo_tmp - 2 - 1, usage()); |
| 2241 | 2244 |
| 2242 DeleteHostData("foo.com", kTemp, | 2245 DeleteHostData("foo.com", kTemp, |
| 2243 QuotaClient::kDatabase | QuotaClient::kIndexedDatabase); | 2246 QuotaClient::kDatabase | QuotaClient::kIndexedDatabase); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2261 base::RunLoop().RunUntilIdle(); | 2264 base::RunLoop().RunUntilIdle(); |
| 2262 EXPECT_EQ(kQuotaStatusOk, status()); | 2265 EXPECT_EQ(kQuotaStatusOk, status()); |
| 2263 EXPECT_EQ(80, usage()); | 2266 EXPECT_EQ(80, usage()); |
| 2264 EXPECT_EQ(0, quota()); | 2267 EXPECT_EQ(0, quota()); |
| 2265 | 2268 |
| 2266 SetTemporaryGlobalQuota(100); | 2269 SetTemporaryGlobalQuota(100); |
| 2267 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); | 2270 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); |
| 2268 base::RunLoop().RunUntilIdle(); | 2271 base::RunLoop().RunUntilIdle(); |
| 2269 EXPECT_EQ(kQuotaStatusOk, status()); | 2272 EXPECT_EQ(kQuotaStatusOk, status()); |
| 2270 EXPECT_EQ(10, usage()); | 2273 EXPECT_EQ(10, usage()); |
| 2271 EXPECT_LE(std::min(static_cast<int64>(100 / kPerHostTemporaryPortion), | 2274 EXPECT_LE(std::min(static_cast<int64_t>(100 / kPerHostTemporaryPortion), |
| 2272 QuotaManager::kIncognitoDefaultQuotaLimit), quota()); | 2275 QuotaManager::kIncognitoDefaultQuotaLimit), |
| 2276 quota()); |
| 2273 | 2277 |
| 2274 mock_special_storage_policy()->AddUnlimited(GURL("http://foo.com/")); | 2278 mock_special_storage_policy()->AddUnlimited(GURL("http://foo.com/")); |
| 2275 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kPerm); | 2279 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kPerm); |
| 2276 base::RunLoop().RunUntilIdle(); | 2280 base::RunLoop().RunUntilIdle(); |
| 2277 EXPECT_EQ(kQuotaStatusOk, status()); | 2281 EXPECT_EQ(kQuotaStatusOk, status()); |
| 2278 EXPECT_EQ(80, usage()); | 2282 EXPECT_EQ(80, usage()); |
| 2279 EXPECT_EQ(QuotaManager::kIncognitoDefaultQuotaLimit, quota()); | 2283 EXPECT_EQ(QuotaManager::kIncognitoDefaultQuotaLimit, quota()); |
| 2280 | 2284 |
| 2281 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); | 2285 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); |
| 2282 base::RunLoop().RunUntilIdle(); | 2286 base::RunLoop().RunUntilIdle(); |
| 2283 EXPECT_EQ(kQuotaStatusOk, status()); | 2287 EXPECT_EQ(kQuotaStatusOk, status()); |
| 2284 EXPECT_EQ(10, usage()); | 2288 EXPECT_EQ(10, usage()); |
| 2285 EXPECT_EQ(QuotaManager::kIncognitoDefaultQuotaLimit, quota()); | 2289 EXPECT_EQ(QuotaManager::kIncognitoDefaultQuotaLimit, quota()); |
| 2286 } | 2290 } |
| 2287 | 2291 |
| 2288 TEST_F(QuotaManagerTest, GetVolumeInfo) { | 2292 TEST_F(QuotaManagerTest, GetVolumeInfo) { |
| 2289 // We aren't actually testing that it's correct, just that it's sane. | 2293 // We aren't actually testing that it's correct, just that it's sane. |
| 2290 base::FilePath tmp_dir; | 2294 base::FilePath tmp_dir; |
| 2291 ASSERT_TRUE(base::GetTempDir(&tmp_dir)); | 2295 ASSERT_TRUE(base::GetTempDir(&tmp_dir)); |
| 2292 uint64_t available_space = 0; | 2296 uint64_t available_space = 0; |
| 2293 uint64_t total_size = 0; | 2297 uint64_t total_size = 0; |
| 2294 EXPECT_TRUE(GetVolumeInfo(tmp_dir, &available_space, &total_size)); | 2298 EXPECT_TRUE(GetVolumeInfo(tmp_dir, &available_space, &total_size)); |
| 2295 EXPECT_GT(available_space, 0u) << tmp_dir.value(); | 2299 EXPECT_GT(available_space, 0u) << tmp_dir.value(); |
| 2296 EXPECT_GT(total_size, 0u) << tmp_dir.value(); | 2300 EXPECT_GT(total_size, 0u) << tmp_dir.value(); |
| 2297 } | 2301 } |
| 2298 | 2302 |
| 2299 } // namespace content | 2303 } // namespace content |
| OLD | NEW |