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

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

Issue 13731002: Cache Backend Proxy to intercept all cache events from the IO thread. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: trivial net.gyp merge 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
« no previous file with comments | « net/disk_cache/simple/simple_disk_format.h ('k') | net/disk_cache/tracing_cache_backend.h » ('j') | 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_disk_format.h" 5 #include "net/disk_cache/simple/simple_disk_format.h"
6 6
7 #include "base/hash.h" 7 #include "base/hash.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/sha1.h" 9 #include "base/sha1.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
11 #include "base/time.h" 11 #include "base/time.h"
12 12
13 namespace disk_cache { 13 namespace disk_cache {
14 14
15 SimpleFileHeader::SimpleFileHeader() {
16 // Make hashing repeatable: leave no padding bytes untouched.
17 memset(this, 0, sizeof(*this));
18 }
19
15 std::string GetEntryHashForKey(const std::string& key) { 20 std::string GetEntryHashForKey(const std::string& key) {
16 const std::string sha_hash = base::SHA1HashString(key); 21 const std::string sha_hash = base::SHA1HashString(key);
17 const std::string key_hash = base::StringPrintf( 22 const std::string key_hash = base::StringPrintf(
18 "%02x%02x%02x%02x%02x", 23 "%02x%02x%02x%02x%02x",
19 implicit_cast<unsigned char>(sha_hash[0]), 24 implicit_cast<unsigned char>(sha_hash[0]),
20 implicit_cast<unsigned char>(sha_hash[1]), 25 implicit_cast<unsigned char>(sha_hash[1]),
21 implicit_cast<unsigned char>(sha_hash[2]), 26 implicit_cast<unsigned char>(sha_hash[2]),
22 implicit_cast<unsigned char>(sha_hash[3]), 27 implicit_cast<unsigned char>(sha_hash[3]),
23 implicit_cast<unsigned char>(sha_hash[4])); 28 implicit_cast<unsigned char>(sha_hash[4]));
24 DCHECK_EQ(static_cast<size_t>(kEntryHashKeySize), key_hash.size()); 29 DCHECK_EQ(static_cast<size_t>(kEntryHashKeySize), key_hash.size());
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 EntryMetadata* to) { 95 EntryMetadata* to) {
91 if (to->last_used_time == 0) 96 if (to->last_used_time == 0)
92 to->last_used_time = from.last_used_time; 97 to->last_used_time = from.last_used_time;
93 if (to->entry_size == 0) 98 if (to->entry_size == 0)
94 to->entry_size = from.entry_size; 99 to->entry_size = from.entry_size;
95 } 100 }
96 101
97 } // namespace SimpleIndexFile 102 } // namespace SimpleIndexFile
98 103
99 } // namespace disk_cache 104 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/simple/simple_disk_format.h ('k') | net/disk_cache/tracing_cache_backend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698