summaryrefslogtreecommitdiffstats
path: root/net/disk_cache/block_files.cc
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-13 20:22:37 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-13 20:22:37 +0000
commitebcb20c7ead50898319724aa42efb0e31acf1877 (patch)
treefc1b9f066fc9ac3aa2faa32ae56e765f9133423a /net/disk_cache/block_files.cc
parent55a75d99c6609ed4f6dc7052fcf3d907efaf7137 (diff)
downloadchromium_src-ebcb20c7ead50898319724aa42efb0e31acf1877.zip
chromium_src-ebcb20c7ead50898319724aa42efb0e31acf1877.tar.gz
chromium_src-ebcb20c7ead50898319724aa42efb0e31acf1877.tar.bz2
Convert BlockFiles to use FilePath instead of wstring.
BUG=24444 Review URL: http://codereview.chromium.org/274012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28873 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/block_files.cc')
-rw-r--r--net/disk_cache/block_files.cc27
1 files changed, 12 insertions, 15 deletions
diff --git a/net/disk_cache/block_files.cc b/net/disk_cache/block_files.cc
index ffb74db..9cdb2e0 100644
--- a/net/disk_cache/block_files.cc
+++ b/net/disk_cache/block_files.cc
@@ -15,7 +15,7 @@ using base::Time;
namespace {
-const wchar_t* kBlockName = L"data_";
+const char* kBlockName = "data_";
// This array is used to perform a fast lookup of the nibble bit pattern to the
// type of entry that can be stored there (number of consecutive blocks).
@@ -200,24 +200,21 @@ void BlockFiles::CloseFiles() {
block_files_.clear();
}
-std::wstring BlockFiles::Name(int index) {
+FilePath BlockFiles::Name(int index) {
// The file format allows for 256 files.
DCHECK(index < 256 || index >= 0);
- std::wstring name(path_);
- std::wstring tmp = StringPrintf(L"%ls%d", kBlockName, index);
- file_util::AppendToPath(&name, tmp);
-
- return name;
+ std::string tmp = StringPrintf("%s%d", kBlockName, index);
+ return path_.AppendASCII(tmp);
}
bool BlockFiles::CreateBlockFile(int index, FileType file_type, bool force) {
- std::wstring name = Name(index);
+ FilePath name = Name(index);
int flags =
force ? base::PLATFORM_FILE_CREATE_ALWAYS : base::PLATFORM_FILE_CREATE;
flags |= base::PLATFORM_FILE_WRITE | base::PLATFORM_FILE_EXCLUSIVE_WRITE;
scoped_refptr<File> file(new File(
- base::CreatePlatformFile(name.c_str(), flags, NULL)));
+ base::CreatePlatformFile(name, flags, NULL)));
if (!file->IsValid())
return false;
@@ -236,16 +233,16 @@ bool BlockFiles::OpenBlockFile(int index) {
block_files_.resize(block_files_.size() + to_add);
}
- std::wstring name = Name(index);
+ FilePath name = Name(index);
scoped_refptr<MappedFile> file(new MappedFile());
- if (!file->Init(name, kBlockHeaderSize)) {
- LOG(ERROR) << "Failed to open " << name;
+ if (!file->Init(name.ToWStringHack(), kBlockHeaderSize)) {
+ LOG(ERROR) << "Failed to open " << name.value();
return false;
}
if (file->GetLength() < static_cast<size_t>(kBlockHeaderSize)) {
- LOG(ERROR) << "File too small " << name;
+ LOG(ERROR) << "File too small " << name.value();
return false;
}
@@ -390,11 +387,11 @@ void BlockFiles::RemoveEmptyFile(FileType block_type) {
block_files_[file_index]->Release();
block_files_[file_index] = NULL;
- std::wstring name = Name(file_index);
+ FilePath name = Name(file_index);
int failure = DeleteCacheFile(name) ? 0 : 1;
UMA_HISTOGRAM_COUNTS("DiskCache.DeleteFailed2", failure);
if (failure)
- LOG(ERROR) << "Failed to delete " << name << " from the cache.";
+ LOG(ERROR) << "Failed to delete " << name.value() << " from the cache.";
continue;
}