Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1089)

Side by Side Diff: net/disk_cache/simple/simple_synchronous_entry.cc

Issue 24251005: SimpleCache: fix error in computation of crc32 for stream 0 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698