Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Unified Diff: content/browser/net/view_http_cache_job_factory.cc

Issue 1410643007: URLRequestJob: change ReadRawData contract (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address michaeln's comment Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..3f9570eed35df9b8dc19c2e9668da5914e8bb7ec 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,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 +66,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 +165,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_;
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) {

Powered by Google App Engine
This is Rietveld 408576698