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

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

Issue 2179353003: [CacheStorage] Check doomed caches first when dropping cache handles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the test to work around a different bug 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 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 std::unique_ptr<storage::BlobDataHandle> data_handle = 541 std::unique_ptr<storage::BlobDataHandle> data_handle =
542 std::move(callback_data_handle_); 542 std::move(callback_data_handle_);
543 543
544 EXPECT_TRUE(Delete(origin1_, "foo")); 544 EXPECT_TRUE(Delete(origin1_, "foo"));
545 // The cache is deleted but the handle to one of its entries is still 545 // The cache is deleted but the handle to one of its entries is still
546 // open. Creating a new cache in the same directory would fail on Windows. 546 // open. Creating a new cache in the same directory would fail on Windows.
547 EXPECT_TRUE(Open(origin1_, "foo")); 547 EXPECT_TRUE(Open(origin1_, "foo"));
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) {
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)
554
555 // 1. Create cache A and hang onto the handle
556 const GURL kTestURL = GURL("http://example.com/foo");
557 EXPECT_TRUE(Open(origin1_, "foo"));
558 EXPECT_FALSE(CacheMatch(callback_cache_handle_->value(), kTestURL));
559 std::unique_ptr<CacheStorageCacheHandle> cache_handle =
560 std::move(callback_cache_handle_);
561
562 // 2. Doom the cache
563 EXPECT_TRUE(Delete(origin1_, "foo"));
564
565 // 3. Create cache B (with the same name)
566 EXPECT_TRUE(Open(origin1_, "foo"));
567 EXPECT_FALSE(CacheMatch(callback_cache_handle_->value(), kTestURL));
568
569 // 4. Drop handle to A
570 cache_handle.reset();
571
572 // 5. Verify that B still works
573 EXPECT_FALSE(CacheMatch(callback_cache_handle_->value(), kTestURL));
574 }
575
551 TEST_P(CacheStorageManagerTestP, StorageMatchAllEntryExistsTwice) { 576 TEST_P(CacheStorageManagerTestP, StorageMatchAllEntryExistsTwice) {
552 EXPECT_TRUE(Open(origin1_, "foo")); 577 EXPECT_TRUE(Open(origin1_, "foo"));
553 EXPECT_TRUE(CachePutWithStatusCode(callback_cache_handle_->value(), 578 EXPECT_TRUE(CachePutWithStatusCode(callback_cache_handle_->value(),
554 GURL("http://example.com/foo"), 200)); 579 GURL("http://example.com/foo"), 200));
555 EXPECT_TRUE(Open(origin1_, "bar")); 580 EXPECT_TRUE(Open(origin1_, "bar"));
556 EXPECT_TRUE(CachePutWithStatusCode(callback_cache_handle_->value(), 581 EXPECT_TRUE(CachePutWithStatusCode(callback_cache_handle_->value(),
557 GURL("http://example.com/foo"), 201)); 582 GURL("http://example.com/foo"), 201));
558 583
559 EXPECT_TRUE(StorageMatchAll(origin1_, GURL("http://example.com/foo"))); 584 EXPECT_TRUE(StorageMatchAll(origin1_, GURL("http://example.com/foo")));
560 585
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 1275
1251 INSTANTIATE_TEST_CASE_P(CacheStorageManagerTests, 1276 INSTANTIATE_TEST_CASE_P(CacheStorageManagerTests,
1252 CacheStorageManagerTestP, 1277 CacheStorageManagerTestP,
1253 ::testing::Values(false, true)); 1278 ::testing::Values(false, true));
1254 1279
1255 INSTANTIATE_TEST_CASE_P(CacheStorageQuotaClientTests, 1280 INSTANTIATE_TEST_CASE_P(CacheStorageQuotaClientTests,
1256 CacheStorageQuotaClientTestP, 1281 CacheStorageQuotaClientTestP,
1257 ::testing::Values(false, true)); 1282 ::testing::Values(false, true));
1258 1283
1259 } // namespace content 1284 } // 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