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

Unified Diff: chrome/renderer/extensions/extension_localization_peer.cc

Issue 1103813002: Make WebURLLoader capable of retaining received buffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months 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: chrome/renderer/extensions/extension_localization_peer.cc
diff --git a/chrome/renderer/extensions/extension_localization_peer.cc b/chrome/renderer/extensions/extension_localization_peer.cc
index 8c20331d8ab7007dc7ef566f5b23d43311ff0709..dac8c0d047eb1e48cebfd238a19176aff73548b2 100644
--- a/chrome/renderer/extensions/extension_localization_peer.cc
+++ b/chrome/renderer/extensions/extension_localization_peer.cc
@@ -14,6 +14,25 @@
#include "net/base/net_errors.h"
#include "net/http/http_response_headers.h"
+namespace {
+
+class StringData final : public content::RequestPeer::ReceivedData {
+ public:
+ explicit StringData(const std::string& data) : data_(data) {}
+ void Append(const char* data, int length) { data_.append(data, length); }
+
+ const char* payload() const override { return data_.c_str(); }
tyoshino (SeeGerritForStatus) 2015/05/27 03:45:34 data_.data()
tyoshino (SeeGerritForStatus) 2015/05/27 03:52:54 Oh, we still need &data_[0]? https://codereview.c
tyoshino (SeeGerritForStatus) 2015/05/27 03:53:22 Sorry. It was vector...
yhirano 2015/05/27 04:51:36 Done.
+ int length() const override { return data_.size(); }
+ int encoded_length() const override { return -1; }
+
+ private:
+ std::string data_;
+
+ DISALLOW_COPY_AND_ASSIGN(StringData);
+};
+
+} // namespace
+
ExtensionLocalizationPeer::ExtensionLocalizationPeer(
content::RequestPeer* peer,
IPC::Sender* message_sender,
@@ -57,10 +76,8 @@ void ExtensionLocalizationPeer::OnReceivedResponse(
response_info_ = info;
}
-void ExtensionLocalizationPeer::OnReceivedData(const char* data,
- int data_length,
- int encoded_data_length) {
- data_.append(data, data_length);
+void ExtensionLocalizationPeer::OnReceivedData(scoped_ptr<ReceivedData> data) {
+ data_.append(data->payload(), data->length());
}
void ExtensionLocalizationPeer::OnCompletedRequest(
@@ -88,9 +105,7 @@ void ExtensionLocalizationPeer::OnCompletedRequest(
original_peer_->OnReceivedResponse(response_info_);
if (!data_.empty())
- original_peer_->OnReceivedData(data_.data(),
- static_cast<int>(data_.size()),
- -1);
+ original_peer_->OnReceivedData(make_scoped_ptr(new StringData(data_)));
original_peer_->OnCompletedRequest(error_code, was_ignored_by_handler,
stale_copy_in_cache,
security_info, completion_time,

Powered by Google App Engine
This is Rietveld 408576698