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

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

Issue 14295013: Simple Cache: DoomEntriesBetween() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix an actual bug in DoomEntry Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « net/disk_cache/simple/simple_util.h ('k') | 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_util.h" 5 #include "net/disk_cache/simple/simple_util.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 return base::HexStringToUInt64(hash_key, hash_key_out); 45 return base::HexStringToUInt64(hash_key, hash_key_out);
46 } 46 }
47 47
48 uint64 GetEntryHashKey(const std::string& key) { 48 uint64 GetEntryHashKey(const std::string& key) {
49 const std::string sha_hash = base::SHA1HashString(key); 49 const std::string sha_hash = base::SHA1HashString(key);
50 uint64 hash_key = 0; 50 uint64 hash_key = 0;
51 sha_hash.copy(reinterpret_cast<char*>(&hash_key), sizeof(hash_key)); 51 sha_hash.copy(reinterpret_cast<char*>(&hash_key), sizeof(hash_key));
52 return hash_key; 52 return hash_key;
53 } 53 }
54 54
55 std::string GetFilenameFromHexStringAndIndex(const std::string& hex_key,
56 int index) {
57 return hex_key + base::StringPrintf("_%1d", index);
58 }
59
55 std::string GetFilenameFromKeyAndIndex(const std::string& key, int index) { 60 std::string GetFilenameFromKeyAndIndex(const std::string& key, int index) {
56 return GetEntryHashKeyAsHexString(key) + base::StringPrintf("_%1d", index); 61 return GetEntryHashKeyAsHexString(key) + base::StringPrintf("_%1d", index);
57 } 62 }
58 63
59 int32 GetDataSizeFromKeyAndFileSize(const std::string& key, int64 file_size) { 64 int32 GetDataSizeFromKeyAndFileSize(const std::string& key, int64 file_size) {
60 int64 data_size = file_size - key.size() - 65 int64 data_size = file_size - key.size() -
61 sizeof(disk_cache::SimpleFileHeader); 66 sizeof(disk_cache::SimpleFileHeader);
62 DCHECK_GE(implicit_cast<int64>(std::numeric_limits<int32>::max()), data_size); 67 DCHECK_GE(implicit_cast<int64>(std::numeric_limits<int32>::max()), data_size);
63 return data_size; 68 return data_size;
64 } 69 }
65 70
66 int64 GetFileSizeFromKeyAndDataSize(const std::string& key, int32 data_size) { 71 int64 GetFileSizeFromKeyAndDataSize(const std::string& key, int32 data_size) {
67 return data_size + key.size() + sizeof(disk_cache::SimpleFileHeader); 72 return data_size + key.size() + sizeof(disk_cache::SimpleFileHeader);
68 } 73 }
69 74
70 int64 GetFileOffsetFromKeyAndDataOffset(const std::string& key, 75 int64 GetFileOffsetFromKeyAndDataOffset(const std::string& key,
71 int data_offset) { 76 int data_offset) {
72 const int64 headers_size = sizeof(disk_cache::SimpleFileHeader) + key.size(); 77 const int64 headers_size = sizeof(disk_cache::SimpleFileHeader) + key.size();
73 return headers_size + data_offset; 78 return headers_size + data_offset;
74 } 79 }
75 80
76 } // namespace simple_backend 81 } // namespace simple_backend
77 82
78 } // namespace disk_cache 83 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/simple/simple_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698