OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stdint.h> |
| 6 |
5 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
6 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
7 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
8 #include "base/port.h" | |
9 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
10 #include "base/strings/string_split.h" | 11 #include "base/strings/string_split.h" |
11 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
12 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
13 #include "base/test/mock_entropy_provider.h" | 14 #include "base/test/mock_entropy_provider.h" |
14 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 15 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
15 #include "base/thread_task_runner_handle.h" | 16 #include "base/thread_task_runner_handle.h" |
16 #include "base/threading/platform_thread.h" | 17 #include "base/threading/platform_thread.h" |
17 #include "base/threading/thread_restrictions.h" | 18 #include "base/threading/thread_restrictions.h" |
18 #include "net/base/cache_type.h" | 19 #include "net/base/cache_type.h" |
(...skipping 3304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3323 | 3324 |
3324 // The entry is being closed on the Simple Cache worker pool | 3325 // The entry is being closed on the Simple Cache worker pool |
3325 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); | 3326 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); |
3326 base::RunLoop().RunUntilIdle(); | 3327 base::RunLoop().RunUntilIdle(); |
3327 | 3328 |
3328 // Write an invalid header for stream 0 and stream 1. | 3329 // Write an invalid header for stream 0 and stream 1. |
3329 base::FilePath entry_file1_path = cache_path_.AppendASCII( | 3330 base::FilePath entry_file1_path = cache_path_.AppendASCII( |
3330 disk_cache::simple_util::GetFilenameFromKeyAndFileIndex(key, 0)); | 3331 disk_cache::simple_util::GetFilenameFromKeyAndFileIndex(key, 0)); |
3331 | 3332 |
3332 disk_cache::SimpleFileHeader header; | 3333 disk_cache::SimpleFileHeader header; |
3333 header.initial_magic_number = GG_UINT64_C(0xbadf00d); | 3334 header.initial_magic_number = UINT64_C(0xbadf00d); |
3334 EXPECT_EQ( | 3335 EXPECT_EQ( |
3335 implicit_cast<int>(sizeof(header)), | 3336 implicit_cast<int>(sizeof(header)), |
3336 base::WriteFile(entry_file1_path, reinterpret_cast<char*>(&header), | 3337 base::WriteFile(entry_file1_path, reinterpret_cast<char*>(&header), |
3337 sizeof(header))); | 3338 sizeof(header))); |
3338 ASSERT_EQ(net::ERR_FAILED, OpenEntry(key, &entry)); | 3339 ASSERT_EQ(net::ERR_FAILED, OpenEntry(key, &entry)); |
3339 } | 3340 } |
3340 | 3341 |
3341 // Tests that the Simple Cache Backend fails to initialize with non-matching | 3342 // Tests that the Simple Cache Backend fails to initialize with non-matching |
3342 // file structure on disk. | 3343 // file structure on disk. |
3343 TEST_F(DiskCacheBackendTest, SimpleCacheOverBlockfileCache) { | 3344 TEST_F(DiskCacheBackendTest, SimpleCacheOverBlockfileCache) { |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3529 // after closing. | 3530 // after closing. |
3530 // NOTE: IF THIS TEST IS FLAKY THEN IT IS FAILING. See https://crbug.com/416940 | 3531 // NOTE: IF THIS TEST IS FLAKY THEN IT IS FAILING. See https://crbug.com/416940 |
3531 TEST_F(DiskCacheBackendTest, SimpleCacheDeleteQuickly) { | 3532 TEST_F(DiskCacheBackendTest, SimpleCacheDeleteQuickly) { |
3532 SetSimpleCacheMode(); | 3533 SetSimpleCacheMode(); |
3533 for (int i = 0; i < 100; ++i) { | 3534 for (int i = 0; i < 100; ++i) { |
3534 InitCache(); | 3535 InitCache(); |
3535 cache_.reset(); | 3536 cache_.reset(); |
3536 EXPECT_TRUE(CleanupCacheDir()); | 3537 EXPECT_TRUE(CleanupCacheDir()); |
3537 } | 3538 } |
3538 } | 3539 } |
OLD | NEW |