Chromium Code Reviews| Index: content/browser/net/view_http_cache_job_factory.cc |
| diff --git a/content/browser/net/view_http_cache_job_factory.cc b/content/browser/net/view_http_cache_job_factory.cc |
| index 6b46b618ea26f20eac1b96411d4c31517080f408..34efe3b1c9fa1c2e1388582870f12dc2d28df3ad 100644 |
| --- a/content/browser/net/view_http_cache_job_factory.cc |
| +++ b/content/browser/net/view_http_cache_job_factory.cc |
| @@ -44,8 +44,8 @@ class ViewHttpCacheJob : public net::URLRequestJob { |
| bool GetCharset(std::string* charset) override { |
| return core_->GetCharset(charset); |
| } |
| - bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read) override { |
| - return core_->ReadRawData(buf, buf_size, bytes_read); |
| + int ReadRawData(net::IOBuffer* buf, int buf_size) override { |
| + return core_->ReadRawData(buf, buf_size); |
| } |
| private: |
| @@ -65,7 +65,7 @@ class ViewHttpCacheJob : public net::URLRequestJob { |
| bool GetMimeType(std::string* mime_type) const; |
| bool GetCharset(std::string* charset); |
| - bool ReadRawData(net::IOBuffer* buf, int buf_size, int *bytes_read); |
| + int ReadRawData(net::IOBuffer* buf, int buf_size); |
| private: |
| friend class base::RefCounted<Core>; |
| @@ -164,17 +164,13 @@ bool ViewHttpCacheJob::Core::GetCharset(std::string* charset) { |
| return true; |
| } |
| -bool ViewHttpCacheJob::Core::ReadRawData(net::IOBuffer* buf, |
| - int buf_size, |
| - int* bytes_read) { |
| - DCHECK(bytes_read); |
| - int remaining = static_cast<int>(data_.size()) - data_offset_; |
| +int ViewHttpCacheJob::Core::ReadRawData(net::IOBuffer* buf, int buf_size) { |
| + int remaining = base::checked_cast<int>(data_.size()) - data_offset_; |
|
davidben
2015/11/03 22:50:05
#include "base/numerics/safe_conversions.h
xunjieli
2015/11/04 01:26:51
Done.
|
| if (buf_size > remaining) |
| buf_size = remaining; |
| memcpy(buf->data(), data_.data() + data_offset_, buf_size); |
| data_offset_ += buf_size; |
| - *bytes_read = buf_size; |
| - return true; |
| + return buf_size; |
| } |
| void ViewHttpCacheJob::Core::OnIOComplete(int result) { |