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

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

Issue 2957133002: Implement in-memory byte hints in SimpleCache (Closed)
Patch Set: Adjust to the interface's naming change. Created 3 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
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 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after
1442 if (header_read_result != sizeof(header)) { 1442 if (header_read_result != sizeof(header)) {
1443 DLOG(WARNING) << "Could not read header from sparse file."; 1443 DLOG(WARNING) << "Could not read header from sparse file.";
1444 return false; 1444 return false;
1445 } 1445 }
1446 1446
1447 if (header.initial_magic_number != kSimpleInitialMagicNumber) { 1447 if (header.initial_magic_number != kSimpleInitialMagicNumber) {
1448 DLOG(WARNING) << "Sparse file magic number did not match."; 1448 DLOG(WARNING) << "Sparse file magic number did not match.";
1449 return false; 1449 return false;
1450 } 1450 }
1451 1451
1452 if (header.version != kSimpleVersion) { 1452 if (header.version < kLastCompatSparseVersion ||
1453 header.version > kSimpleVersion) {
1453 DLOG(WARNING) << "Sparse file unreadable version."; 1454 DLOG(WARNING) << "Sparse file unreadable version.";
1454 return false; 1455 return false;
1455 } 1456 }
1456 1457
1457 sparse_ranges_.clear(); 1458 sparse_ranges_.clear();
1458 1459
1459 int64_t range_header_offset = sizeof(header) + key_.size(); 1460 int64_t range_header_offset = sizeof(header) + key_.size();
1460 while (1) { 1461 while (1) {
1461 SimpleFileSparseRangeHeader range_header; 1462 SimpleFileSparseRangeHeader range_header;
1462 int range_header_read_result = 1463 int range_header_read_result =
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 range.offset = offset; 1597 range.offset = offset;
1597 range.length = len; 1598 range.length = len;
1598 range.data_crc32 = data_crc32; 1599 range.data_crc32 = data_crc32;
1599 range.file_offset = data_file_offset; 1600 range.file_offset = data_file_offset;
1600 sparse_ranges_.insert(std::make_pair(offset, range)); 1601 sparse_ranges_.insert(std::make_pair(offset, range));
1601 1602
1602 return true; 1603 return true;
1603 } 1604 }
1604 1605
1605 } // namespace disk_cache 1606 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/simple/simple_index_unittest.cc ('k') | net/disk_cache/simple/simple_version_upgrade.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698