| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <set> | 6 #include <set> |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 const StorageType kPerm = kStorageTypePersistent; | 51 const StorageType kPerm = kStorageTypePersistent; |
| 52 const StorageType kSync = kStorageTypeSyncable; | 52 const StorageType kSync = kStorageTypeSyncable; |
| 53 | 53 |
| 54 const int kAllClients = QuotaClient::kAllClientsMask; | 54 const int kAllClients = QuotaClient::kAllClientsMask; |
| 55 | 55 |
| 56 const int64 kAvailableSpaceForApp = 13377331U; | 56 const int64 kAvailableSpaceForApp = 13377331U; |
| 57 | 57 |
| 58 const int64 kMinimumPreserveForSystem = QuotaManager::kMinimumPreserveForSystem; | 58 const int64 kMinimumPreserveForSystem = QuotaManager::kMinimumPreserveForSystem; |
| 59 const int kPerHostTemporaryPortion = QuotaManager::kPerHostTemporaryPortion; | 59 const int kPerHostTemporaryPortion = QuotaManager::kPerHostTemporaryPortion; |
| 60 | 60 |
| 61 const GURL kTestEvictionOrigin = GURL("http://test.eviction.policy/result"); |
| 62 |
| 61 // Returns a deterministic value for the amount of available disk space. | 63 // Returns a deterministic value for the amount of available disk space. |
| 62 int64 GetAvailableDiskSpaceForTest(const base::FilePath&) { | 64 int64 GetAvailableDiskSpaceForTest(const base::FilePath&) { |
| 63 return kAvailableSpaceForApp + kMinimumPreserveForSystem; | 65 return kAvailableSpaceForApp + kMinimumPreserveForSystem; |
| 64 } | 66 } |
| 65 | 67 |
| 68 class TestEvictionPolicy : public storage::QuotaEvictionPolicy { |
| 69 public: |
| 70 TestEvictionPolicy() {} |
| 71 ~TestEvictionPolicy() override {} |
| 72 |
| 73 // Overridden from storage::QuotaEvictionPolicy: |
| 74 void GetEvictionOrigin(const scoped_refptr<storage::SpecialStoragePolicy>& |
| 75 special_storage_policy, |
| 76 const std::map<GURL, int64>& usage_map, |
| 77 int64 global_quota, |
| 78 const storage::GetOriginCallback& callback) override { |
| 79 callback.Run(kTestEvictionOrigin); |
| 80 } |
| 81 }; |
| 82 |
| 66 } // namespace | 83 } // namespace |
| 67 | 84 |
| 68 class QuotaManagerTest : public testing::Test { | 85 class QuotaManagerTest : public testing::Test { |
| 69 protected: | 86 protected: |
| 70 typedef QuotaManager::QuotaTableEntry QuotaTableEntry; | 87 typedef QuotaManager::QuotaTableEntry QuotaTableEntry; |
| 71 typedef QuotaManager::QuotaTableEntries QuotaTableEntries; | 88 typedef QuotaManager::QuotaTableEntries QuotaTableEntries; |
| 72 typedef QuotaManager::OriginInfoTableEntries OriginInfoTableEntries; | 89 typedef QuotaManager::OriginInfoTableEntries OriginInfoTableEntries; |
| 73 | 90 |
| 74 public: | 91 public: |
| 75 QuotaManagerTest() | 92 QuotaManagerTest() |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 StorageType type) { | 287 StorageType type) { |
| 271 DCHECK(client); | 288 DCHECK(client); |
| 272 quota_manager_->NotifyStorageAccessedInternal( | 289 quota_manager_->NotifyStorageAccessedInternal( |
| 273 client->id(), origin, type, IncrementMockTime()); | 290 client->id(), origin, type, IncrementMockTime()); |
| 274 } | 291 } |
| 275 | 292 |
| 276 void DeleteOriginFromDatabase(const GURL& origin, StorageType type) { | 293 void DeleteOriginFromDatabase(const GURL& origin, StorageType type) { |
| 277 quota_manager_->DeleteOriginFromDatabase(origin, type); | 294 quota_manager_->DeleteOriginFromDatabase(origin, type); |
| 278 } | 295 } |
| 279 | 296 |
| 280 void GetLRUOrigin(StorageType type) { | 297 void GetEvictionOrigin(StorageType type) { |
| 281 lru_origin_ = GURL(); | 298 eviction_origin_ = GURL(); |
| 282 quota_manager_->GetLRUOrigin( | 299 // The quota manager's default eviction policy is to use an LRU eviction |
| 283 type, | 300 // policy. |
| 284 base::Bind(&QuotaManagerTest::DidGetLRUOrigin, | 301 quota_manager_->GetEvictionOrigin( |
| 285 weak_factory_.GetWeakPtr())); | 302 type, 0, base::Bind(&QuotaManagerTest::DidGetEvictionOrigin, |
| 303 weak_factory_.GetWeakPtr())); |
| 286 } | 304 } |
| 287 | 305 |
| 288 void NotifyOriginInUse(const GURL& origin) { | 306 void NotifyOriginInUse(const GURL& origin) { |
| 289 quota_manager_->NotifyOriginInUse(origin); | 307 quota_manager_->NotifyOriginInUse(origin); |
| 290 } | 308 } |
| 291 | 309 |
| 292 void NotifyOriginNoLongerInUse(const GURL& origin) { | 310 void NotifyOriginNoLongerInUse(const GURL& origin) { |
| 293 quota_manager_->NotifyOriginNoLongerInUse(origin); | 311 quota_manager_->NotifyOriginNoLongerInUse(origin); |
| 294 } | 312 } |
| 295 | 313 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 } | 377 } |
| 360 | 378 |
| 361 void DidGetUsageAndQuotaForEviction(QuotaStatusCode status, | 379 void DidGetUsageAndQuotaForEviction(QuotaStatusCode status, |
| 362 const UsageAndQuota& usage_and_quota) { | 380 const UsageAndQuota& usage_and_quota) { |
| 363 quota_status_ = status; | 381 quota_status_ = status; |
| 364 limited_usage_ = usage_and_quota.global_limited_usage; | 382 limited_usage_ = usage_and_quota.global_limited_usage; |
| 365 quota_ = usage_and_quota.quota; | 383 quota_ = usage_and_quota.quota; |
| 366 available_space_ = usage_and_quota.available_disk_space; | 384 available_space_ = usage_and_quota.available_disk_space; |
| 367 } | 385 } |
| 368 | 386 |
| 369 void DidGetLRUOrigin(const GURL& origin) { | 387 void DidGetEvictionOrigin(const GURL& origin) { |
| 370 lru_origin_ = origin; | 388 eviction_origin_ = origin; |
| 371 } | 389 } |
| 372 | 390 |
| 373 void DidGetModifiedOrigins(const std::set<GURL>& origins, StorageType type) { | 391 void DidGetModifiedOrigins(const std::set<GURL>& origins, StorageType type) { |
| 374 modified_origins_ = origins; | 392 modified_origins_ = origins; |
| 375 modified_origins_type_ = type; | 393 modified_origins_type_ = type; |
| 376 } | 394 } |
| 377 | 395 |
| 378 void DidDumpQuotaTable(const QuotaTableEntries& entries) { | 396 void DidDumpQuotaTable(const QuotaTableEntries& entries) { |
| 379 quota_entries_ = entries; | 397 quota_entries_ = entries; |
| 380 } | 398 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 401 return mock_special_storage_policy_.get(); | 419 return mock_special_storage_policy_.get(); |
| 402 } | 420 } |
| 403 | 421 |
| 404 QuotaStatusCode status() const { return quota_status_; } | 422 QuotaStatusCode status() const { return quota_status_; } |
| 405 const UsageInfoEntries& usage_info() const { return usage_info_; } | 423 const UsageInfoEntries& usage_info() const { return usage_info_; } |
| 406 int64 usage() const { return usage_; } | 424 int64 usage() const { return usage_; } |
| 407 int64 limited_usage() const { return limited_usage_; } | 425 int64 limited_usage() const { return limited_usage_; } |
| 408 int64 unlimited_usage() const { return unlimited_usage_; } | 426 int64 unlimited_usage() const { return unlimited_usage_; } |
| 409 int64 quota() const { return quota_; } | 427 int64 quota() const { return quota_; } |
| 410 int64 available_space() const { return available_space_; } | 428 int64 available_space() const { return available_space_; } |
| 411 const GURL& lru_origin() const { return lru_origin_; } | 429 const GURL& eviction_origin() const { return eviction_origin_; } |
| 412 const std::set<GURL>& modified_origins() const { return modified_origins_; } | 430 const std::set<GURL>& modified_origins() const { return modified_origins_; } |
| 413 StorageType modified_origins_type() const { return modified_origins_type_; } | 431 StorageType modified_origins_type() const { return modified_origins_type_; } |
| 414 const QuotaTableEntries& quota_entries() const { return quota_entries_; } | 432 const QuotaTableEntries& quota_entries() const { return quota_entries_; } |
| 415 const OriginInfoTableEntries& origin_info_entries() const { | 433 const OriginInfoTableEntries& origin_info_entries() const { |
| 416 return origin_info_entries_; | 434 return origin_info_entries_; |
| 417 } | 435 } |
| 418 base::FilePath profile_path() const { return data_dir_.path(); } | 436 base::FilePath profile_path() const { return data_dir_.path(); } |
| 419 int status_callback_count() const { return status_callback_count_; } | 437 int status_callback_count() const { return status_callback_count_; } |
| 420 void reset_status_callback_count() { status_callback_count_ = 0; } | 438 void reset_status_callback_count() { status_callback_count_ = 0; } |
| 421 | 439 |
| 422 private: | 440 private: |
| 423 base::Time IncrementMockTime() { | 441 base::Time IncrementMockTime() { |
| 424 ++mock_time_counter_; | 442 ++mock_time_counter_; |
| 425 return base::Time::FromDoubleT(mock_time_counter_ * 10.0); | 443 return base::Time::FromDoubleT(mock_time_counter_ * 10.0); |
| 426 } | 444 } |
| 427 | 445 |
| 428 base::MessageLoop message_loop_; | 446 base::MessageLoop message_loop_; |
| 429 base::ScopedTempDir data_dir_; | 447 base::ScopedTempDir data_dir_; |
| 430 | 448 |
| 431 scoped_refptr<QuotaManager> quota_manager_; | 449 scoped_refptr<QuotaManager> quota_manager_; |
| 432 scoped_refptr<MockSpecialStoragePolicy> mock_special_storage_policy_; | 450 scoped_refptr<MockSpecialStoragePolicy> mock_special_storage_policy_; |
| 433 | 451 |
| 434 QuotaStatusCode quota_status_; | 452 QuotaStatusCode quota_status_; |
| 435 UsageInfoEntries usage_info_; | 453 UsageInfoEntries usage_info_; |
| 436 int64 usage_; | 454 int64 usage_; |
| 437 int64 limited_usage_; | 455 int64 limited_usage_; |
| 438 int64 unlimited_usage_; | 456 int64 unlimited_usage_; |
| 439 int64 quota_; | 457 int64 quota_; |
| 440 int64 available_space_; | 458 int64 available_space_; |
| 441 GURL lru_origin_; | 459 GURL eviction_origin_; |
| 442 std::set<GURL> modified_origins_; | 460 std::set<GURL> modified_origins_; |
| 443 StorageType modified_origins_type_; | 461 StorageType modified_origins_type_; |
| 444 QuotaTableEntries quota_entries_; | 462 QuotaTableEntries quota_entries_; |
| 445 OriginInfoTableEntries origin_info_entries_; | 463 OriginInfoTableEntries origin_info_entries_; |
| 446 int status_callback_count_; | 464 int status_callback_count_; |
| 447 | 465 |
| 448 int additional_callback_count_; | 466 int additional_callback_count_; |
| 449 | 467 |
| 450 int mock_time_counter_; | 468 int mock_time_counter_; |
| 451 | 469 |
| (...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1256 EXPECT_EQ(predelete_host_pers, usage()); | 1274 EXPECT_EQ(predelete_host_pers, usage()); |
| 1257 } | 1275 } |
| 1258 | 1276 |
| 1259 TEST_F(QuotaManagerTest, GetAvailableSpaceTest) { | 1277 TEST_F(QuotaManagerTest, GetAvailableSpaceTest) { |
| 1260 GetAvailableSpace(); | 1278 GetAvailableSpace(); |
| 1261 base::RunLoop().RunUntilIdle(); | 1279 base::RunLoop().RunUntilIdle(); |
| 1262 EXPECT_EQ(kQuotaStatusOk, status()); | 1280 EXPECT_EQ(kQuotaStatusOk, status()); |
| 1263 EXPECT_LE(0, available_space()); | 1281 EXPECT_LE(0, available_space()); |
| 1264 } | 1282 } |
| 1265 | 1283 |
| 1284 TEST_F(QuotaManagerTest, SetTemporaryStorageEvictionPolicy) { |
| 1285 quota_manager()->SetTemporaryStorageEvictionPolicy( |
| 1286 make_scoped_ptr(new TestEvictionPolicy)); |
| 1287 |
| 1288 GetEvictionOrigin(kTemp); |
| 1289 base::RunLoop().RunUntilIdle(); |
| 1290 EXPECT_EQ(kTestEvictionOrigin, eviction_origin()); |
| 1291 } |
| 1292 |
| 1266 TEST_F(QuotaManagerTest, EvictOriginData) { | 1293 TEST_F(QuotaManagerTest, EvictOriginData) { |
| 1267 static const MockOriginData kData1[] = { | 1294 static const MockOriginData kData1[] = { |
| 1268 { "http://foo.com/", kTemp, 1 }, | 1295 { "http://foo.com/", kTemp, 1 }, |
| 1269 { "http://foo.com:1/", kTemp, 20 }, | 1296 { "http://foo.com:1/", kTemp, 20 }, |
| 1270 { "http://foo.com/", kPerm, 300 }, | 1297 { "http://foo.com/", kPerm, 300 }, |
| 1271 { "http://bar.com/", kTemp, 4000 }, | 1298 { "http://bar.com/", kTemp, 4000 }, |
| 1272 }; | 1299 }; |
| 1273 static const MockOriginData kData2[] = { | 1300 static const MockOriginData kData2[] = { |
| 1274 { "http://foo.com/", kTemp, 50000 }, | 1301 { "http://foo.com/", kTemp, 50000 }, |
| 1275 { "http://foo.com:1/", kTemp, 6000 }, | 1302 { "http://foo.com:1/", kTemp, 6000 }, |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1380 if (itr->type == kTemp && | 1407 if (itr->type == kTemp && |
| 1381 GURL("http://foo.com/") == itr->origin) { | 1408 GURL("http://foo.com/") == itr->origin) { |
| 1382 found_origin_in_database = true; | 1409 found_origin_in_database = true; |
| 1383 break; | 1410 break; |
| 1384 } | 1411 } |
| 1385 } | 1412 } |
| 1386 // The origin "http://foo.com/" should be in the database. | 1413 // The origin "http://foo.com/" should be in the database. |
| 1387 EXPECT_TRUE(found_origin_in_database); | 1414 EXPECT_TRUE(found_origin_in_database); |
| 1388 | 1415 |
| 1389 for (size_t i = 0; i < kNumberOfTemporaryOrigins - 1; ++i) { | 1416 for (size_t i = 0; i < kNumberOfTemporaryOrigins - 1; ++i) { |
| 1390 GetLRUOrigin(kTemp); | 1417 GetEvictionOrigin(kTemp); |
| 1391 base::RunLoop().RunUntilIdle(); | 1418 base::RunLoop().RunUntilIdle(); |
| 1392 EXPECT_FALSE(lru_origin().is_empty()); | 1419 EXPECT_FALSE(eviction_origin().is_empty()); |
| 1393 // The origin "http://foo.com/" should not be in the LRU list. | 1420 // The origin "http://foo.com/" should not be in the LRU list. |
| 1394 EXPECT_NE(std::string("http://foo.com/"), lru_origin().spec()); | 1421 EXPECT_NE(std::string("http://foo.com/"), eviction_origin().spec()); |
| 1395 DeleteOriginFromDatabase(lru_origin(), kTemp); | 1422 DeleteOriginFromDatabase(eviction_origin(), kTemp); |
| 1396 base::RunLoop().RunUntilIdle(); | 1423 base::RunLoop().RunUntilIdle(); |
| 1397 } | 1424 } |
| 1398 | 1425 |
| 1399 // Now the LRU list must be empty. | 1426 // Now the LRU list must be empty. |
| 1400 GetLRUOrigin(kTemp); | 1427 GetEvictionOrigin(kTemp); |
| 1401 base::RunLoop().RunUntilIdle(); | 1428 base::RunLoop().RunUntilIdle(); |
| 1402 EXPECT_TRUE(lru_origin().is_empty()); | 1429 EXPECT_TRUE(eviction_origin().is_empty()); |
| 1403 | 1430 |
| 1404 // Deleting origins from the database should not affect the results of the | 1431 // Deleting origins from the database should not affect the results of the |
| 1405 // following checks. | 1432 // following checks. |
| 1406 GetGlobalUsage(kTemp); | 1433 GetGlobalUsage(kTemp); |
| 1407 base::RunLoop().RunUntilIdle(); | 1434 base::RunLoop().RunUntilIdle(); |
| 1408 EXPECT_EQ(predelete_global_tmp, usage()); | 1435 EXPECT_EQ(predelete_global_tmp, usage()); |
| 1409 | 1436 |
| 1410 GetHostUsage("foo.com", kTemp); | 1437 GetHostUsage("foo.com", kTemp); |
| 1411 base::RunLoop().RunUntilIdle(); | 1438 base::RunLoop().RunUntilIdle(); |
| 1412 EXPECT_EQ(predelete_host_tmp, usage()); | 1439 EXPECT_EQ(predelete_host_tmp, usage()); |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1721 { "http://a.com:1/", kTemp, 0 }, | 1748 { "http://a.com:1/", kTemp, 0 }, |
| 1722 { "https://a.com/", kTemp, 0 }, | 1749 { "https://a.com/", kTemp, 0 }, |
| 1723 { "http://b.com/", kPerm, 0 }, // persistent | 1750 { "http://b.com/", kPerm, 0 }, // persistent |
| 1724 { "http://c.com/", kTemp, 0 }, | 1751 { "http://c.com/", kTemp, 0 }, |
| 1725 }; | 1752 }; |
| 1726 MockStorageClient* client = CreateClient(kData, arraysize(kData), | 1753 MockStorageClient* client = CreateClient(kData, arraysize(kData), |
| 1727 QuotaClient::kFileSystem); | 1754 QuotaClient::kFileSystem); |
| 1728 RegisterClient(client); | 1755 RegisterClient(client); |
| 1729 | 1756 |
| 1730 GURL origin; | 1757 GURL origin; |
| 1731 GetLRUOrigin(kTemp); | 1758 GetEvictionOrigin(kTemp); |
| 1732 base::RunLoop().RunUntilIdle(); | 1759 base::RunLoop().RunUntilIdle(); |
| 1733 EXPECT_TRUE(lru_origin().is_empty()); | 1760 EXPECT_TRUE(eviction_origin().is_empty()); |
| 1734 | 1761 |
| 1735 NotifyStorageAccessed(client, GURL("http://a.com/"), kTemp); | 1762 NotifyStorageAccessed(client, GURL("http://a.com/"), kTemp); |
| 1736 GetLRUOrigin(kTemp); | 1763 GetEvictionOrigin(kTemp); |
| 1737 base::RunLoop().RunUntilIdle(); | 1764 base::RunLoop().RunUntilIdle(); |
| 1738 EXPECT_EQ("http://a.com/", lru_origin().spec()); | 1765 EXPECT_EQ("http://a.com/", eviction_origin().spec()); |
| 1739 | 1766 |
| 1740 NotifyStorageAccessed(client, GURL("http://b.com/"), kPerm); | 1767 NotifyStorageAccessed(client, GURL("http://b.com/"), kPerm); |
| 1741 NotifyStorageAccessed(client, GURL("https://a.com/"), kTemp); | 1768 NotifyStorageAccessed(client, GURL("https://a.com/"), kTemp); |
| 1742 NotifyStorageAccessed(client, GURL("http://c.com/"), kTemp); | 1769 NotifyStorageAccessed(client, GURL("http://c.com/"), kTemp); |
| 1743 GetLRUOrigin(kTemp); | 1770 GetEvictionOrigin(kTemp); |
| 1744 base::RunLoop().RunUntilIdle(); | 1771 base::RunLoop().RunUntilIdle(); |
| 1745 EXPECT_EQ("http://a.com/", lru_origin().spec()); | 1772 EXPECT_EQ("http://a.com/", eviction_origin().spec()); |
| 1746 | 1773 |
| 1747 DeleteOriginFromDatabase(lru_origin(), kTemp); | 1774 DeleteOriginFromDatabase(eviction_origin(), kTemp); |
| 1748 GetLRUOrigin(kTemp); | 1775 GetEvictionOrigin(kTemp); |
| 1749 base::RunLoop().RunUntilIdle(); | 1776 base::RunLoop().RunUntilIdle(); |
| 1750 EXPECT_EQ("https://a.com/", lru_origin().spec()); | 1777 EXPECT_EQ("https://a.com/", eviction_origin().spec()); |
| 1751 | 1778 |
| 1752 DeleteOriginFromDatabase(lru_origin(), kTemp); | 1779 DeleteOriginFromDatabase(eviction_origin(), kTemp); |
| 1753 GetLRUOrigin(kTemp); | 1780 GetEvictionOrigin(kTemp); |
| 1754 base::RunLoop().RunUntilIdle(); | 1781 base::RunLoop().RunUntilIdle(); |
| 1755 EXPECT_EQ("http://c.com/", lru_origin().spec()); | 1782 EXPECT_EQ("http://c.com/", eviction_origin().spec()); |
| 1756 } | 1783 } |
| 1757 | 1784 |
| 1758 TEST_F(QuotaManagerTest, GetLRUOriginWithOriginInUse) { | 1785 TEST_F(QuotaManagerTest, GetLRUOriginWithOriginInUse) { |
| 1759 static const MockOriginData kData[] = { | 1786 static const MockOriginData kData[] = { |
| 1760 { "http://a.com/", kTemp, 0 }, | 1787 { "http://a.com/", kTemp, 0 }, |
| 1761 { "http://a.com:1/", kTemp, 0 }, | 1788 { "http://a.com:1/", kTemp, 0 }, |
| 1762 { "https://a.com/", kTemp, 0 }, | 1789 { "https://a.com/", kTemp, 0 }, |
| 1763 { "http://b.com/", kPerm, 0 }, // persistent | 1790 { "http://b.com/", kPerm, 0 }, // persistent |
| 1764 { "http://c.com/", kTemp, 0 }, | 1791 { "http://c.com/", kTemp, 0 }, |
| 1765 }; | 1792 }; |
| 1766 MockStorageClient* client = CreateClient(kData, arraysize(kData), | 1793 MockStorageClient* client = CreateClient(kData, arraysize(kData), |
| 1767 QuotaClient::kFileSystem); | 1794 QuotaClient::kFileSystem); |
| 1768 RegisterClient(client); | 1795 RegisterClient(client); |
| 1769 | 1796 |
| 1770 GURL origin; | 1797 GURL origin; |
| 1771 GetLRUOrigin(kTemp); | 1798 GetEvictionOrigin(kTemp); |
| 1772 base::RunLoop().RunUntilIdle(); | 1799 base::RunLoop().RunUntilIdle(); |
| 1773 EXPECT_TRUE(lru_origin().is_empty()); | 1800 EXPECT_TRUE(eviction_origin().is_empty()); |
| 1774 | 1801 |
| 1775 NotifyStorageAccessed(client, GURL("http://a.com/"), kTemp); | 1802 NotifyStorageAccessed(client, GURL("http://a.com/"), kTemp); |
| 1776 NotifyStorageAccessed(client, GURL("http://b.com/"), kPerm); | 1803 NotifyStorageAccessed(client, GURL("http://b.com/"), kPerm); |
| 1777 NotifyStorageAccessed(client, GURL("https://a.com/"), kTemp); | 1804 NotifyStorageAccessed(client, GURL("https://a.com/"), kTemp); |
| 1778 NotifyStorageAccessed(client, GURL("http://c.com/"), kTemp); | 1805 NotifyStorageAccessed(client, GURL("http://c.com/"), kTemp); |
| 1779 | 1806 |
| 1780 GetLRUOrigin(kTemp); | 1807 GetEvictionOrigin(kTemp); |
| 1781 base::RunLoop().RunUntilIdle(); | 1808 base::RunLoop().RunUntilIdle(); |
| 1782 EXPECT_EQ("http://a.com/", lru_origin().spec()); | 1809 EXPECT_EQ("http://a.com/", eviction_origin().spec()); |
| 1783 | 1810 |
| 1784 // Notify origin http://a.com is in use. | 1811 // Notify origin http://a.com is in use. |
| 1785 NotifyOriginInUse(GURL("http://a.com/")); | 1812 NotifyOriginInUse(GURL("http://a.com/")); |
| 1786 GetLRUOrigin(kTemp); | 1813 GetEvictionOrigin(kTemp); |
| 1787 base::RunLoop().RunUntilIdle(); | 1814 base::RunLoop().RunUntilIdle(); |
| 1788 EXPECT_EQ("https://a.com/", lru_origin().spec()); | 1815 EXPECT_EQ("https://a.com/", eviction_origin().spec()); |
| 1789 | 1816 |
| 1790 // Notify origin https://a.com is in use while GetLRUOrigin is running. | 1817 // Notify origin https://a.com is in use while GetEvictionOrigin is running. |
| 1791 GetLRUOrigin(kTemp); | 1818 GetEvictionOrigin(kTemp); |
| 1792 NotifyOriginInUse(GURL("https://a.com/")); | 1819 NotifyOriginInUse(GURL("https://a.com/")); |
| 1793 base::RunLoop().RunUntilIdle(); | 1820 base::RunLoop().RunUntilIdle(); |
| 1794 // Post-filtering must have excluded the returned origin, so we will | 1821 // Post-filtering must have excluded the returned origin, so we will |
| 1795 // see empty result here. | 1822 // see empty result here. |
| 1796 EXPECT_TRUE(lru_origin().is_empty()); | 1823 EXPECT_TRUE(eviction_origin().is_empty()); |
| 1797 | 1824 |
| 1798 // Notify access for http://c.com while GetLRUOrigin is running. | 1825 // Notify access for http://c.com while GetEvictionOrigin is running. |
| 1799 GetLRUOrigin(kTemp); | 1826 GetEvictionOrigin(kTemp); |
| 1800 NotifyStorageAccessed(client, GURL("http://c.com/"), kTemp); | 1827 NotifyStorageAccessed(client, GURL("http://c.com/"), kTemp); |
| 1801 base::RunLoop().RunUntilIdle(); | 1828 base::RunLoop().RunUntilIdle(); |
| 1802 // Post-filtering must have excluded the returned origin, so we will | 1829 // Post-filtering must have excluded the returned origin, so we will |
| 1803 // see empty result here. | 1830 // see empty result here. |
| 1804 EXPECT_TRUE(lru_origin().is_empty()); | 1831 EXPECT_TRUE(eviction_origin().is_empty()); |
| 1805 | 1832 |
| 1806 NotifyOriginNoLongerInUse(GURL("http://a.com/")); | 1833 NotifyOriginNoLongerInUse(GURL("http://a.com/")); |
| 1807 NotifyOriginNoLongerInUse(GURL("https://a.com/")); | 1834 NotifyOriginNoLongerInUse(GURL("https://a.com/")); |
| 1808 GetLRUOrigin(kTemp); | 1835 GetEvictionOrigin(kTemp); |
| 1809 base::RunLoop().RunUntilIdle(); | 1836 base::RunLoop().RunUntilIdle(); |
| 1810 EXPECT_EQ("http://a.com/", lru_origin().spec()); | 1837 EXPECT_EQ("http://a.com/", eviction_origin().spec()); |
| 1811 } | 1838 } |
| 1812 | 1839 |
| 1813 TEST_F(QuotaManagerTest, GetOriginsModifiedSince) { | 1840 TEST_F(QuotaManagerTest, GetOriginsModifiedSince) { |
| 1814 static const MockOriginData kData[] = { | 1841 static const MockOriginData kData[] = { |
| 1815 { "http://a.com/", kTemp, 0 }, | 1842 { "http://a.com/", kTemp, 0 }, |
| 1816 { "http://a.com:1/", kTemp, 0 }, | 1843 { "http://a.com:1/", kTemp, 0 }, |
| 1817 { "https://a.com/", kTemp, 0 }, | 1844 { "https://a.com/", kTemp, 0 }, |
| 1818 { "http://b.com/", kPerm, 0 }, // persistent | 1845 { "http://b.com/", kPerm, 0 }, // persistent |
| 1819 { "http://c.com/", kTemp, 0 }, | 1846 { "http://c.com/", kTemp, 0 }, |
| 1820 }; | 1847 }; |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2177 EXPECT_EQ(QuotaManager::kIncognitoDefaultQuotaLimit, quota()); | 2204 EXPECT_EQ(QuotaManager::kIncognitoDefaultQuotaLimit, quota()); |
| 2178 | 2205 |
| 2179 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); | 2206 GetUsageAndQuotaForWebApps(GURL("http://foo.com/"), kTemp); |
| 2180 base::RunLoop().RunUntilIdle(); | 2207 base::RunLoop().RunUntilIdle(); |
| 2181 EXPECT_EQ(kQuotaStatusOk, status()); | 2208 EXPECT_EQ(kQuotaStatusOk, status()); |
| 2182 EXPECT_EQ(10, usage()); | 2209 EXPECT_EQ(10, usage()); |
| 2183 EXPECT_EQ(QuotaManager::kIncognitoDefaultQuotaLimit, quota()); | 2210 EXPECT_EQ(QuotaManager::kIncognitoDefaultQuotaLimit, quota()); |
| 2184 } | 2211 } |
| 2185 | 2212 |
| 2186 } // namespace content | 2213 } // namespace content |
| OLD | NEW |