| Index: chrome/renderer/security_filter_peer.cc
|
| diff --git a/chrome/renderer/security_filter_peer.cc b/chrome/renderer/security_filter_peer.cc
|
| index e43e7ec7edc687cc82ca6d68c26329c562802faa..0ae98ca8ef6c91177d8fa719079a028f4726081c 100644
|
| --- a/chrome/renderer/security_filter_peer.cc
|
| +++ b/chrome/renderer/security_filter_peer.cc
|
| @@ -4,6 +4,8 @@
|
|
|
| #include "chrome/renderer/security_filter_peer.h"
|
|
|
| +#include <string>
|
| +
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/strings/stringprintf.h"
|
| #include "chrome/grit/generated_resources.h"
|
| @@ -11,6 +13,24 @@
|
| #include "net/http/http_response_headers.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
|
|
| +namespace {
|
| +
|
| +class StringData final : public content::RequestPeer::ReceivedData {
|
| + public:
|
| + explicit StringData(const std::string& data) : data_(data) {}
|
| +
|
| + const char* payload() const override { return data_.data(); }
|
| + int length() const override { return data_.size(); }
|
| + int encoded_length() const override { return -1; }
|
| +
|
| + private:
|
| + std::string data_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(StringData);
|
| +};
|
| +
|
| +} // namespace
|
| +
|
| SecurityFilterPeer::SecurityFilterPeer(content::RequestPeer* peer)
|
| : original_peer_(peer) {
|
| }
|
| @@ -80,9 +100,7 @@ void SecurityFilterPeer::OnReceivedResponse(
|
| NOTREACHED();
|
| }
|
|
|
| -void SecurityFilterPeer::OnReceivedData(const char* data,
|
| - int data_length,
|
| - int encoded_data_length) {
|
| +void SecurityFilterPeer::OnReceivedData(scoped_ptr<ReceivedData> data) {
|
| NOTREACHED();
|
| }
|
|
|
| @@ -139,10 +157,8 @@ void BufferedPeer::OnReceivedResponse(
|
| ProcessResponseInfo(info, &response_info_, mime_type_);
|
| }
|
|
|
| -void BufferedPeer::OnReceivedData(const char* data,
|
| - int data_length,
|
| - int encoded_data_length) {
|
| - data_.append(data, data_length);
|
| +void BufferedPeer::OnReceivedData(scoped_ptr<ReceivedData> data) {
|
| + data_.append(data->payload(), data->length());
|
| }
|
|
|
| void BufferedPeer::OnCompletedRequest(int error_code,
|
| @@ -167,9 +183,7 @@ void BufferedPeer::OnCompletedRequest(int error_code,
|
|
|
| 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, total_transfer_size);
|
| @@ -193,9 +207,7 @@ void ReplaceContentPeer::OnReceivedResponse(
|
| // Ignore this, we'll serve some alternate content in OnCompletedRequest.
|
| }
|
|
|
| -void ReplaceContentPeer::OnReceivedData(const char* data,
|
| - int data_length,
|
| - int encoded_data_length) {
|
| +void ReplaceContentPeer::OnReceivedData(scoped_ptr<ReceivedData> data) {
|
| // Ignore this, we'll serve some alternate content in OnCompletedRequest.
|
| }
|
|
|
| @@ -212,9 +224,7 @@ void ReplaceContentPeer::OnCompletedRequest(
|
| info.content_length = static_cast<int>(data_.size());
|
| original_peer_->OnReceivedResponse(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(net::OK,
|
| false,
|
| stale_copy_in_cache,
|
|
|