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

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

Issue 11275088: Remove implicit scoped_refptr operator T* Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 8 years, 1 month 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
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 dest_size = static_cast<int>(remaining_bytes_); 111 dest_size = static_cast<int>(remaining_bytes_);
112 112
113 // If we should copy zero bytes because |remaining_bytes_| is zero, short 113 // If we should copy zero bytes because |remaining_bytes_| is zero, short
114 // circuit here. 114 // circuit here.
115 if (!dest_size) { 115 if (!dest_size) {
116 *bytes_read = 0; 116 *bytes_read = 0;
117 return true; 117 return true;
118 } 118 }
119 119
120 // Keep track of the buffer. 120 // Keep track of the buffer.
121 DCHECK(!read_buf_); 121 DCHECK(!read_buf_.get());
122 read_buf_ = new net::DrainableIOBuffer(dest, dest_size); 122 read_buf_ = new net::DrainableIOBuffer(dest, dest_size);
123 123
124 return ReadLoop(bytes_read); 124 return ReadLoop(bytes_read);
125 } 125 }
126 126
127 bool BlobURLRequestJob::GetMimeType(std::string* mime_type) const { 127 bool BlobURLRequestJob::GetMimeType(std::string* mime_type) const {
128 if (!response_info_.get()) 128 if (!response_info_.get())
129 return false; 129 return false;
130 130
131 return response_info_->headers->GetMimeType(mime_type); 131 return response_info_->headers->GetMimeType(mime_type);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 } 168 }
169 169
170 void BlobURLRequestJob::DidStart() { 170 void BlobURLRequestJob::DidStart() {
171 // We only support GET request per the spec. 171 // We only support GET request per the spec.
172 if (request()->method() != "GET") { 172 if (request()->method() != "GET") {
173 NotifyFailure(net::ERR_METHOD_NOT_SUPPORTED); 173 NotifyFailure(net::ERR_METHOD_NOT_SUPPORTED);
174 return; 174 return;
175 } 175 }
176 176
177 // If the blob data is not present, bail out. 177 // If the blob data is not present, bail out.
178 if (!blob_data_) { 178 if (!blob_data_.get()) {
179 NotifyFailure(net::ERR_FILE_NOT_FOUND); 179 NotifyFailure(net::ERR_FILE_NOT_FOUND);
180 return; 180 return;
181 } 181 }
182 182
183 CountSize(); 183 CountSize();
184 } 184 }
185 185
186 void BlobURLRequestJob::CountSize() { 186 void BlobURLRequestJob::CountSize() {
187 error_ = false; 187 error_ = false;
188 pending_get_file_info_count_ = 0; 188 pending_get_file_info_count_ = 0;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 358
359 AdvanceBytesRead(bytes_to_read); 359 AdvanceBytesRead(bytes_to_read);
360 return true; 360 return true;
361 } 361 }
362 362
363 bool BlobURLRequestJob::ReadFileItem(FileStreamReader* reader, 363 bool BlobURLRequestJob::ReadFileItem(FileStreamReader* reader,
364 int bytes_to_read) { 364 int bytes_to_read) {
365 DCHECK_GE(read_buf_->BytesRemaining(), bytes_to_read); 365 DCHECK_GE(read_buf_->BytesRemaining(), bytes_to_read);
366 DCHECK(reader); 366 DCHECK(reader);
367 const int result = reader->Read( 367 const int result = reader->Read(
368 read_buf_, bytes_to_read, 368 read_buf_.get(), bytes_to_read,
369 base::Bind(&BlobURLRequestJob::DidReadFile, 369 base::Bind(&BlobURLRequestJob::DidReadFile,
370 base::Unretained(this))); 370 base::Unretained(this)));
371 if (result >= 0) { 371 if (result >= 0) {
372 // Data is immediately available. 372 // Data is immediately available.
373 if (GetStatus().is_io_pending()) 373 if (GetStatus().is_io_pending())
374 DidReadFile(result); 374 DidReadFile(result);
375 else 375 else
376 AdvanceBytesRead(result); 376 AdvanceBytesRead(result);
377 return true; 377 return true;
378 } 378 }
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 int64 additional_offset) { 548 int64 additional_offset) {
549 DCHECK_LT(index, blob_data_->items().size()); 549 DCHECK_LT(index, blob_data_->items().size());
550 const BlobData::Item& item = blob_data_->items().at(index); 550 const BlobData::Item& item = blob_data_->items().at(index);
551 DCHECK(IsFileType(item.type())); 551 DCHECK(IsFileType(item.type()));
552 DCHECK_EQ(0U, index_to_reader_.count(index)); 552 DCHECK_EQ(0U, index_to_reader_.count(index));
553 553
554 FileStreamReader* reader = NULL; 554 FileStreamReader* reader = NULL;
555 switch (item.type()) { 555 switch (item.type()) {
556 case BlobData::Item::TYPE_FILE: 556 case BlobData::Item::TYPE_FILE:
557 reader = new LocalFileStreamReader( 557 reader = new LocalFileStreamReader(
558 file_thread_proxy_, 558 file_thread_proxy_.get(),
559 item.path(), 559 item.path(),
560 item.offset() + additional_offset, 560 item.offset() + additional_offset,
561 item.expected_modification_time()); 561 item.expected_modification_time());
562 break; 562 break;
563 case BlobData::Item::TYPE_FILE_FILESYSTEM: 563 case BlobData::Item::TYPE_FILE_FILESYSTEM:
564 reader = file_system_context_->CreateFileStreamReader( 564 reader = file_system_context_->CreateFileStreamReader(
565 fileapi::FileSystemURL(item.url()), 565 fileapi::FileSystemURL(item.url()),
566 item.offset() + additional_offset, 566 item.offset() + additional_offset,
567 item.expected_modification_time()); 567 item.expected_modification_time());
568 break; 568 break;
569 default: 569 default:
570 NOTREACHED(); 570 NOTREACHED();
571 } 571 }
572 DCHECK(reader); 572 DCHECK(reader);
573 index_to_reader_[index] = reader; 573 index_to_reader_[index] = reader;
574 } 574 }
575 575
576 } // namespace webkit_blob 576 } // namespace webkit_blob
OLDNEW
« no previous file with comments | « webkit/appcache/mock_appcache_storage_unittest.cc ('k') | webkit/blob/blob_url_request_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698