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

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

Issue 8843: Add write and read/write support to FileStream (renamed from FileInputStream)... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 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/url_request/url_request_file_job.h ('k') | no next file » | 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-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 // We may have been orphaned... 170 // We may have been orphaned...
171 if (!request_) 171 if (!request_)
172 return; 172 return;
173 173
174 is_directory_ = file_info.is_directory; 174 is_directory_ = file_info.is_directory;
175 175
176 int rv = net::OK; 176 int rv = net::OK;
177 if (!exists) { 177 if (!exists) {
178 rv = net::ERR_FILE_NOT_FOUND; 178 rv = net::ERR_FILE_NOT_FOUND;
179 } else if (!is_directory_) { 179 } else if (!is_directory_) {
180 rv = stream_.Open(file_path_, true); 180 int flags = base::PLATFORM_FILE_OPEN |
181 base::PLATFORM_FILE_READ |
182 base::PLATFORM_FILE_ASYNC;
183 rv = stream_.Open(file_path_, flags);
181 } 184 }
182 185
183 if (rv == net::OK) { 186 if (rv == net::OK) {
184 set_expected_content_size(file_info.size); 187 set_expected_content_size(file_info.size);
185 NotifyHeadersComplete(); 188 NotifyHeadersComplete();
186 } else { 189 } else {
187 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); 190 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv));
188 } 191 }
189 } 192 }
190 193
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 return false; 236 return false;
234 237
235 *location = net::FilePathToFileURL(new_path); 238 *location = net::FilePathToFileURL(new_path);
236 *http_status_code = 301; 239 *http_status_code = 301;
237 return true; 240 return true;
238 #else 241 #else
239 return false; 242 return false;
240 #endif 243 #endif
241 } 244 }
242 245
OLDNEW
« no previous file with comments | « net/url_request/url_request_file_job.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698