| 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..ee4407a781d4d0ae9846d7ae03464734fe5b0aae 100644
|
| --- a/chrome/renderer/security_filter_peer.cc
|
| +++ b/chrome/renderer/security_filter_peer.cc
|
| @@ -11,6 +11,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_.c_str(); }
|
| + 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 +98,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 +155,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 +181,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 +205,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 +222,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,
|
|
|