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

Side by Side Diff: webkit/blob/blob_url_request_job.cc

Issue 10080001: Reland 132134 with memory fix - Use LocalFileReader in FileSystemURLRequestJob (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Read return value fix Created 8 years, 8 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 | « no previous file | webkit/blob/local_file_reader.h » ('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) 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 #include "webkit/blob/blob_url_request_job.h" 5 #include "webkit/blob/blob_url_request_job.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/file_util_proxy.h" 9 #include "base/file_util_proxy.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 25 matching lines...) Expand all
36 36
37 const char kHTTPOKText[] = "OK"; 37 const char kHTTPOKText[] = "OK";
38 const char kHTTPPartialContentText[] = "Partial Content"; 38 const char kHTTPPartialContentText[] = "Partial Content";
39 const char kHTTPNotAllowedText[] = "Not Allowed"; 39 const char kHTTPNotAllowedText[] = "Not Allowed";
40 const char kHTTPNotFoundText[] = "Not Found"; 40 const char kHTTPNotFoundText[] = "Not Found";
41 const char kHTTPMethodNotAllowText[] = "Method Not Allowed"; 41 const char kHTTPMethodNotAllowText[] = "Method Not Allowed";
42 const char kHTTPRequestedRangeNotSatisfiableText[] = 42 const char kHTTPRequestedRangeNotSatisfiableText[] =
43 "Requested Range Not Satisfiable"; 43 "Requested Range Not Satisfiable";
44 const char kHTTPInternalErrorText[] = "Internal Server Error"; 44 const char kHTTPInternalErrorText[] = "Internal Server Error";
45 45
46 const int kFileOpenFlags = base::PLATFORM_FILE_OPEN |
47 base::PLATFORM_FILE_READ |
48 base::PLATFORM_FILE_ASYNC;
49
50 } // namespace 46 } // namespace
51 47
52 BlobURLRequestJob::BlobURLRequestJob( 48 BlobURLRequestJob::BlobURLRequestJob(
53 net::URLRequest* request, 49 net::URLRequest* request,
54 BlobData* blob_data, 50 BlobData* blob_data,
55 base::MessageLoopProxy* file_thread_proxy) 51 base::MessageLoopProxy* file_thread_proxy)
56 : net::URLRequestJob(request), 52 : net::URLRequestJob(request),
57 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), 53 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
58 blob_data_(blob_data), 54 blob_data_(blob_data),
59 file_thread_proxy_(file_thread_proxy), 55 file_thread_proxy_(file_thread_proxy),
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 } 350 }
355 351
356 bool BlobURLRequestJob::ReadFileItem(LocalFileReader* reader, 352 bool BlobURLRequestJob::ReadFileItem(LocalFileReader* reader,
357 int bytes_to_read) { 353 int bytes_to_read) {
358 DCHECK_GE(read_buf_->BytesRemaining(), bytes_to_read); 354 DCHECK_GE(read_buf_->BytesRemaining(), bytes_to_read);
359 DCHECK(reader); 355 DCHECK(reader);
360 const int result = reader->Read( 356 const int result = reader->Read(
361 read_buf_, bytes_to_read, 357 read_buf_, bytes_to_read,
362 base::Bind(&BlobURLRequestJob::DidReadFile, 358 base::Bind(&BlobURLRequestJob::DidReadFile,
363 base::Unretained(this))); 359 base::Unretained(this)));
364 if (result != net::ERR_IO_PENDING) { 360 if (result >= 0) {
365 DCHECK(result != net::OK); 361 // Data is immediately available.
362 if (GetStatus().is_io_pending())
363 DidReadFile(result);
364 else
365 AdvanceBytesRead(result);
366 return true;
367 }
368 if (result == net::ERR_IO_PENDING)
369 SetStatus(net::URLRequestStatus(net::URLRequestStatus::IO_PENDING, 0));
370 else
366 NotifyFailure(result); 371 NotifyFailure(result);
367 return false;
368 }
369 SetStatus(net::URLRequestStatus(net::URLRequestStatus::IO_PENDING, 0));
370 return false; 372 return false;
371 } 373 }
372 374
373 void BlobURLRequestJob::DidReadFile(int result) { 375 void BlobURLRequestJob::DidReadFile(int result) {
374 if (result <= 0) { 376 if (result <= 0) {
375 NotifyFailure(net::ERR_FAILED); 377 NotifyFailure(net::ERR_FAILED);
376 return; 378 return;
377 } 379 }
378 SetStatus(net::URLRequestStatus()); // Clear the IO_PENDING status 380 SetStatus(net::URLRequestStatus()); // Clear the IO_PENDING status
379 381
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 file_thread_proxy_, 530 file_thread_proxy_,
529 item.file_path, 531 item.file_path,
530 item.offset, 532 item.offset,
531 item.expected_modification_time); 533 item.expected_modification_time);
532 } 534 }
533 DCHECK(index_to_reader_[index]); 535 DCHECK(index_to_reader_[index]);
534 return index_to_reader_[index]; 536 return index_to_reader_[index];
535 } 537 }
536 538
537 } // namespace webkit_blob 539 } // namespace webkit_blob
OLDNEW
« no previous file with comments | « no previous file | webkit/blob/local_file_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698