| 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/file_util.h" | 7 #include "base/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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 SafeCreateDirectory(entry_path_.DirName()); | 101 SafeCreateDirectory(entry_path_.DirName()); |
| 102 | 102 |
| 103 base::FilePath::StringType file = entry_path_.value(); | 103 base::FilePath::StringType file = entry_path_.value(); |
| 104 #ifdef WIN32_LARGE_FILENAME_SUPPORT | 104 #ifdef WIN32_LARGE_FILENAME_SUPPORT |
| 105 entry_ = CreateFileW(file.c_str(), GENERIC_WRITE|GENERIC_READ, 0, 0, | 105 entry_ = CreateFileW(file.c_str(), GENERIC_WRITE|GENERIC_READ, 0, 0, |
| 106 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); | 106 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); |
| 107 if (entry_ == INVALID_HANDLE_VALUE) | 107 if (entry_ == INVALID_HANDLE_VALUE) |
| 108 wprintf(L"CreateFileW (%s) failed: %d\n", file.c_str(), GetLastError()); | 108 wprintf(L"CreateFileW (%s) failed: %d\n", file.c_str(), GetLastError()); |
| 109 return (entry_ != INVALID_HANDLE_VALUE) ? net::OK : net::ERR_FAILED; | 109 return (entry_ != INVALID_HANDLE_VALUE) ? net::OK : net::ERR_FAILED; |
| 110 #else | 110 #else |
| 111 entry_ = file_util::OpenFile(entry_path_, "w+"); | 111 entry_ = base::OpenFile(entry_path_, "w+"); |
| 112 return (entry_ != NULL) ? net::OK : net::ERR_FAILED; | 112 return (entry_ != NULL) ? net::OK : net::ERR_FAILED; |
| 113 #endif | 113 #endif |
| 114 } | 114 } |
| 115 | 115 |
| 116 // Utility Function to create a normalized header string from a | 116 // Utility Function to create a normalized header string from a |
| 117 // HttpResponseInfo. The output will be formatted exactly | 117 // HttpResponseInfo. The output will be formatted exactly |
| 118 // like so: | 118 // like so: |
| 119 // HTTP/<version> <status_code> <status_text>\n | 119 // HTTP/<version> <status_code> <status_text>\n |
| 120 // [<header-name>: <header-values>\n]* | 120 // [<header-name>: <header-values>\n]* |
| 121 // meaning, each line is \n-terminated, and there is no extra whitespace | 121 // meaning, each line is \n-terminated, and there is no extra whitespace |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 #else | 211 #else |
| 212 return fwrite(data, 1, len, entry_); | 212 return fwrite(data, 1, len, entry_); |
| 213 #endif | 213 #endif |
| 214 } | 214 } |
| 215 | 215 |
| 216 void DiskDumper::CloseEntry(disk_cache::Entry* entry, base::Time last_used, | 216 void DiskDumper::CloseEntry(disk_cache::Entry* entry, base::Time last_used, |
| 217 base::Time last_modified) { | 217 base::Time last_modified) { |
| 218 #ifdef WIN32_LARGE_FILENAME_SUPPORT | 218 #ifdef WIN32_LARGE_FILENAME_SUPPORT |
| 219 CloseHandle(entry_); | 219 CloseHandle(entry_); |
| 220 #else | 220 #else |
| 221 file_util::CloseFile(entry_); | 221 base::CloseFile(entry_); |
| 222 #endif | 222 #endif |
| 223 } | 223 } |
| OLD | NEW |