| OLD | NEW |
| 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/tools/dump_cache/cache_dumper.h" | 5 #include "net/tools/dump_cache/cache_dumper.h" |
| 6 | 6 |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 pos++; | 62 pos++; |
| 63 } | 63 } |
| 64 // Now create the full path | 64 // Now create the full path |
| 65 return CreateDirectoryW(path.value().c_str(), NULL) == TRUE; | 65 return CreateDirectoryW(path.value().c_str(), NULL) == TRUE; |
| 66 #else | 66 #else |
| 67 return base::CreateDirectory(path); | 67 return base::CreateDirectory(path); |
| 68 #endif | 68 #endif |
| 69 } | 69 } |
| 70 | 70 |
| 71 DiskDumper::DiskDumper(const base::FilePath& path) | 71 DiskDumper::DiskDumper(const base::FilePath& path) |
| 72 : path_(path), entry_(NULL) { | 72 : path_(path.AsEndingWithSeparator()), entry_(NULL) { |
| 73 base::CreateDirectory(path); | 73 base::CreateDirectory(path); |
| 74 } | 74 } |
| 75 | 75 |
| 76 int DiskDumper::CreateEntry(const std::string& key, | 76 int DiskDumper::CreateEntry(const std::string& key, |
| 77 disk_cache::Entry** entry, | 77 disk_cache::Entry** entry, |
| 78 const net::CompletionCallback& callback) { | 78 const net::CompletionCallback& callback) { |
| 79 // The URL may not start with a valid protocol; search for it. | 79 // The URL may not start with a valid protocol; search for it. |
| 80 int urlpos = key.find("http"); | 80 int urlpos = key.find("http"); |
| 81 std::string url = urlpos > 0 ? key.substr(urlpos) : key; | 81 std::string url = urlpos > 0 ? key.substr(urlpos) : key; |
| 82 std::string base_path = path_.MaybeAsASCII(); | 82 std::string base_path = path_.MaybeAsASCII(); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 } | 213 } |
| 214 | 214 |
| 215 void DiskDumper::CloseEntry(disk_cache::Entry* entry, base::Time last_used, | 215 void DiskDumper::CloseEntry(disk_cache::Entry* entry, base::Time last_used, |
| 216 base::Time last_modified) { | 216 base::Time last_modified) { |
| 217 #ifdef WIN32_LARGE_FILENAME_SUPPORT | 217 #ifdef WIN32_LARGE_FILENAME_SUPPORT |
| 218 CloseHandle(entry_); | 218 CloseHandle(entry_); |
| 219 #else | 219 #else |
| 220 base::CloseFile(entry_); | 220 base::CloseFile(entry_); |
| 221 #endif | 221 #endif |
| 222 } | 222 } |
| OLD | NEW |