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

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

Issue 2922973003: RFC: use some in-memory state in SimpleCache to quickly cache-miss some CantConditionalize cases
Patch Set: omewhat better take at higher-level HC::T impl, a bit lessy hacky, and actually write to cache now. Created 3 years, 6 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
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 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 if (header_read_result != sizeof(header)) { 1492 if (header_read_result != sizeof(header)) {
1493 DLOG(WARNING) << "Could not read header from sparse file."; 1493 DLOG(WARNING) << "Could not read header from sparse file.";
1494 return false; 1494 return false;
1495 } 1495 }
1496 1496
1497 if (header.initial_magic_number != kSimpleInitialMagicNumber) { 1497 if (header.initial_magic_number != kSimpleInitialMagicNumber) {
1498 DLOG(WARNING) << "Sparse file magic number did not match."; 1498 DLOG(WARNING) << "Sparse file magic number did not match.";
1499 return false; 1499 return false;
1500 } 1500 }
1501 1501
1502 if (header.version != kSimpleVersion) { 1502 if (header.version < kLastCompatSparseVersion ||
1503 header.version > kSimpleVersion) {
1503 DLOG(WARNING) << "Sparse file unreadable version."; 1504 DLOG(WARNING) << "Sparse file unreadable version.";
1504 return false; 1505 return false;
1505 } 1506 }
1506 1507
1507 sparse_ranges_.clear(); 1508 sparse_ranges_.clear();
1508 1509
1509 int64_t range_header_offset = sizeof(header) + key_.size(); 1510 int64_t range_header_offset = sizeof(header) + key_.size();
1510 while (1) { 1511 while (1) {
1511 SimpleFileSparseRangeHeader range_header; 1512 SimpleFileSparseRangeHeader range_header;
1512 int range_header_read_result = 1513 int range_header_read_result =
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 range.offset = offset; 1652 range.offset = offset;
1652 range.length = len; 1653 range.length = len;
1653 range.data_crc32 = data_crc32; 1654 range.data_crc32 = data_crc32;
1654 range.file_offset = data_file_offset; 1655 range.file_offset = data_file_offset;
1655 sparse_ranges_.insert(std::make_pair(offset, range)); 1656 sparse_ranges_.insert(std::make_pair(offset, range));
1656 1657
1657 return true; 1658 return true;
1658 } 1659 }
1659 1660
1660 } // namespace disk_cache 1661 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698