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

Side by Side Diff: chrome/renderer/net/net_error_helper.cc

Issue 136203009: Support auto-reload on errors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: 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
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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 // The fetcher may only be deleted after |data| is passed to |core_|. Move 205 // 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. 206 // it to a temporary to prevent any potential re-entrancy issues.
207 scoped_ptr<content::ResourceFetcher> fetcher( 207 scoped_ptr<content::ResourceFetcher> fetcher(
208 alt_error_page_fetcher_.release()); 208 alt_error_page_fetcher_.release());
209 if (!response.isNull() && response.httpStatusCode() == 200) { 209 if (!response.isNull() && response.httpStatusCode() == 200) {
210 core_.OnAlternateErrorPageFetched(data); 210 core_.OnAlternateErrorPageFetched(data);
211 } else { 211 } else {
212 core_.OnAlternateErrorPageFetched(""); 212 core_.OnAlternateErrorPageFetched("");
213 } 213 }
214 } 214 }
215
216 // MockableOneShotTimer implementation in terms of base::OneShotTimer
Randy Smith (Not in Mondays) 2014/01/30 20:14:47 This feels like it should be in its own file, not
Elly Fong-Jones 2014/02/05 21:12:37 Done.
217
218 template<class Receiver>
219 class MockableOneShotTimerImpl
220 : public NetErrorHelperCore::MockableOneShotTimer {
221 public:
222 MockableOneShotTimerImpl();
223 virtual ~MockableOneShotTimerImpl();
224 virtual void Start(const tracked_objects::Location& posted_from,
225 base::TimeDelta delay, const base::Closure& user_task);
226 virtual void Stop();
227 virtual bool IsRunning() const;
228 private:
229 base::OneShotTimer<Receiver> timer_;
230 };
231
232 template<class Receiver>
233 MockableOneShotTimerImpl<Receiver>::MockableOneShotTimerImpl() {}
234 template<class Receiver>
235 MockableOneShotTimerImpl<Receiver>::~MockableOneShotTimerImpl() {}
236 template<class Receiver>
237 void MockableOneShotTimerImpl<Receiver>::Start(
238 const tracked_objects::Location& posted_from, base::TimeDelta delay,
239 const base::Closure& user_task) {
240 timer_.Start(posted_from, delay, user_task);
241 }
242
243 template<class Receiver>
244 void MockableOneShotTimerImpl<Receiver>::Stop() {
245 timer_.Stop();
246 }
247
248 template<class Receiver>
249 bool MockableOneShotTimerImpl<Receiver>::IsRunning() const {
250 return timer_.IsRunning();
251 }
252
253 NetErrorHelperCore::MockableOneShotTimer* NetErrorHelper::NewMockableOneShotTime r() {
Randy Smith (Not in Mondays) 2014/01/30 20:14:47 nit: Line too long?
Elly Fong-Jones 2014/02/05 21:12:37 Done.
254 return new MockableOneShotTimerImpl<NetErrorHelperCore>();
255 }
256
257 void NetErrorHelper::FetchAutoReloadPage(const GURL& url) {
258 render_frame()->GetWebFrame()->loadRequest(blink::WebURLRequest(url));
259 }
260
261 void NetErrorHelper::CancelFetchAutoReloadPage() {
262 // TODO(ellyjones): is this necessary? We can only get here via OnStop(),
263 // which already implies stopLoading().
264 // render_frame()->GetWebFrame()->stopLoading();
265 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698