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

Side by Side Diff: net/tools/dump_cache/cache_dumper.cc

Issue 2253001: Revert 48186, 48196, 48198 (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 7 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
« no previous file with comments | « net/socket/tcp_client_socket_win.cc ('k') | net/tools/dump_cache/upgrade.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "net/base/io_buffer.h" 7 #include "net/base/io_buffer.h"
8 #include "net/disk_cache/entry_impl.h" 8 #include "net/disk_cache/entry_impl.h"
9 #include "net/http/http_cache.h" 9 #include "net/http/http_cache.h"
10 #include "net/http/http_response_headers.h" 10 #include "net/http/http_response_headers.h"
11 #include "net/http/http_response_info.h" 11 #include "net/http/http_response_info.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 entry_url_ = key; 83 entry_url_ = key;
84 84
85 FilePath directory = entry_path_.DirName(); 85 FilePath directory = entry_path_.DirName();
86 SafeCreateDirectory(directory.value()); 86 SafeCreateDirectory(directory.value());
87 87
88 std::wstring file = entry_path_.value(); 88 std::wstring file = entry_path_.value();
89 #ifdef WIN32_LARGE_FILENAME_SUPPORT 89 #ifdef WIN32_LARGE_FILENAME_SUPPORT
90 entry_ = CreateFileW(file.c_str(), GENERIC_WRITE|GENERIC_READ, 0, 0, 90 entry_ = CreateFileW(file.c_str(), GENERIC_WRITE|GENERIC_READ, 0, 0,
91 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); 91 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
92 if (entry_ == INVALID_HANDLE_VALUE) {
93 wprintf(L"CreateFileW (%s) failed: %d\n", file.c_str(), GetLastError());
94 return false;
95 }
96 return entry_ != INVALID_HANDLE_VALUE; 92 return entry_ != INVALID_HANDLE_VALUE;
97 #else 93 #else
98 entry_ = file_util::OpenFile(entry_path_, "w+"); 94 entry_ = file_util::OpenFile(entry_path_, "w+");
99 return entry_ != NULL; 95 return entry_ != NULL;
100 #endif 96 #endif
101 } 97 }
102 98
103 // Utility Function to create a normalized header string from a 99 // Utility Function to create a normalized header string from a
104 // HttpResponseInfo. The output will be formatted exactly 100 // HttpResponseInfo. The output will be formatted exactly
105 // like so: 101 // like so:
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 177
182 data = headers.c_str(); 178 data = headers.c_str();
183 len = headers.size(); 179 len = headers.size();
184 } else if (index == 1) { // Stream 1 is the data. 180 } else if (index == 1) { // Stream 1 is the data.
185 data = buf->data(); 181 data = buf->data();
186 len = buf_len; 182 len = buf_len;
187 } 183 }
188 #ifdef WIN32_LARGE_FILENAME_SUPPORT 184 #ifdef WIN32_LARGE_FILENAME_SUPPORT
189 DWORD bytes; 185 DWORD bytes;
190 DWORD rv = WriteFile(entry_, data, len, &bytes, 0); 186 DWORD rv = WriteFile(entry_, data, len, &bytes, 0);
191 return rv == TRUE && bytes == static_cast<DWORD>(len); 187 return rv == TRUE && bytes == len;
192 #else 188 #else
193 int bytes = fwrite(data, 1, len, entry_); 189 int bytes = fwrite(data, 1, len, entry_);
194 return bytes == len; 190 return bytes == len;
195 #endif 191 #endif
196 } 192 }
197 193
198 void DiskDumper::CloseEntry(disk_cache::Entry* entry, base::Time last_used, 194 void DiskDumper::CloseEntry(disk_cache::Entry* entry, base::Time last_used,
199 base::Time last_modified) { 195 base::Time last_modified) {
200 #ifdef WIN32_LARGE_FILENAME_SUPPORT 196 #ifdef WIN32_LARGE_FILENAME_SUPPORT
201 CloseHandle(entry_); 197 CloseHandle(entry_);
202 #else 198 #else
203 file_util::CloseFile(entry_); 199 file_util::CloseFile(entry_);
204 #endif 200 #endif
205 } 201 }
206 202
OLDNEW
« no previous file with comments | « net/socket/tcp_client_socket_win.cc ('k') | net/tools/dump_cache/upgrade.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698