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

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

Issue 12767006: [Cleanup] Remove StringPrintf from global namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, once more Created 7 years, 9 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
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 <limits> 9 #include <limits>
10 10
(...skipping 23 matching lines...) Expand all
34 using base::ReadPlatformFile; 34 using base::ReadPlatformFile;
35 using base::TaskRunner; 35 using base::TaskRunner;
36 using base::Time; 36 using base::Time;
37 using base::TruncatePlatformFile; 37 using base::TruncatePlatformFile;
38 using base::WritePlatformFile; 38 using base::WritePlatformFile;
39 39
40 namespace { 40 namespace {
41 41
42 std::string GetFilenameForKeyAndIndex(const std::string& key, int index) { 42 std::string GetFilenameForKeyAndIndex(const std::string& key, int index) {
43 const std::string sha_hash = base::SHA1HashString(key); 43 const std::string sha_hash = base::SHA1HashString(key);
44 return StringPrintf("%02x%02x%02x%02x%02x_%1d", 44 return base::StringPrintf("%02x%02x%02x%02x%02x_%1d",
45 implicit_cast<unsigned char>(sha_hash[0]), 45 implicit_cast<unsigned char>(sha_hash[0]),
46 implicit_cast<unsigned char>(sha_hash[1]), 46 implicit_cast<unsigned char>(sha_hash[1]),
47 implicit_cast<unsigned char>(sha_hash[2]), 47 implicit_cast<unsigned char>(sha_hash[2]),
48 implicit_cast<unsigned char>(sha_hash[3]), 48 implicit_cast<unsigned char>(sha_hash[3]),
49 implicit_cast<unsigned char>(sha_hash[4]), index); 49 implicit_cast<unsigned char>(sha_hash[4]), index);
50 } 50 }
51 51
52 int32 DataSizeFromKeyAndFileSize(size_t key_size, int64 file_size) { 52 int32 DataSizeFromKeyAndFileSize(size_t key_size, int64 file_size) {
53 int64 data_size = file_size - key_size - sizeof(disk_cache::SimpleFileHeader); 53 int64 data_size = file_size - key_size - sizeof(disk_cache::SimpleFileHeader);
54 DCHECK_GE(implicit_cast<int64>(std::numeric_limits<int32>::max()), data_size); 54 DCHECK_GE(implicit_cast<int64>(std::numeric_limits<int32>::max()), data_size);
55 return data_size; 55 return data_size;
56 } 56 }
57 57
58 int64 FileOffsetFromDataOffset(size_t key_size, int data_offset) { 58 int64 FileOffsetFromDataOffset(size_t key_size, int data_offset) {
59 const int64 headers_size = sizeof(disk_cache::SimpleFileHeader) + 59 const int64 headers_size = sizeof(disk_cache::SimpleFileHeader) +
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 DLOG(WARNING) << "Could not write keys to new cache entry."; 301 DLOG(WARNING) << "Could not write keys to new cache entry.";
302 return false; 302 return false;
303 } 303 }
304 } 304 }
305 305
306 initialized_ = true; 306 initialized_ = true;
307 return true; 307 return true;
308 } 308 }
309 309
310 } // namespace disk_cache 310 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698