summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
Diffstat (limited to 'content')
-rw-r--r--content/browser/net/view_http_cache_job_factory.cc23
1 files changed, 16 insertions, 7 deletions
diff --git a/content/browser/net/view_http_cache_job_factory.cc b/content/browser/net/view_http_cache_job_factory.cc
index 41e7b377..823ced9 100644
--- a/content/browser/net/view_http_cache_job_factory.cc
+++ b/content/browser/net/view_http_cache_job_factory.cc
@@ -10,6 +10,7 @@
#include "base/compiler_specific.h"
#include "base/location.h"
#include "base/memory/weak_ptr.h"
+#include "base/numerics/safe_conversions.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_util.h"
#include "base/thread_task_runner_handle.h"
@@ -44,8 +45,15 @@ 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);
+ 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:
@@ -65,7 +73,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);
+ bool ReadRawData(net::IOBuffer* buf, size_t buf_size, size_t* bytes_read);
private:
friend class base::RefCounted<Core>;
@@ -76,7 +84,7 @@ class ViewHttpCacheJob : public net::URLRequestJob {
void OnIOComplete(int result);
std::string data_;
- int data_offset_;
+ size_t data_offset_;
net::ViewCacheHelper cache_helper_;
net::CompletionCallback callback_;
base::Closure user_callback_;
@@ -165,10 +173,11 @@ bool ViewHttpCacheJob::Core::GetCharset(std::string* charset) {
}
bool ViewHttpCacheJob::Core::ReadRawData(net::IOBuffer* buf,
- int buf_size,
- int* bytes_read) {
+ size_t buf_size,
+ size_t* bytes_read) {
DCHECK(bytes_read);
- int remaining = static_cast<int>(data_.size()) - data_offset_;
+ DCHECK_LE(data_offset_, data_.size());
+ size_t remaining = data_.size() - data_offset_;
if (buf_size > remaining)
buf_size = remaining;
memcpy(buf->data(), data_.data() + data_offset_, buf_size);