Chromium Code Reviews| Index: content/browser/webui/url_data_manager_backend.cc |
| diff --git a/content/browser/webui/url_data_manager_backend.cc b/content/browser/webui/url_data_manager_backend.cc |
| index ac346dda7ca827cb786eabfff9963a3d313a1310..8b82bb7a9e35672489e93d52081bfe0eb01b8b02 100644 |
| --- a/content/browser/webui/url_data_manager_backend.cc |
| +++ b/content/browser/webui/url_data_manager_backend.cc |
| @@ -119,7 +119,7 @@ class URLRequestChromeJob : public net::URLRequestJob { |
| // net::URLRequestJob implementation. |
| void Start() override; |
| void Kill() override; |
| - bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read) override; |
| + int ReadRawData(net::IOBuffer* buf, int buf_size) override; |
| bool GetMimeType(std::string* mime_type) const override; |
| int GetResponseCode() const override; |
| void GetResponseInfo(net::HttpResponseInfo* info) override; |
| @@ -191,7 +191,9 @@ class URLRequestChromeJob : public net::URLRequestJob { |
| // Do the actual copy from data_ (the data we're serving) into |buf|. |
| // Separate from ReadRawData so we can handle async I/O. |
| - void CompleteRead(net::IOBuffer* buf, int buf_size, int* bytes_read); |
| + // return value is either >= 0 to indicate a successful read and count of |
| + // bytes read, or < 0 to indicate an error. |
|
davidben
2015/11/03 22:50:05
It doesn't look like this function can actually re
xunjieli
2015/11/04 01:26:51
Done.
|
| + int CompleteRead(net::IOBuffer* buf, int buf_size); |
| // The actual data we're serving. NULL until it's been fetched. |
| scoped_refptr<base::RefCountedMemory> data_; |
| @@ -336,22 +338,16 @@ void URLRequestChromeJob::MimeTypeAvailable(const std::string& mime_type) { |
| void URLRequestChromeJob::DataAvailable(base::RefCountedMemory* bytes) { |
| TRACE_EVENT_ASYNC_END0("browser", "DataManager:Request", this); |
| if (bytes) { |
| - // The request completed, and we have all the data. |
| - // Clear any IO pending status. |
| - SetStatus(net::URLRequestStatus()); |
| - |
| data_ = bytes; |
| - int bytes_read; |
| if (pending_buf_.get()) { |
| CHECK(pending_buf_->data()); |
| - CompleteRead(pending_buf_.get(), pending_buf_size_, &bytes_read); |
| + int result = CompleteRead(pending_buf_.get(), pending_buf_size_); |
| pending_buf_ = NULL; |
| - NotifyReadComplete(bytes_read); |
| + ReadRawDataComplete(result); |
| } |
| } else { |
| // The request failed. |
| - NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED, |
| - net::ERR_FAILED)); |
| + ReadRawDataComplete(net::ERR_FAILED); |
| } |
| } |
| @@ -359,25 +355,21 @@ base::WeakPtr<URLRequestChromeJob> URLRequestChromeJob::AsWeakPtr() { |
| return weak_factory_.GetWeakPtr(); |
| } |
| -bool URLRequestChromeJob::ReadRawData(net::IOBuffer* buf, int buf_size, |
| - int* bytes_read) { |
| +int URLRequestChromeJob::ReadRawData(net::IOBuffer* buf, int buf_size) { |
| if (!data_.get()) { |
| - SetStatus(net::URLRequestStatus(net::URLRequestStatus::IO_PENDING, 0)); |
| DCHECK(!pending_buf_.get()); |
| CHECK(buf->data()); |
| pending_buf_ = buf; |
| pending_buf_size_ = buf_size; |
| - return false; // Tell the caller we're still waiting for data. |
| + return net::ERR_IO_PENDING; |
| } |
| // Otherwise, the data is available. |
| - CompleteRead(buf, buf_size, bytes_read); |
| - return true; |
| + return CompleteRead(buf, buf_size); |
| } |
| -void URLRequestChromeJob::CompleteRead(net::IOBuffer* buf, int buf_size, |
| - int* bytes_read) { |
| - int remaining = static_cast<int>(data_->size()) - data_offset_; |
| +int URLRequestChromeJob::CompleteRead(net::IOBuffer* buf, int buf_size) { |
| + int remaining = data_->size() - data_offset_; |
| if (buf_size > remaining) |
| buf_size = remaining; |
| if (buf_size > 0) { |
| @@ -389,7 +381,7 @@ void URLRequestChromeJob::CompleteRead(net::IOBuffer* buf, int buf_size, |
| memcpy(buf->data(), data_->front() + data_offset_, buf_size); |
| data_offset_ += buf_size; |
| } |
| - *bytes_read = buf_size; |
| + return buf_size; |
| } |
| void URLRequestChromeJob::CheckStoragePartitionMatches( |