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

Side by Side Diff: net/url_request/url_request_file_job.cc

Issue 4222005: Turn on file access checks on Win. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Second try Created 10 years, 1 month 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/proxy/proxy_config_service_win.cc ('k') | webkit/glue/plugins/pepper_url_request_info.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) 2006-2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2010 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 // For loading files, we make use of overlapped i/o to ensure that reading from 5 // For loading files, we make use of overlapped i/o to ensure that reading from
6 // the filesystem (e.g., a network filesystem) does not block the calling 6 // the filesystem (e.g., a network filesystem) does not block the calling
7 // thread. An alternative approach would be to use a background thread or pool 7 // thread. An alternative approach would be to use a background thread or pool
8 // of threads, but it seems better to leverage the operating system's ability 8 // of threads, but it seems better to leverage the operating system's ability
9 // to do background file reads for us. 9 // to do background file reads for us.
10 // 10 //
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 DCHECK(encoding_types->empty()); 196 DCHECK(encoding_types->empty());
197 197
198 // Bug 9936 - .svgz files needs to be decompressed. 198 // Bug 9936 - .svgz files needs to be decompressed.
199 if (LowerCaseEqualsASCII(file_path_.Extension(), ".svgz")) 199 if (LowerCaseEqualsASCII(file_path_.Extension(), ".svgz"))
200 encoding_types->push_back(Filter::FILTER_TYPE_GZIP); 200 encoding_types->push_back(Filter::FILTER_TYPE_GZIP);
201 201
202 return !encoding_types->empty(); 202 return !encoding_types->empty();
203 } 203 }
204 204
205 bool URLRequestFileJob::GetMimeType(std::string* mime_type) const { 205 bool URLRequestFileJob::GetMimeType(std::string* mime_type) const {
206 // URL requests should not block on the disk! On Windows this goes to the
207 // registry.
208 // http://code.google.com/p/chromium/issues/detail?id=59849
209 base::ThreadRestrictions::ScopedAllowIO allow_io;
206 DCHECK(request_); 210 DCHECK(request_);
207 return net::GetMimeTypeFromFile(file_path_, mime_type); 211 return net::GetMimeTypeFromFile(file_path_, mime_type);
208 } 212 }
209 213
210 void URLRequestFileJob::SetExtraRequestHeaders( 214 void URLRequestFileJob::SetExtraRequestHeaders(
211 const net::HttpRequestHeaders& headers) { 215 const net::HttpRequestHeaders& headers) {
212 std::string range_header; 216 std::string range_header;
213 if (headers.GetHeader(net::HttpRequestHeaders::kRange, &range_header)) { 217 if (headers.GetHeader(net::HttpRequestHeaders::kRange, &range_header)) {
214 // We only care about "Range" header here. 218 // We only care about "Range" header here.
215 std::vector<net::HttpByteRange> ranges; 219 std::vector<net::HttpByteRange> ranges;
(...skipping 29 matching lines...) Expand all
245 // trailing slash. 249 // trailing slash.
246 // If a directory does not exist, we return ERR_FILE_NOT_FOUND. Otherwise, 250 // If a directory does not exist, we return ERR_FILE_NOT_FOUND. Otherwise,
247 // we will append trailing slash and redirect to FileDirJob. 251 // we will append trailing slash and redirect to FileDirJob.
248 // A special case is "\" on Windows. We should resolve as invalid. 252 // A special case is "\" on Windows. We should resolve as invalid.
249 // However, Windows resolves "\" to "C:\", thus reports it as existent. 253 // However, Windows resolves "\" to "C:\", thus reports it as existent.
250 // So what happens is we append it with trailing slash and redirect it to 254 // So what happens is we append it with trailing slash and redirect it to
251 // FileDirJob where it is resolved as invalid. 255 // FileDirJob where it is resolved as invalid.
252 if (!exists) { 256 if (!exists) {
253 rv = net::ERR_FILE_NOT_FOUND; 257 rv = net::ERR_FILE_NOT_FOUND;
254 } else if (!is_directory_) { 258 } else if (!is_directory_) {
259 // URL requests should not block on the disk!
260 // http://code.google.com/p/chromium/issues/detail?id=59849
261 base::ThreadRestrictions::ScopedAllowIO allow_io;
262
255 int flags = base::PLATFORM_FILE_OPEN | 263 int flags = base::PLATFORM_FILE_OPEN |
256 base::PLATFORM_FILE_READ | 264 base::PLATFORM_FILE_READ |
257 base::PLATFORM_FILE_ASYNC; 265 base::PLATFORM_FILE_ASYNC;
258 rv = stream_.Open(file_path_, flags); 266 rv = stream_.Open(file_path_, flags);
259 } 267 }
260 268
261 if (rv != net::OK) { 269 if (rv != net::OK) {
262 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); 270 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv));
263 return; 271 return;
264 } 272 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 if (!resolved) 339 if (!resolved)
332 return false; 340 return false;
333 341
334 *location = net::FilePathToFileURL(new_path); 342 *location = net::FilePathToFileURL(new_path);
335 *http_status_code = 301; 343 *http_status_code = 301;
336 return true; 344 return true;
337 #else 345 #else
338 return false; 346 return false;
339 #endif 347 #endif
340 } 348 }
OLDNEW
« no previous file with comments | « net/proxy/proxy_config_service_win.cc ('k') | webkit/glue/plugins/pepper_url_request_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698