Index: storage/browser/blob/blob_url_request_job.cc |
diff --git a/storage/browser/blob/blob_url_request_job.cc b/storage/browser/blob/blob_url_request_job.cc |
index d94fa0ba46a67f10bc1e49f6ee1caa06f6b9e530..5796b0419faa272a0718e0c79897315621d43b27 100644 |
--- a/storage/browser/blob/blob_url_request_job.cc |
+++ b/storage/browser/blob/blob_url_request_job.cc |
@@ -351,6 +351,8 @@ bool BlobURLRequestJob::ReadItem() { |
return ReadFileItem(GetFileStreamReader(current_item_index_), |
bytes_to_read); |
} |
+ if (item.type() == DataElement::TYPE_DISK_CACHE_ENTRY) |
+ return ReadDiskCacheEntryItem(item, bytes_to_read); |
NOTREACHED(); |
return false; |
} |
@@ -453,6 +455,42 @@ void BlobURLRequestJob::DeleteCurrentFileReader() { |
} |
} |
+bool BlobURLRequestJob::ReadDiskCacheEntryItem(const BlobDataItem& item, |
+ int bytes_to_read) { |
+ DCHECK_GE(read_buf_->BytesRemaining(), bytes_to_read); |
+ |
+ const int result = item.disk_cache_entry()->ReadData( |
+ item.disk_cache_stream_index(), current_item_offset_, read_buf_.get(), |
+ bytes_to_read, base::Bind(&BlobURLRequestJob::DidReadDiskCacheEntry, |
+ base::Unretained(this))); |
michaeln
2015/06/12 22:35:09
2 questions:
1) How is base::Unretained here safe
gavinp
2015/06/15 14:01:19
I think you're right. jkarlin first raised this in
|
+ DCHECK_LT(result, 0); |
+ if (result == net::ERR_IO_PENDING) |
+ SetStatus(net::URLRequestStatus(net::URLRequestStatus::IO_PENDING, 0)); |
+ else |
+ NotifyFailure(result); |
+ return false; |
+} |
+ |
+void BlobURLRequestJob::DidReadDiskCacheEntry(int result) { |
+ if (result <= 0) { |
+ NotifyFailure(net::ERR_FAILED); |
+ return; |
+ } |
+ SetStatus(net::URLRequestStatus()); |
+ |
+ AdvanceBytesRead(result); |
+ |
+ if (!read_buf_->BytesRemaining()) { |
+ int bytes_read = BytesReadCompleted(); |
+ NotifyReadComplete(bytes_read); |
+ return; |
+ } |
+ |
+ int bytes_read = 0; |
+ if (ReadLoop(&bytes_read)) |
+ NotifyReadComplete(bytes_read); |
+} |
+ |
int BlobURLRequestJob::BytesReadCompleted() { |
int bytes_read = read_buf_->BytesConsumed(); |
read_buf_ = NULL; |