| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
| 7 #include "base/metrics/field_trial.h" | 7 #include "base/metrics/field_trial.h" |
| 8 #include "base/port.h" | 8 #include "base/port.h" |
| 9 #include "base/run_loop.h" |
| 9 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 10 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 11 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 12 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
| 12 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
| 13 #include "base/threading/platform_thread.h" | 14 #include "base/threading/platform_thread.h" |
| 14 #include "base/threading/thread_restrictions.h" | 15 #include "base/threading/thread_restrictions.h" |
| 15 #include "net/base/cache_type.h" | 16 #include "net/base/cache_type.h" |
| 16 #include "net/base/io_buffer.h" | 17 #include "net/base/io_buffer.h" |
| 17 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
| 18 #include "net/base/test_completion_callback.h" | 19 #include "net/base/test_completion_callback.h" |
| (...skipping 3256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3275 entry->Close(); | 3276 entry->Close(); |
| 3276 entry = NULL; | 3277 entry = NULL; |
| 3277 | 3278 |
| 3278 // To make sure the file creation completed we need to call open again so that | 3279 // To make sure the file creation completed we need to call open again so that |
| 3279 // we block until it actually created the files. | 3280 // we block until it actually created the files. |
| 3280 ASSERT_EQ(net::OK, OpenEntry(key, &entry)); | 3281 ASSERT_EQ(net::OK, OpenEntry(key, &entry)); |
| 3281 ASSERT_NE(null, entry); | 3282 ASSERT_NE(null, entry); |
| 3282 entry->Close(); | 3283 entry->Close(); |
| 3283 entry = NULL; | 3284 entry = NULL; |
| 3284 | 3285 |
| 3286 // The entry is being closed on the Simple Cache worker pool |
| 3287 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); |
| 3288 base::RunLoop().RunUntilIdle(); |
| 3289 |
| 3285 // Write an invalid header for stream 0 and stream 1. | 3290 // Write an invalid header for stream 0 and stream 1. |
| 3286 base::FilePath entry_file1_path = cache_path_.AppendASCII( | 3291 base::FilePath entry_file1_path = cache_path_.AppendASCII( |
| 3287 disk_cache::simple_util::GetFilenameFromKeyAndFileIndex(key, 0)); | 3292 disk_cache::simple_util::GetFilenameFromKeyAndFileIndex(key, 0)); |
| 3288 | 3293 |
| 3289 disk_cache::SimpleFileHeader header; | 3294 disk_cache::SimpleFileHeader header; |
| 3290 header.initial_magic_number = GG_UINT64_C(0xbadf00d); | 3295 header.initial_magic_number = GG_UINT64_C(0xbadf00d); |
| 3291 EXPECT_EQ( | 3296 EXPECT_EQ( |
| 3292 implicit_cast<int>(sizeof(header)), | 3297 implicit_cast<int>(sizeof(header)), |
| 3293 base::WriteFile(entry_file1_path, reinterpret_cast<char*>(&header), | 3298 base::WriteFile(entry_file1_path, reinterpret_cast<char*>(&header), |
| 3294 sizeof(header))); | 3299 sizeof(header))); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3486 // after closing. | 3491 // after closing. |
| 3487 // NOTE: IF THIS TEST IS FLAKY THEN IT IS FAILING. See https://crbug.com/416940 | 3492 // NOTE: IF THIS TEST IS FLAKY THEN IT IS FAILING. See https://crbug.com/416940 |
| 3488 TEST_F(DiskCacheBackendTest, SimpleCacheDeleteQuickly) { | 3493 TEST_F(DiskCacheBackendTest, SimpleCacheDeleteQuickly) { |
| 3489 SetSimpleCacheMode(); | 3494 SetSimpleCacheMode(); |
| 3490 for (int i = 0; i < 100; ++i) { | 3495 for (int i = 0; i < 100; ++i) { |
| 3491 InitCache(); | 3496 InitCache(); |
| 3492 cache_.reset(); | 3497 cache_.reset(); |
| 3493 EXPECT_TRUE(CleanupCacheDir()); | 3498 EXPECT_TRUE(CleanupCacheDir()); |
| 3494 } | 3499 } |
| 3495 } | 3500 } |
| OLD | NEW |