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

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

Issue 2835123005: Send the decoded size when response completed and stop summing in ResourceLoader::DidReceiveData() (Closed)
Patch Set: Created 3 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 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"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 void ExtensionLocalizationPeer::OnTransferSizeUpdated(int transfer_size_diff) { 88 void ExtensionLocalizationPeer::OnTransferSizeUpdated(int transfer_size_diff) {
89 original_peer_->OnTransferSizeUpdated(transfer_size_diff); 89 original_peer_->OnTransferSizeUpdated(transfer_size_diff);
90 } 90 }
91 91
92 void ExtensionLocalizationPeer::OnCompletedRequest( 92 void ExtensionLocalizationPeer::OnCompletedRequest(
93 int error_code, 93 int error_code,
94 bool was_ignored_by_handler, 94 bool was_ignored_by_handler,
95 bool stale_copy_in_cache, 95 bool stale_copy_in_cache,
96 const base::TimeTicks& completion_time, 96 const base::TimeTicks& completion_time,
97 int64_t total_transfer_size, 97 int64_t total_transfer_size,
98 int64_t encoded_body_size) { 98 int64_t encoded_body_size,
99 int64_t decoded_body_size) {
99 // Give sub-classes a chance at altering the data. 100 // Give sub-classes a chance at altering the data.
100 if (error_code != net::OK) { 101 if (error_code != net::OK) {
101 // We failed to load the resource. 102 // We failed to load the resource.
102 original_peer_->OnReceivedResponse(response_info_); 103 original_peer_->OnReceivedResponse(response_info_);
103 original_peer_->OnCompletedRequest(net::ERR_ABORTED, false, 104 original_peer_->OnCompletedRequest(
104 stale_copy_in_cache, completion_time, 105 net::ERR_ABORTED, false, stale_copy_in_cache, completion_time,
105 total_transfer_size, encoded_body_size); 106 total_transfer_size, encoded_body_size, decoded_body_size);
106 return; 107 return;
107 } 108 }
108 109
109 ReplaceMessages(); 110 ReplaceMessages();
110 111
111 original_peer_->OnReceivedResponse(response_info_); 112 original_peer_->OnReceivedResponse(response_info_);
112 if (!data_.empty()) 113 if (!data_.empty())
113 original_peer_->OnReceivedData(base::MakeUnique<StringData>(data_)); 114 original_peer_->OnReceivedData(base::MakeUnique<StringData>(data_));
114 original_peer_->OnCompletedRequest(error_code, was_ignored_by_handler, 115 original_peer_->OnCompletedRequest(
115 stale_copy_in_cache, completion_time, 116 error_code, was_ignored_by_handler, stale_copy_in_cache, completion_time,
116 total_transfer_size, encoded_body_size); 117 total_transfer_size, encoded_body_size, decoded_body_size);
117 } 118 }
118 119
119 void ExtensionLocalizationPeer::ReplaceMessages() { 120 void ExtensionLocalizationPeer::ReplaceMessages() {
120 if (!message_sender_ || data_.empty()) 121 if (!message_sender_ || data_.empty())
121 return; 122 return;
122 123
123 if (!request_url_.is_valid()) 124 if (!request_url_.is_valid())
124 return; 125 return;
125 126
126 std::string extension_id = request_url_.host(); 127 std::string extension_id = request_url_.host();
(...skipping 12 matching lines...) Expand all
139 140
140 l10n_messages = extensions::GetL10nMessagesMap(extension_id); 141 l10n_messages = extensions::GetL10nMessagesMap(extension_id);
141 } 142 }
142 143
143 std::string error; 144 std::string error;
144 if (extensions::MessageBundle::ReplaceMessagesWithExternalDictionary( 145 if (extensions::MessageBundle::ReplaceMessagesWithExternalDictionary(
145 *l10n_messages, &data_, &error)) { 146 *l10n_messages, &data_, &error)) {
146 data_.resize(data_.size()); 147 data_.resize(data_.size());
147 } 148 }
148 } 149 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698