| 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/file_util.h" | 6 #include "base/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/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 3270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3281 entry->Close(); | 3281 entry->Close(); |
| 3282 entry = NULL; | 3282 entry = NULL; |
| 3283 | 3283 |
| 3284 // To make sure the file creation completed we need to call open again so that | 3284 // To make sure the file creation completed we need to call open again so that |
| 3285 // we block until it actually created the files. | 3285 // we block until it actually created the files. |
| 3286 ASSERT_EQ(net::OK, OpenEntry(key, &entry)); | 3286 ASSERT_EQ(net::OK, OpenEntry(key, &entry)); |
| 3287 ASSERT_NE(null, entry); | 3287 ASSERT_NE(null, entry); |
| 3288 entry->Close(); | 3288 entry->Close(); |
| 3289 entry = NULL; | 3289 entry = NULL; |
| 3290 | 3290 |
| 3291 // Write an invalid header on stream 1. | 3291 // Write an invalid header for stream 0 and stream 1. |
| 3292 base::FilePath entry_file1_path = cache_path_.AppendASCII( | 3292 base::FilePath entry_file1_path = cache_path_.AppendASCII( |
| 3293 disk_cache::simple_util::GetFilenameFromKeyAndIndex(key, 1)); | 3293 disk_cache::simple_util::GetFilenameFromKeyAndIndex(key, 0)); |
| 3294 | 3294 |
| 3295 disk_cache::SimpleFileHeader header; | 3295 disk_cache::SimpleFileHeader header; |
| 3296 header.initial_magic_number = GG_UINT64_C(0xbadf00d); | 3296 header.initial_magic_number = GG_UINT64_C(0xbadf00d); |
| 3297 EXPECT_EQ( | 3297 EXPECT_EQ( |
| 3298 implicit_cast<int>(sizeof(header)), | 3298 implicit_cast<int>(sizeof(header)), |
| 3299 file_util::WriteFile(entry_file1_path, reinterpret_cast<char*>(&header), | 3299 file_util::WriteFile(entry_file1_path, reinterpret_cast<char*>(&header), |
| 3300 sizeof(header))); | 3300 sizeof(header))); |
| 3301 ASSERT_EQ(net::ERR_FAILED, OpenEntry(key, &entry)); | 3301 ASSERT_EQ(net::ERR_FAILED, OpenEntry(key, &entry)); |
| 3302 } | 3302 } |
| 3303 | 3303 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3467 void* iter = NULL; | 3467 void* iter = NULL; |
| 3468 size_t count = 0; | 3468 size_t count = 0; |
| 3469 ASSERT_TRUE(EnumerateAndMatchKeys(-1, &iter, &keys_to_match, &count)); | 3469 ASSERT_TRUE(EnumerateAndMatchKeys(-1, &iter, &keys_to_match, &count)); |
| 3470 cache_->EndEnumeration(&iter); | 3470 cache_->EndEnumeration(&iter); |
| 3471 | 3471 |
| 3472 EXPECT_EQ(key_pool.size(), count); | 3472 EXPECT_EQ(key_pool.size(), count); |
| 3473 EXPECT_TRUE(keys_to_match.empty()); | 3473 EXPECT_TRUE(keys_to_match.empty()); |
| 3474 } | 3474 } |
| 3475 | 3475 |
| 3476 #endif // !defined(OS_WIN) | 3476 #endif // !defined(OS_WIN) |
| OLD | NEW |