diff options
author | hashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-10 12:37:38 +0000 |
---|---|---|
committer | hashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-10 12:37:38 +0000 |
commit | 535b73c90de52b413e5a9340e4e9864c6f5ba758 (patch) | |
tree | c54d579f3ccb838865d5db97f42fa3c75268dfbf /webkit/blob | |
parent | c95dfa314db117dee4ff481ca9c056126d96bcb4 (diff) | |
download | chromium_src-535b73c90de52b413e5a9340e4e9864c6f5ba758.zip chromium_src-535b73c90de52b413e5a9340e4e9864c6f5ba758.tar.gz chromium_src-535b73c90de52b413e5a9340e4e9864c6f5ba758.tar.bz2 |
webkit_blob: Remove duplicated FileStreamReader creation code from BlobURLReqeustJob
BUG=141835
TEST=content_unittests --gtest_filter="BlobURLRequestJobTest.*"
Review URL: https://chromiumcodereview.appspot.com/11017053
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161100 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/blob')
-rw-r--r-- | webkit/blob/blob_url_request_job.cc | 32 | ||||
-rw-r--r-- | webkit/blob/blob_url_request_job.h | 3 |
2 files changed, 21 insertions, 14 deletions
diff --git a/webkit/blob/blob_url_request_job.cc b/webkit/blob/blob_url_request_job.cc index 1ef9545..07a4fc4 100644 --- a/webkit/blob/blob_url_request_job.cc +++ b/webkit/blob/blob_url_request_job.cc @@ -271,11 +271,7 @@ void BlobURLRequestJob::Seek(int64 offset) { const BlobData::Item& item = blob_data_->items().at(current_item_index_); if (item.type() == BlobData::Item::TYPE_FILE) { DeleteCurrentFileReader(); - index_to_reader_[current_item_index_] = new LocalFileStreamReader( - file_thread_proxy_, - item.path(), - item.offset() + offset, - item.expected_modification_time()); + CreateFileStreamReader(current_item_index_, offset); } } @@ -533,17 +529,25 @@ LocalFileStreamReader* BlobURLRequestJob::GetFileStreamReader(size_t index) { const BlobData::Item& item = blob_data_->items().at(index); if (item.type() != BlobData::Item::TYPE_FILE) return NULL; - // TODO(kinuko): Create appropriate FileStreamReader for TYPE_FILE_FILESYSTEM. - // http://crbug.com/141835 - if (index_to_reader_.find(index) == index_to_reader_.end()) { - index_to_reader_[index] = new LocalFileStreamReader( - file_thread_proxy_, - item.path(), - item.offset(), - item.expected_modification_time()); - } + if (index_to_reader_.find(index) == index_to_reader_.end()) + CreateFileStreamReader(index, 0); DCHECK(index_to_reader_[index]); return index_to_reader_[index]; } +void BlobURLRequestJob::CreateFileStreamReader(size_t index, + int64 additional_offset) { + DCHECK_LT(index, blob_data_->items().size()); + const BlobData::Item& item = blob_data_->items().at(index); + DCHECK_EQ(BlobData::Item::TYPE_FILE, item.type()); + DCHECK_EQ(0U, index_to_reader_.count(index)); + // TODO(kinuko): Create appropriate FileStreamReader for TYPE_FILE_FILESYSTEM. + // http://crbug.com/141835 + index_to_reader_[index] = new LocalFileStreamReader( + file_thread_proxy_, + item.path(), + item.offset() + additional_offset, + item.expected_modification_time()); +} + } // namespace webkit_blob diff --git a/webkit/blob/blob_url_request_job.h b/webkit/blob/blob_url_request_job.h index d7080bc..5d95871 100644 --- a/webkit/blob/blob_url_request_job.h +++ b/webkit/blob/blob_url_request_job.h @@ -82,6 +82,9 @@ class BLOB_EXPORT BlobURLRequestJob : public net::URLRequestJob { // If the item at |index| is not of TYPE_FILE this returns NULL. LocalFileStreamReader* GetFileStreamReader(size_t index); + // Creates a FileStreamReader for the item at |index| with additional_offset. + void CreateFileStreamReader(size_t index, int64 additional_offset); + base::WeakPtrFactory<BlobURLRequestJob> weak_factory_; scoped_refptr<BlobData> blob_data_; scoped_refptr<base::MessageLoopProxy> file_thread_proxy_; |