| Index: net/url_request/url_request_simple_job.cc
|
| diff --git a/net/url_request/url_request_simple_job.cc b/net/url_request/url_request_simple_job.cc
|
| index b855932d577824997d390d3c32dd0661415f6737..55a0f8842710743a61364492bf630d20d755af5f 100644
|
| --- a/net/url_request/url_request_simple_job.cc
|
| +++ b/net/url_request/url_request_simple_job.cc
|
| @@ -8,6 +8,7 @@
|
|
|
| #include "base/bind.h"
|
| #include "base/compiler_specific.h"
|
| +#include "base/memory/ref_counted_memory.h"
|
| #include "base/message_loop/message_loop.h"
|
| #include "base/profiler/scoped_tracker.h"
|
| #include "net/base/io_buffer.h"
|
| @@ -50,12 +51,31 @@ bool URLRequestSimpleJob::ReadRawData(IOBuffer* buf, int buf_size,
|
| int remaining = byte_range_.last_byte_position() - data_offset_ + 1;
|
| if (buf_size > remaining)
|
| buf_size = remaining;
|
| - memcpy(buf->data(), data_.data() + data_offset_, buf_size);
|
| + memcpy(buf->data(), data_->front() + data_offset_, buf_size);
|
| data_offset_ += buf_size;
|
| *bytes_read = buf_size;
|
| return true;
|
| }
|
|
|
| +int URLRequestSimpleJob::GetData(std::string* mime_type,
|
| + std::string* charset,
|
| + std::string* data,
|
| + const CompletionCallback& callback) const {
|
| + NOTREACHED();
|
| + return ERR_UNEXPECTED;
|
| +}
|
| +
|
| +int URLRequestSimpleJob::GetRefCountedData(
|
| + std::string* mime_type,
|
| + std::string* charset,
|
| + scoped_refptr<base::RefCountedMemory>* data,
|
| + const CompletionCallback& callback) const {
|
| + scoped_refptr<base::RefCountedString> str_data(new base::RefCountedString());
|
| + int result = GetData(mime_type, charset, &str_data->data(), callback);
|
| + *data = str_data;
|
| + return result;
|
| +}
|
| +
|
| void URLRequestSimpleJob::StartAsync() {
|
| if (!request_)
|
| return;
|
| @@ -82,11 +102,10 @@ void URLRequestSimpleJob::StartAsync() {
|
| FROM_HERE_WITH_EXPLICIT_FUNCTION(
|
| "422489 URLRequestSimpleJob::StartAsync 2"));
|
|
|
| - result = GetData(&mime_type_,
|
| - &charset_,
|
| - &data_,
|
| - base::Bind(&URLRequestSimpleJob::OnGetDataCompleted,
|
| - weak_factory_.GetWeakPtr()));
|
| + result =
|
| + GetRefCountedData(&mime_type_, &charset_, &data_,
|
| + base::Bind(&URLRequestSimpleJob::OnGetDataCompleted,
|
| + weak_factory_.GetWeakPtr()));
|
| }
|
|
|
| if (result != ERR_IO_PENDING) {
|
| @@ -107,7 +126,7 @@ void URLRequestSimpleJob::OnGetDataCompleted(int result) {
|
|
|
| if (result == OK) {
|
| // Notify that the headers are complete
|
| - if (!byte_range_.ComputeBounds(data_.size())) {
|
| + if (!byte_range_.ComputeBounds(data_->size())) {
|
| NotifyDone(URLRequestStatus(URLRequestStatus::FAILED,
|
| ERR_REQUEST_RANGE_NOT_SATISFIABLE));
|
| return;
|
|
|