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

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

Issue 1459333002: Revert "Reland: URLRequestJob: change ReadRawData contract" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 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) {

Powered by Google App Engine
This is Rietveld 408576698