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

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

Issue 9349005: net: Rename FileStream::Open/Close with OpenSync/CloseSync. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win build Created 8 years, 10 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 | Annotate | Revision Log
OLDNEW
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 // 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 base::WorkerPool::PostTask( 154 base::WorkerPool::PostTask(
155 FROM_HERE, 155 FROM_HERE,
156 base::Bind(&AsyncResolver::Resolve, async_resolver_.get(), file_path_), 156 base::Bind(&AsyncResolver::Resolve, async_resolver_.get(), file_path_),
157 true); 157 true);
158 } 158 }
159 159
160 void URLRequestFileJob::Kill() { 160 void URLRequestFileJob::Kill() {
161 // URL requests should not block on the disk! 161 // URL requests should not block on the disk!
162 // http://code.google.com/p/chromium/issues/detail?id=59849 162 // http://code.google.com/p/chromium/issues/detail?id=59849
163 base::ThreadRestrictions::ScopedAllowIO allow_io; 163 base::ThreadRestrictions::ScopedAllowIO allow_io;
164 stream_.Close(); 164 stream_.CloseSync();
165 165
166 if (async_resolver_) { 166 if (async_resolver_) {
167 async_resolver_->Cancel(); 167 async_resolver_->Cancel();
168 async_resolver_ = NULL; 168 async_resolver_ = NULL;
169 } 169 }
170 170
171 URLRequestJob::Kill(); 171 URLRequestJob::Kill();
172 } 172 }
173 173
174 bool URLRequestFileJob::ReadRawData(IOBuffer* dest, int dest_size, 174 bool URLRequestFileJob::ReadRawData(IOBuffer* dest, int dest_size,
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 // FileDirJob where it is resolved as invalid. 305 // FileDirJob where it is resolved as invalid.
306 if (!exists) { 306 if (!exists) {
307 rv = ERR_FILE_NOT_FOUND; 307 rv = ERR_FILE_NOT_FOUND;
308 } else if (!is_directory_) { 308 } else if (!is_directory_) {
309 // URL requests should not block on the disk! 309 // URL requests should not block on the disk!
310 // http://code.google.com/p/chromium/issues/detail?id=59849 310 // http://code.google.com/p/chromium/issues/detail?id=59849
311 base::ThreadRestrictions::ScopedAllowIO allow_io; 311 base::ThreadRestrictions::ScopedAllowIO allow_io;
312 312
313 int flags = base::PLATFORM_FILE_OPEN | 313 int flags = base::PLATFORM_FILE_OPEN |
314 base::PLATFORM_FILE_READ | 314 base::PLATFORM_FILE_READ |
315 base::PLATFORM_FILE_ASYNC; 315 base::PLATFORM_FILE_ASYNC;
satorux1 2012/02/07 18:06:27 async.
316 rv = stream_.Open(file_path_, flags); 316 rv = stream_.OpenSync(file_path_, flags);
317 } 317 }
318 318
319 if (rv != OK) { 319 if (rv != OK) {
320 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); 320 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv));
321 return; 321 return;
322 } 322 }
323 323
324 if (!byte_range_.ComputeBounds(file_info.size)) { 324 if (!byte_range_.ComputeBounds(file_info.size)) {
325 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, 325 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED,
326 ERR_REQUEST_RANGE_NOT_SATISFIABLE)); 326 ERR_REQUEST_RANGE_NOT_SATISFIABLE));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result)); 359 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result));
360 } 360 }
361 361
362 remaining_bytes_ -= result; 362 remaining_bytes_ -= result;
363 DCHECK_GE(remaining_bytes_, 0); 363 DCHECK_GE(remaining_bytes_, 0);
364 364
365 NotifyReadComplete(result); 365 NotifyReadComplete(result);
366 } 366 }
367 367
368 } // namespace net 368 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698