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/net/net_error_helper.cc

Issue 138513002: Plumb network stack information about existence of cached copy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync'd to r248769. Created 6 years, 10 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/net/net_error_helper.h" 5 #include "chrome/renderer/net/net_error_helper.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 119
120 int resource_id = IDR_NET_ERROR_HTML; 120 int resource_id = IDR_NET_ERROR_HTML;
121 const base::StringPiece template_html( 121 const base::StringPiece template_html(
122 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id)); 122 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id));
123 if (template_html.empty()) { 123 if (template_html.empty()) {
124 NOTREACHED() << "unable to load template."; 124 NOTREACHED() << "unable to load template.";
125 } else { 125 } else {
126 base::DictionaryValue error_strings; 126 base::DictionaryValue error_strings;
127 LocalizedError::GetStrings(error.reason, error.domain.utf8(), 127 LocalizedError::GetStrings(error.reason, error.domain.utf8(),
128 error.unreachableURL, is_failed_post, 128 error.unreachableURL, is_failed_post,
129 error.staleCopyInCache,
129 RenderThread::Get()->GetLocale(), 130 RenderThread::Get()->GetLocale(),
130 render_frame()->GetRenderView()-> 131 render_frame()->GetRenderView()->
131 GetAcceptLanguages(), 132 GetAcceptLanguages(),
132 &error_strings); 133 &error_strings);
133 // "t" is the id of the template's root node. 134 // "t" is the id of the template's root node.
134 *error_html = webui::GetTemplatesHtml(template_html, &error_strings, "t"); 135 *error_html = webui::GetTemplatesHtml(template_html, &error_strings, "t");
135 } 136 }
136 } 137 }
137 138
138 void NetErrorHelper::LoadErrorPageInMainFrame(const std::string& html, 139 void NetErrorHelper::LoadErrorPageInMainFrame(const std::string& html,
139 const GURL& failed_url) { 140 const GURL& failed_url) {
140 blink::WebView* web_view = render_frame()->GetRenderView()->GetWebView(); 141 blink::WebView* web_view = render_frame()->GetRenderView()->GetWebView();
141 if (!web_view) 142 if (!web_view)
142 return; 143 return;
143 blink::WebFrame* frame = web_view->mainFrame(); 144 blink::WebFrame* frame = web_view->mainFrame();
144 frame->loadHTMLString(html, GURL(kUnreachableWebDataURL), failed_url, true); 145 frame->loadHTMLString(html, GURL(kUnreachableWebDataURL), failed_url, true);
145 } 146 }
146 147
147 void NetErrorHelper::UpdateErrorPage(const blink::WebURLError& error, 148 void NetErrorHelper::UpdateErrorPage(const blink::WebURLError& error,
148 bool is_failed_post) { 149 bool is_failed_post) {
149 base::DictionaryValue error_strings; 150 base::DictionaryValue error_strings;
150 LocalizedError::GetStrings(error.reason, 151 LocalizedError::GetStrings(error.reason,
151 error.domain.utf8(), 152 error.domain.utf8(),
152 error.unreachableURL, 153 error.unreachableURL,
153 is_failed_post, 154 is_failed_post,
155 error.staleCopyInCache,
154 RenderThread::Get()->GetLocale(), 156 RenderThread::Get()->GetLocale(),
155 render_frame()->GetRenderView()-> 157 render_frame()->GetRenderView()->
156 GetAcceptLanguages(), 158 GetAcceptLanguages(),
157 &error_strings); 159 &error_strings);
158 160
159 std::string json; 161 std::string json;
160 JSONWriter::Write(&error_strings, &json); 162 JSONWriter::Write(&error_strings, &json);
161 163
162 std::string js = "if (window.updateForDnsProbe) " 164 std::string js = "if (window.updateForDnsProbe) "
163 "updateForDnsProbe(" + json + ");"; 165 "updateForDnsProbe(" + json + ");";
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 // The fetcher may only be deleted after |data| is passed to |core_|. Move 214 // The fetcher may only be deleted after |data| is passed to |core_|. Move
213 // it to a temporary to prevent any potential re-entrancy issues. 215 // it to a temporary to prevent any potential re-entrancy issues.
214 scoped_ptr<content::ResourceFetcher> fetcher( 216 scoped_ptr<content::ResourceFetcher> fetcher(
215 alt_error_page_fetcher_.release()); 217 alt_error_page_fetcher_.release());
216 if (!response.isNull() && response.httpStatusCode() == 200) { 218 if (!response.isNull() && response.httpStatusCode() == 200) {
217 core_.OnAlternateErrorPageFetched(data); 219 core_.OnAlternateErrorPageFetched(data);
218 } else { 220 } else {
219 core_.OnAlternateErrorPageFetched(""); 221 core_.OnAlternateErrorPageFetched("");
220 } 222 }
221 } 223 }
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/extension_localization_peer_unittest.cc ('k') | chrome/renderer/net/net_error_helper_core.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698