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

Side by Side Diff: content/browser/cache_storage/cache_storage_manager_unittest.cc

Issue 2186433004: [CacheStorage] Deleting a cache could delete the wrong directory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix1
Patch Set: Rebase Created 4 years, 4 months 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 unified diff | Download patch
« no previous file with comments | « content/browser/cache_storage/cache_storage.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/browser/cache_storage/cache_storage_manager.h" 5 #include "content/browser/cache_storage/cache_storage_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 EXPECT_TRUE(CachePut(callback_cache_handle_->value(), kTestURL)); 548 EXPECT_TRUE(CachePut(callback_cache_handle_->value(), kTestURL));
549 } 549 }
550 550
551 TEST_P(CacheStorageManagerTestP, DropRefAfterNewCacheWithSameNameCreated) { 551 TEST_P(CacheStorageManagerTestP, DropRefAfterNewCacheWithSameNameCreated) {
552 // Make sure that dropping the final cache handle to a doomed cache doesn't 552 // Make sure that dropping the final cache handle to a doomed cache doesn't
553 // affect newer caches with the same name. (see crbug.com/631467) 553 // affect newer caches with the same name. (see crbug.com/631467)
554 554
555 // 1. Create cache A and hang onto the handle 555 // 1. Create cache A and hang onto the handle
556 const GURL kTestURL = GURL("http://example.com/foo"); 556 const GURL kTestURL = GURL("http://example.com/foo");
557 EXPECT_TRUE(Open(origin1_, "foo")); 557 EXPECT_TRUE(Open(origin1_, "foo"));
558 EXPECT_FALSE(CacheMatch(callback_cache_handle_->value(), kTestURL));
559 std::unique_ptr<CacheStorageCacheHandle> cache_handle = 558 std::unique_ptr<CacheStorageCacheHandle> cache_handle =
560 std::move(callback_cache_handle_); 559 std::move(callback_cache_handle_);
561 560
562 // 2. Doom the cache 561 // 2. Doom the cache
563 EXPECT_TRUE(Delete(origin1_, "foo")); 562 EXPECT_TRUE(Delete(origin1_, "foo"));
564 563
565 // 3. Create cache B (with the same name) 564 // 3. Create cache B (with the same name)
566 EXPECT_TRUE(Open(origin1_, "foo")); 565 EXPECT_TRUE(Open(origin1_, "foo"));
567 EXPECT_FALSE(CacheMatch(callback_cache_handle_->value(), kTestURL));
568 566
569 // 4. Drop handle to A 567 // 4. Drop handle to A
570 cache_handle.reset(); 568 cache_handle.reset();
571 569
572 // 5. Verify that B still works 570 // 5. Verify that B still works
573 EXPECT_FALSE(CacheMatch(callback_cache_handle_->value(), kTestURL)); 571 EXPECT_FALSE(CacheMatch(callback_cache_handle_->value(), kTestURL));
574 } 572 }
575 573
574 TEST_P(CacheStorageManagerTestP, DeleteCorrectDirectory) {
575 // This test reproduces crbug.com/630036.
576 // 1. Cache A with name "foo" is created
577 const GURL kTestURL = GURL("http://example.com/foo");
578 EXPECT_TRUE(Open(origin1_, "foo"));
579 std::unique_ptr<CacheStorageCacheHandle> cache_handle =
580 std::move(callback_cache_handle_);
581
582 // 2. Cache A is doomed, but js hangs onto the handle.
583 EXPECT_TRUE(Delete(origin1_, "foo"));
584
585 // 3. Cache B with name "foo" is created
586 EXPECT_TRUE(Open(origin1_, "foo"));
587
588 // 4. Cache B is doomed, and both handles are reset.
589 EXPECT_TRUE(Delete(origin1_, "foo"));
590 cache_handle.reset();
591 callback_cache_handle_.reset();
592
593 // Do some busy work on a different cache to move the cache pool threads
594 // along and trigger the bug.
595 EXPECT_TRUE(Open(origin1_, "bar"));
596 EXPECT_TRUE(CachePut(callback_cache_handle_->value(), kTestURL));
597 EXPECT_TRUE(CacheMatch(callback_cache_handle_->value(), kTestURL));
598 }
599
576 TEST_P(CacheStorageManagerTestP, StorageMatchAllEntryExistsTwice) { 600 TEST_P(CacheStorageManagerTestP, StorageMatchAllEntryExistsTwice) {
577 EXPECT_TRUE(Open(origin1_, "foo")); 601 EXPECT_TRUE(Open(origin1_, "foo"));
578 EXPECT_TRUE(CachePutWithStatusCode(callback_cache_handle_->value(), 602 EXPECT_TRUE(CachePutWithStatusCode(callback_cache_handle_->value(),
579 GURL("http://example.com/foo"), 200)); 603 GURL("http://example.com/foo"), 200));
580 EXPECT_TRUE(Open(origin1_, "bar")); 604 EXPECT_TRUE(Open(origin1_, "bar"));
581 EXPECT_TRUE(CachePutWithStatusCode(callback_cache_handle_->value(), 605 EXPECT_TRUE(CachePutWithStatusCode(callback_cache_handle_->value(),
582 GURL("http://example.com/foo"), 201)); 606 GURL("http://example.com/foo"), 201));
583 607
584 EXPECT_TRUE(StorageMatchAll(origin1_, GURL("http://example.com/foo"))); 608 EXPECT_TRUE(StorageMatchAll(origin1_, GURL("http://example.com/foo")));
585 609
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 1299
1276 INSTANTIATE_TEST_CASE_P(CacheStorageManagerTests, 1300 INSTANTIATE_TEST_CASE_P(CacheStorageManagerTests,
1277 CacheStorageManagerTestP, 1301 CacheStorageManagerTestP,
1278 ::testing::Values(false, true)); 1302 ::testing::Values(false, true));
1279 1303
1280 INSTANTIATE_TEST_CASE_P(CacheStorageQuotaClientTests, 1304 INSTANTIATE_TEST_CASE_P(CacheStorageQuotaClientTests,
1281 CacheStorageQuotaClientTestP, 1305 CacheStorageQuotaClientTestP,
1282 ::testing::Values(false, true)); 1306 ::testing::Values(false, true));
1283 1307
1284 } // namespace content 1308 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/cache_storage/cache_storage.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698