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

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

Issue 138513002: Plumb network stack information about existence of cached copy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporated comments from Matt & Ricardo. Created 6 years, 11 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 | Annotate | Revision Log
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 "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "chrome/common/extensions/extension_messages.h" 9 #include "chrome/common/extensions/extension_messages.h"
10 #include "chrome/common/extensions/message_bundle.h" 10 #include "chrome/common/extensions/message_bundle.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 void ExtensionLocalizationPeer::OnReceivedData(const char* data, 62 void ExtensionLocalizationPeer::OnReceivedData(const char* data,
63 int data_length, 63 int data_length,
64 int encoded_data_length) { 64 int encoded_data_length) {
65 data_.append(data, data_length); 65 data_.append(data, data_length);
66 } 66 }
67 67
68 void ExtensionLocalizationPeer::OnCompletedRequest( 68 void ExtensionLocalizationPeer::OnCompletedRequest(
69 int error_code, 69 int error_code,
70 bool was_ignored_by_handler, 70 bool was_ignored_by_handler,
71 bool stale_copy_in_cache,
71 const std::string& security_info, 72 const std::string& security_info,
72 const base::TimeTicks& completion_time) { 73 const base::TimeTicks& completion_time) {
73 // Make sure we delete ourselves at the end of this call. 74 // Make sure we delete ourselves at the end of this call.
74 scoped_ptr<ExtensionLocalizationPeer> this_deleter(this); 75 scoped_ptr<ExtensionLocalizationPeer> this_deleter(this);
75 76
76 // Give sub-classes a chance at altering the data. 77 // Give sub-classes a chance at altering the data.
77 if (error_code != net::OK) { 78 if (error_code != net::OK) {
78 // We failed to load the resource. 79 // We failed to load the resource.
79 original_peer_->OnReceivedResponse(response_info_); 80 original_peer_->OnReceivedResponse(response_info_);
80 original_peer_->OnCompletedRequest(net::ERR_ABORTED, false, security_info, 81 original_peer_->OnCompletedRequest(net::ERR_ABORTED, false,
82 stale_copy_in_cache, security_info,
81 completion_time); 83 completion_time);
82 return; 84 return;
83 } 85 }
84 86
85 ReplaceMessages(); 87 ReplaceMessages();
86 88
87 original_peer_->OnReceivedResponse(response_info_); 89 original_peer_->OnReceivedResponse(response_info_);
88 if (!data_.empty()) 90 if (!data_.empty())
89 original_peer_->OnReceivedData(data_.data(), 91 original_peer_->OnReceivedData(data_.data(),
90 static_cast<int>(data_.size()), 92 static_cast<int>(data_.size()),
91 -1); 93 -1);
92 original_peer_->OnCompletedRequest(error_code, was_ignored_by_handler, 94 original_peer_->OnCompletedRequest(error_code, was_ignored_by_handler,
95 stale_copy_in_cache,
93 security_info, completion_time); 96 security_info, completion_time);
94 } 97 }
95 98
96 void ExtensionLocalizationPeer::ReplaceMessages() { 99 void ExtensionLocalizationPeer::ReplaceMessages() {
97 if (!message_sender_ || data_.empty()) 100 if (!message_sender_ || data_.empty())
98 return; 101 return;
99 102
100 if (!request_url_.is_valid()) 103 if (!request_url_.is_valid())
101 return; 104 return;
102 105
(...skipping 13 matching lines...) Expand all
116 119
117 l10n_messages = extensions::GetL10nMessagesMap(extension_id); 120 l10n_messages = extensions::GetL10nMessagesMap(extension_id);
118 } 121 }
119 122
120 std::string error; 123 std::string error;
121 if (extensions::MessageBundle::ReplaceMessagesWithExternalDictionary( 124 if (extensions::MessageBundle::ReplaceMessagesWithExternalDictionary(
122 *l10n_messages, &data_, &error)) { 125 *l10n_messages, &data_, &error)) {
123 data_.resize(data_.size()); 126 data_.resize(data_.size());
124 } 127 }
125 } 128 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698