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

Side by Side Diff: net/disk_cache/cache_util.cc

Issue 176843022: Move UTF16ToASCII, remove WideToASCII. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
« no previous file with comments | « net/cert/x509_certificate_win.cc ('k') | net/dns/dns_config_service_win.cc » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/cache_util.h" 5 #include "net/disk_cache/cache_util.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/file_enumerator.h" 8 #include "base/files/file_enumerator.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "base/strings/utf_string_conversions.h"
12 #include "base/threading/thread_restrictions.h" 13 #include "base/threading/thread_restrictions.h"
13 #include "base/threading/worker_pool.h" 14 #include "base/threading/worker_pool.h"
14 15
15 namespace { 16 namespace {
16 17
17 const int kMaxOldFolders = 100; 18 const int kMaxOldFolders = 100;
18 19
19 // Returns a fully qualified name from path and name, using a given name prefix 20 // Returns a fully qualified name from path and name, using a given name prefix
20 // and index number. For instance, if the arguments are "/foo", "bar" and 5, it 21 // and index number. For instance, if the arguments are "/foo", "bar" and 5, it
21 // will return "/foo/old_bar_005". 22 // will return "/foo/old_bar_005".
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 base::ThreadRestrictions::ScopedAllowIO allow_io; 112 base::ThreadRestrictions::ScopedAllowIO allow_io;
112 113
113 base::FilePath current_path = full_path.StripTrailingSeparators(); 114 base::FilePath current_path = full_path.StripTrailingSeparators();
114 115
115 base::FilePath path = current_path.DirName(); 116 base::FilePath path = current_path.DirName();
116 base::FilePath name = current_path.BaseName(); 117 base::FilePath name = current_path.BaseName();
117 #if defined(OS_POSIX) 118 #if defined(OS_POSIX)
118 std::string name_str = name.value(); 119 std::string name_str = name.value();
119 #elif defined(OS_WIN) 120 #elif defined(OS_WIN)
120 // We created this file so it should only contain ASCII. 121 // We created this file so it should only contain ASCII.
121 std::string name_str = WideToASCII(name.value()); 122 std::string name_str = base::UTF16ToASCII(name.value());
122 #endif 123 #endif
123 124
124 base::FilePath to_delete = GetTempCacheName(path, name_str); 125 base::FilePath to_delete = GetTempCacheName(path, name_str);
125 if (to_delete.empty()) { 126 if (to_delete.empty()) {
126 LOG(ERROR) << "Unable to get another cache folder"; 127 LOG(ERROR) << "Unable to get another cache folder";
127 return false; 128 return false;
128 } 129 }
129 130
130 if (!disk_cache::MoveCache(full_path, to_delete)) { 131 if (!disk_cache::MoveCache(full_path, to_delete)) {
131 LOG(ERROR) << "Unable to move cache folder " << full_path.value() << " to " 132 LOG(ERROR) << "Unable to move cache folder " << full_path.value() << " to "
(...skipping 17 matching lines...) Expand all
149 // Limit cache size to somewhat less than kint32max to avoid potential 150 // Limit cache size to somewhat less than kint32max to avoid potential
150 // integer overflows in cache backend implementations. 151 // integer overflows in cache backend implementations.
151 DCHECK(kDefaultCacheSize * 4 < kint32max); 152 DCHECK(kDefaultCacheSize * 4 < kint32max);
152 if (max_size > kDefaultCacheSize * 4) 153 if (max_size > kDefaultCacheSize * 4)
153 max_size = kDefaultCacheSize * 4; 154 max_size = kDefaultCacheSize * 4;
154 155
155 return implicit_cast<int32>(max_size); 156 return implicit_cast<int32>(max_size);
156 } 157 }
157 158
158 } // namespace disk_cache 159 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/cert/x509_certificate_win.cc ('k') | net/dns/dns_config_service_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698