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

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

Issue 266963003: Beginning of support for extension content verification (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged latest trunk Created 6 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 | 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) 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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, 287 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED,
288 ERR_REQUEST_RANGE_NOT_SATISFIABLE)); 288 ERR_REQUEST_RANGE_NOT_SATISFIABLE));
289 return; 289 return;
290 } 290 }
291 291
292 set_expected_content_size(remaining_bytes_); 292 set_expected_content_size(remaining_bytes_);
293 NotifyHeadersComplete(); 293 NotifyHeadersComplete();
294 } 294 }
295 295
296 void URLRequestFileJob::DidRead(scoped_refptr<net::IOBuffer> buf, int result) { 296 void URLRequestFileJob::DidRead(scoped_refptr<net::IOBuffer> buf, int result) {
297 if (result > 0) {
298 SetStatus(URLRequestStatus()); // Clear the IO_PENDING status
299 remaining_bytes_ -= result;
300 DCHECK_GE(remaining_bytes_, 0);
301 }
302
297 OnReadComplete(buf.get(), result); 303 OnReadComplete(buf.get(), result);
298 buf = NULL; 304 buf = NULL;
299 if (result > 0) { 305
300 SetStatus(URLRequestStatus()); // Clear the IO_PENDING status 306 if (result == 0) {
301 } else if (result == 0) {
302 NotifyDone(URLRequestStatus()); 307 NotifyDone(URLRequestStatus());
303 } else { 308 } else if (result < 0) {
304 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result)); 309 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, result));
305 } 310 }
306 311
307 remaining_bytes_ -= result;
308 DCHECK_GE(remaining_bytes_, 0);
309
310 NotifyReadComplete(result); 312 NotifyReadComplete(result);
311 } 313 }
312 314
313 } // namespace net 315 } // namespace net
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