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

Side by Side Diff: chrome/renderer/extensions/extension_localization_peer.cc

Issue 2540023003: Dispatch encoded_data_length separately in content/child (Closed)
Patch Set: fix Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/extensions/extension_localization_peer.h" 5 #include "chrome/renderer/extensions/extension_localization_peer.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "chrome/common/url_constants.h" 13 #include "chrome/common/url_constants.h"
14 #include "extensions/common/constants.h" 14 #include "extensions/common/constants.h"
15 #include "extensions/common/extension_messages.h" 15 #include "extensions/common/extension_messages.h"
16 #include "extensions/common/message_bundle.h" 16 #include "extensions/common/message_bundle.h"
17 #include "ipc/ipc_sender.h" 17 #include "ipc/ipc_sender.h"
18 #include "net/base/net_errors.h" 18 #include "net/base/net_errors.h"
19 #include "net/http/http_response_headers.h" 19 #include "net/http/http_response_headers.h"
20 20
21 namespace { 21 namespace {
22 22
23 class StringData final : public content::RequestPeer::ReceivedData { 23 class StringData final : public content::RequestPeer::ReceivedData {
24 public: 24 public:
25 explicit StringData(const std::string& data) : data_(data) {} 25 explicit StringData(const std::string& data) : data_(data) {}
26 26
27 const char* payload() const override { return data_.data(); } 27 const char* payload() const override { return data_.data(); }
28 int length() const override { return data_.size(); } 28 int length() const override { return data_.size(); }
29 int encoded_data_length() const override { return -1; }
30 29
31 private: 30 private:
32 const std::string data_; 31 const std::string data_;
33 32
34 DISALLOW_COPY_AND_ASSIGN(StringData); 33 DISALLOW_COPY_AND_ASSIGN(StringData);
35 }; 34 };
36 35
37 } // namespace 36 } // namespace
38 37
39 ExtensionLocalizationPeer::ExtensionLocalizationPeer( 38 ExtensionLocalizationPeer::ExtensionLocalizationPeer(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 void ExtensionLocalizationPeer::OnReceivedResponse( 78 void ExtensionLocalizationPeer::OnReceivedResponse(
80 const content::ResourceResponseInfo& info) { 79 const content::ResourceResponseInfo& info) {
81 response_info_ = info; 80 response_info_ = info;
82 } 81 }
83 82
84 void ExtensionLocalizationPeer::OnReceivedData( 83 void ExtensionLocalizationPeer::OnReceivedData(
85 std::unique_ptr<ReceivedData> data) { 84 std::unique_ptr<ReceivedData> data) {
86 data_.append(data->payload(), data->length()); 85 data_.append(data->payload(), data->length());
87 } 86 }
88 87
88 void ExtensionLocalizationPeer::OnTransferSizeUpdated(int transfer_size_diff) {
89 original_peer_->OnTransferSizeUpdated(transfer_size_diff);
90 }
91
89 void ExtensionLocalizationPeer::OnCompletedRequest( 92 void ExtensionLocalizationPeer::OnCompletedRequest(
90 int error_code, 93 int error_code,
91 bool was_ignored_by_handler, 94 bool was_ignored_by_handler,
92 bool stale_copy_in_cache, 95 bool stale_copy_in_cache,
93 const base::TimeTicks& completion_time, 96 const base::TimeTicks& completion_time,
94 int64_t total_transfer_size, 97 int64_t total_transfer_size,
95 int64_t encoded_body_size) { 98 int64_t encoded_body_size) {
96 // Give sub-classes a chance at altering the data. 99 // Give sub-classes a chance at altering the data.
97 if (error_code != net::OK) { 100 if (error_code != net::OK) {
98 // We failed to load the resource. 101 // We failed to load the resource.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 139
137 l10n_messages = extensions::GetL10nMessagesMap(extension_id); 140 l10n_messages = extensions::GetL10nMessagesMap(extension_id);
138 } 141 }
139 142
140 std::string error; 143 std::string error;
141 if (extensions::MessageBundle::ReplaceMessagesWithExternalDictionary( 144 if (extensions::MessageBundle::ReplaceMessagesWithExternalDictionary(
142 *l10n_messages, &data_, &error)) { 145 *l10n_messages, &data_, &error)) {
143 data_.resize(data_.size()); 146 data_.resize(data_.size());
144 } 147 }
145 } 148 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698