| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "net/disk_cache/simple/simple_synchronous_entry.h" | 5 #include "net/disk_cache/simple/simple_synchronous_entry.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 #include <functional> | 9 #include <functional> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 stream_0_size == 0 | 767 stream_0_size == 0 |
| 768 ? crc32(0, Z_NULL, 0) | 768 ? crc32(0, Z_NULL, 0) |
| 769 : crc32(crc32(0, Z_NULL, 0), | 769 : crc32(crc32(0, Z_NULL, 0), |
| 770 reinterpret_cast<const Bytef*>((*stream_0_data)->data()), | 770 reinterpret_cast<const Bytef*>((*stream_0_data)->data()), |
| 771 stream_0_size); | 771 stream_0_size); |
| 772 if (has_crc32 && read_crc32 != expected_crc32) { | 772 if (has_crc32 && read_crc32 != expected_crc32) { |
| 773 DLOG(INFO) << "EOF record had bad crc."; | 773 DLOG(INFO) << "EOF record had bad crc."; |
| 774 RecordCheckEOFResult(cache_type_, CHECK_EOF_RESULT_CRC_MISMATCH); | 774 RecordCheckEOFResult(cache_type_, CHECK_EOF_RESULT_CRC_MISMATCH); |
| 775 return net::ERR_FAILED; | 775 return net::ERR_FAILED; |
| 776 } | 776 } |
| 777 *out_stream_0_crc32 = read_crc32; | 777 *out_stream_0_crc32 = expected_crc32; |
| 778 RecordCheckEOFResult(cache_type_, CHECK_EOF_RESULT_SUCCESS); | 778 RecordCheckEOFResult(cache_type_, CHECK_EOF_RESULT_SUCCESS); |
| 779 return net::OK; | 779 return net::OK; |
| 780 } | 780 } |
| 781 | 781 |
| 782 int SimpleSynchronousEntry::GetEOFRecordData(int index, | 782 int SimpleSynchronousEntry::GetEOFRecordData(int index, |
| 783 const SimpleEntryStat& entry_stat, | 783 const SimpleEntryStat& entry_stat, |
| 784 bool* out_has_crc32, | 784 bool* out_has_crc32, |
| 785 uint32* out_crc32, | 785 uint32* out_crc32, |
| 786 int* out_data_size) const { | 786 int* out_data_size) const { |
| 787 SimpleFileEOF eof_record; | 787 SimpleFileEOF eof_record; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 808 SIMPLE_CACHE_UMA(BOOLEAN, "SyncCheckEOFHasCrc", cache_type_, *out_has_crc32); | 808 SIMPLE_CACHE_UMA(BOOLEAN, "SyncCheckEOFHasCrc", cache_type_, *out_has_crc32); |
| 809 return net::OK; | 809 return net::OK; |
| 810 } | 810 } |
| 811 | 811 |
| 812 void SimpleSynchronousEntry::Doom() const { | 812 void SimpleSynchronousEntry::Doom() const { |
| 813 // TODO(gavinp): Consider if we should guard against redundant Doom() calls. | 813 // TODO(gavinp): Consider if we should guard against redundant Doom() calls. |
| 814 DeleteFilesForEntryHash(path_, entry_hash_); | 814 DeleteFilesForEntryHash(path_, entry_hash_); |
| 815 } | 815 } |
| 816 | 816 |
| 817 } // namespace disk_cache | 817 } // namespace disk_cache |
| OLD | NEW |