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

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: 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 (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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 115
116 int resource_id = IDR_NET_ERROR_HTML; 116 int resource_id = IDR_NET_ERROR_HTML;
117 const base::StringPiece template_html( 117 const base::StringPiece template_html(
118 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id)); 118 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id));
119 if (template_html.empty()) { 119 if (template_html.empty()) {
120 NOTREACHED() << "unable to load template."; 120 NOTREACHED() << "unable to load template.";
121 } else { 121 } else {
122 base::DictionaryValue error_strings; 122 base::DictionaryValue error_strings;
123 LocalizedError::GetStrings(error.reason, error.domain.utf8(), 123 LocalizedError::GetStrings(error.reason, error.domain.utf8(),
124 error.unreachableURL, is_failed_post, 124 error.unreachableURL, is_failed_post,
125 error.staleCopyInCache,
125 RenderThread::Get()->GetLocale(), 126 RenderThread::Get()->GetLocale(),
126 render_view()->GetAcceptLanguages(), 127 render_view()->GetAcceptLanguages(),
127 &error_strings); 128 &error_strings);
128 // "t" is the id of the template's root node. 129 // "t" is the id of the template's root node.
129 *error_html = webui::GetTemplatesHtml(template_html, &error_strings, "t"); 130 *error_html = webui::GetTemplatesHtml(template_html, &error_strings, "t");
130 } 131 }
131 } 132 }
132 133
133 void NetErrorHelper::LoadErrorPageInMainFrame(const std::string& html, 134 void NetErrorHelper::LoadErrorPageInMainFrame(const std::string& html,
134 const GURL& failed_url) { 135 const GURL& failed_url) {
135 blink::WebView* web_view = render_view()->GetWebView(); 136 blink::WebView* web_view = render_view()->GetWebView();
136 if (!web_view) 137 if (!web_view)
137 return; 138 return;
138 blink::WebFrame* frame = web_view->mainFrame(); 139 blink::WebFrame* frame = web_view->mainFrame();
139 frame->loadHTMLString(html, GURL(kUnreachableWebDataURL), failed_url, true); 140 frame->loadHTMLString(html, GURL(kUnreachableWebDataURL), failed_url, true);
140 } 141 }
141 142
142 void NetErrorHelper::UpdateErrorPage(const blink::WebURLError& error, 143 void NetErrorHelper::UpdateErrorPage(const blink::WebURLError& error,
143 bool is_failed_post) { 144 bool is_failed_post) {
144 base::DictionaryValue error_strings; 145 base::DictionaryValue error_strings;
145 LocalizedError::GetStrings(error.reason, 146 LocalizedError::GetStrings(error.reason,
146 error.domain.utf8(), 147 error.domain.utf8(),
147 error.unreachableURL, 148 error.unreachableURL,
148 is_failed_post, 149 is_failed_post,
150 error.staleCopyInCache,
149 RenderThread::Get()->GetLocale(), 151 RenderThread::Get()->GetLocale(),
150 render_view()->GetAcceptLanguages(), 152 render_view()->GetAcceptLanguages(),
151 &error_strings); 153 &error_strings);
152 154
153 std::string json; 155 std::string json;
154 JSONWriter::Write(&error_strings, &json); 156 JSONWriter::Write(&error_strings, &json);
155 157
156 std::string js = "if (window.updateForDnsProbe) " 158 std::string js = "if (window.updateForDnsProbe) "
157 "updateForDnsProbe(" + json + ");"; 159 "updateForDnsProbe(" + json + ");";
158 base::string16 js16; 160 base::string16 js16;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 // The fetcher may only be deleted after |data| is passed to |core_|. Move 207 // The fetcher may only be deleted after |data| is passed to |core_|. Move
206 // it to a temporary to prevent any potential re-entrancy issues. 208 // it to a temporary to prevent any potential re-entrancy issues.
207 scoped_ptr<content::ResourceFetcher> fetcher( 209 scoped_ptr<content::ResourceFetcher> fetcher(
208 alt_error_page_fetcher_.release()); 210 alt_error_page_fetcher_.release());
209 if (!response.isNull() && response.httpStatusCode() == 200) { 211 if (!response.isNull() && response.httpStatusCode() == 200) {
210 core_.OnAlternateErrorPageFetched(data); 212 core_.OnAlternateErrorPageFetched(data);
211 } else { 213 } else {
212 core_.OnAlternateErrorPageFetched(""); 214 core_.OnAlternateErrorPageFetched("");
213 } 215 }
214 } 216 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698