| 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/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 2700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2711 entry = NULL; | 2711 entry = NULL; |
| 2712 | 2712 |
| 2713 // Force the entry to flush to disk, so subsequent platform file operations | 2713 // Force the entry to flush to disk, so subsequent platform file operations |
| 2714 // succed. | 2714 // succed. |
| 2715 ASSERT_EQ(net::OK, OpenEntry(key, &entry)); | 2715 ASSERT_EQ(net::OK, OpenEntry(key, &entry)); |
| 2716 entry->Close(); | 2716 entry->Close(); |
| 2717 entry = NULL; | 2717 entry = NULL; |
| 2718 | 2718 |
| 2719 // Truncate the file such that the length isn't sufficient to have an EOF | 2719 // Truncate the file such that the length isn't sufficient to have an EOF |
| 2720 // record. | 2720 // record. |
| 2721 int kTruncationBytes = -implicit_cast<int>(sizeof(disk_cache::SimpleFileEOF)); | 2721 int kTruncationBytes = -static_cast<int>(sizeof(disk_cache::SimpleFileEOF)); |
| 2722 const base::FilePath entry_path = cache_path_.AppendASCII( | 2722 const base::FilePath entry_path = cache_path_.AppendASCII( |
| 2723 disk_cache::simple_util::GetFilenameFromKeyAndFileIndex(key, 0)); | 2723 disk_cache::simple_util::GetFilenameFromKeyAndFileIndex(key, 0)); |
| 2724 const int64 invalid_size = | 2724 const int64 invalid_size = |
| 2725 disk_cache::simple_util::GetFileSizeFromKeyAndDataSize(key, | 2725 disk_cache::simple_util::GetFileSizeFromKeyAndDataSize(key, |
| 2726 kTruncationBytes); | 2726 kTruncationBytes); |
| 2727 EXPECT_TRUE(TruncatePath(entry_path, invalid_size)); | 2727 EXPECT_TRUE(TruncatePath(entry_path, invalid_size)); |
| 2728 EXPECT_EQ(net::ERR_FAILED, OpenEntry(key, &entry)); | 2728 EXPECT_EQ(net::ERR_FAILED, OpenEntry(key, &entry)); |
| 2729 DisableIntegrityCheck(); | 2729 DisableIntegrityCheck(); |
| 2730 } | 2730 } |
| 2731 | 2731 |
| (...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4140 | 4140 |
| 4141 ret = entry->ReadSparseData(kSize, buffer.get(), kSize, callback.callback()); | 4141 ret = entry->ReadSparseData(kSize, buffer.get(), kSize, callback.callback()); |
| 4142 EXPECT_EQ(kSize, callback.GetResult(ret)); | 4142 EXPECT_EQ(kSize, callback.GetResult(ret)); |
| 4143 | 4143 |
| 4144 // Make sure the first range was removed when the second was written. | 4144 // Make sure the first range was removed when the second was written. |
| 4145 ret = entry->ReadSparseData(0, buffer.get(), kSize, callback.callback()); | 4145 ret = entry->ReadSparseData(0, buffer.get(), kSize, callback.callback()); |
| 4146 EXPECT_EQ(0, callback.GetResult(ret)); | 4146 EXPECT_EQ(0, callback.GetResult(ret)); |
| 4147 | 4147 |
| 4148 entry->Close(); | 4148 entry->Close(); |
| 4149 } | 4149 } |
| OLD | NEW |