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 3170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3181 entry->Close(); | 3181 entry->Close(); |
3182 entry = NULL; | 3182 entry = NULL; |
3183 | 3183 |
3184 // To make sure the file creation completed we need to call open again so that | 3184 // To make sure the file creation completed we need to call open again so that |
3185 // we block until it actually created the files. | 3185 // we block until it actually created the files. |
3186 ASSERT_EQ(net::OK, OpenEntry(key, &entry)); | 3186 ASSERT_EQ(net::OK, OpenEntry(key, &entry)); |
3187 ASSERT_NE(null, entry); | 3187 ASSERT_NE(null, entry); |
3188 entry->Close(); | 3188 entry->Close(); |
3189 entry = NULL; | 3189 entry = NULL; |
3190 | 3190 |
3191 // Write an invalid header on stream 1. | 3191 // Write an invalid header on stream 1. |
pasko
2013/09/13 19:09:21
Let's mention stream 0 here as well to be less cry
clamy
2013/09/16 15:01:17
Done.
| |
3192 base::FilePath entry_file1_path = cache_path_.AppendASCII( | 3192 base::FilePath entry_file1_path = cache_path_.AppendASCII( |
3193 disk_cache::simple_util::GetFilenameFromKeyAndIndex(key, 1)); | 3193 disk_cache::simple_util::GetFilenameFromKeyAndIndex(key, 0)); |
3194 | 3194 |
3195 disk_cache::SimpleFileHeader header; | 3195 disk_cache::SimpleFileHeader header; |
3196 header.initial_magic_number = GG_UINT64_C(0xbadf00d); | 3196 header.initial_magic_number = GG_UINT64_C(0xbadf00d); |
3197 EXPECT_EQ( | 3197 EXPECT_EQ( |
3198 implicit_cast<int>(sizeof(header)), | 3198 implicit_cast<int>(sizeof(header)), |
3199 file_util::WriteFile(entry_file1_path, reinterpret_cast<char*>(&header), | 3199 file_util::WriteFile(entry_file1_path, reinterpret_cast<char*>(&header), |
3200 sizeof(header))); | 3200 sizeof(header))); |
3201 ASSERT_EQ(net::ERR_FAILED, OpenEntry(key, &entry)); | 3201 ASSERT_EQ(net::ERR_FAILED, OpenEntry(key, &entry)); |
3202 } | 3202 } |
3203 | 3203 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3407 void* iter = NULL; | 3407 void* iter = NULL; |
3408 size_t count = 0; | 3408 size_t count = 0; |
3409 ASSERT_TRUE(EnumerateAndMatchKeys(-1, &iter, &keys_to_match, &count)); | 3409 ASSERT_TRUE(EnumerateAndMatchKeys(-1, &iter, &keys_to_match, &count)); |
3410 cache_->EndEnumeration(&iter); | 3410 cache_->EndEnumeration(&iter); |
3411 | 3411 |
3412 EXPECT_EQ(key_pool.size(), count); | 3412 EXPECT_EQ(key_pool.size(), count); |
3413 EXPECT_TRUE(keys_to_match.empty()); | 3413 EXPECT_TRUE(keys_to_match.empty()); |
3414 } | 3414 } |
3415 | 3415 |
3416 #endif // !defined(OS_WIN) | 3416 #endif // !defined(OS_WIN) |
OLD | NEW |