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 22b408ea8fbacf970dbbaf26ceb45b1158e5f9c7..823ced9cc1066d1639571d9ec4d39caf40367723 100644 |
--- a/content/browser/net/view_http_cache_job_factory.cc |
+++ b/content/browser/net/view_http_cache_job_factory.cc |
@@ -45,8 +45,15 @@ class ViewHttpCacheJob : public net::URLRequestJob { |
bool GetCharset(std::string* charset) override { |
return core_->GetCharset(charset); |
} |
- int ReadRawData(net::IOBuffer* buf, int buf_size) override { |
- return core_->ReadRawData(buf, buf_size); |
+ bool ReadRawData(net::IOBuffer* buf, |
+ int buf_size, |
+ int* out_bytes_read) override { |
+ size_t bytes_read; |
+ if (!core_->ReadRawData(buf, base::checked_cast<size_t>(buf_size), |
+ &bytes_read)) |
+ return false; |
+ *out_bytes_read = base::checked_cast<int>(bytes_read); |
+ return true; |
} |
private: |
@@ -66,7 +73,7 @@ class ViewHttpCacheJob : public net::URLRequestJob { |
bool GetMimeType(std::string* mime_type) const; |
bool GetCharset(std::string* charset); |
- int ReadRawData(net::IOBuffer* buf, int buf_size); |
+ bool ReadRawData(net::IOBuffer* buf, size_t buf_size, size_t* bytes_read); |
private: |
friend class base::RefCounted<Core>; |
@@ -165,14 +172,18 @@ bool ViewHttpCacheJob::Core::GetCharset(std::string* charset) { |
return true; |
} |
-int ViewHttpCacheJob::Core::ReadRawData(net::IOBuffer* buf, int buf_size) { |
+bool ViewHttpCacheJob::Core::ReadRawData(net::IOBuffer* buf, |
+ size_t buf_size, |
+ size_t* bytes_read) { |
+ DCHECK(bytes_read); |
DCHECK_LE(data_offset_, data_.size()); |
- int remaining = base::checked_cast<int>(data_.size() - data_offset_); |
+ size_t remaining = data_.size() - data_offset_; |
if (buf_size > remaining) |
buf_size = remaining; |
memcpy(buf->data(), data_.data() + data_offset_, buf_size); |
data_offset_ += buf_size; |
- return buf_size; |
+ *bytes_read = buf_size; |
+ return true; |
} |
void ViewHttpCacheJob::Core::OnIOComplete(int result) { |