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

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

Issue 136203009: Support auto-reload on errors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Fixes 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 #ifndef CHROME_RENDERER_NET_NET_ERROR_HELPER_H_ 5 #ifndef CHROME_RENDERER_NET_NET_ERROR_HELPER_H_
6 #define CHROME_RENDERER_NET_NET_ERROR_HELPER_H_ 6 #define CHROME_RENDERER_NET_NET_ERROR_HELPER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "chrome/common/net/net_error_info.h" 10 #include "chrome/common/net/net_error_info.h"
11 #include "chrome/renderer/net/net_error_helper_core.h" 11 #include "chrome/renderer/net/net_error_helper_core.h"
12 #include "content/public/renderer/render_frame_observer.h" 12 #include "content/public/renderer/render_frame_observer.h"
13 #include "content/public/renderer/render_frame_observer_tracker.h" 13 #include "content/public/renderer/render_frame_observer_tracker.h"
14 #include "content/public/renderer/render_process_observer.h"
14 15
15 class GURL; 16 class GURL;
17 class MockableOneShotTimer;
16 18
17 namespace content { 19 namespace content {
18 class ResourceFetcher; 20 class ResourceFetcher;
19 } 21 }
20 22
21 namespace blink { 23 namespace blink {
22 class WebFrame; 24 class WebFrame;
23 class WebURLResponse; 25 class WebURLResponse;
24 struct WebURLError; 26 struct WebURLError;
25 } 27 }
26 28
27 // Listens for NetErrorInfo messages from the NetErrorTabHelper on the 29 // Listens for NetErrorInfo messages from the NetErrorTabHelper on the
28 // browser side and updates the error page with more details (currently, just 30 // browser side and updates the error page with more details (currently, just
29 // DNS probe results) if/when available. 31 // DNS probe results) if/when available.
30 class NetErrorHelper 32 class NetErrorHelper
31 : public content::RenderFrameObserver, 33 : public content::RenderFrameObserver,
32 public content::RenderFrameObserverTracker<NetErrorHelper>, 34 public content::RenderFrameObserverTracker<NetErrorHelper>,
35 public content::RenderProcessObserver,
33 public NetErrorHelperCore::Delegate { 36 public NetErrorHelperCore::Delegate {
34 public: 37 public:
35 explicit NetErrorHelper(content::RenderFrame* render_view); 38 explicit NetErrorHelper(content::RenderFrame* render_view,
39 bool auto_reload_enabled);
Randy Smith (Not in Mondays) 2014/02/06 16:47:16 Given that there aren't any tests currently in thi
36 virtual ~NetErrorHelper(); 40 virtual ~NetErrorHelper();
37 41
38 // RenderFrameObserver implementation. 42 // RenderFrameObserver implementation.
39 virtual void DidStartProvisionalLoad() OVERRIDE; 43 virtual void DidStartProvisionalLoad() OVERRIDE;
40 virtual void DidCommitProvisionalLoad(bool is_new_navigation) OVERRIDE; 44 virtual void DidCommitProvisionalLoad(bool is_new_navigation) OVERRIDE;
41 virtual void DidFinishLoad() OVERRIDE; 45 virtual void DidFinishLoad() OVERRIDE;
42 virtual void OnStop() OVERRIDE; 46 virtual void OnStop() OVERRIDE;
43 47
44 // IPC::Listener implementation. 48 // IPC::Listener implementation.
45 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 49 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
46 50
51 // RenderProcessObserver implementation.
52 virtual void NetworkStateChanged(bool online) OVERRIDE;
53
47 // Examines |frame| and |error| to see if this is an error worthy of a DNS 54 // Examines |frame| and |error| to see if this is an error worthy of a DNS
48 // probe. If it is, initializes |error_strings| based on |error|, 55 // probe. If it is, initializes |error_strings| based on |error|,
49 // |is_failed_post|, and |locale| with suitable strings and returns true. 56 // |is_failed_post|, and |locale| with suitable strings and returns true.
50 // If not, returns false, in which case the caller should look up error 57 // If not, returns false, in which case the caller should look up error
51 // strings directly using LocalizedError::GetNavigationErrorStrings. 58 // strings directly using LocalizedError::GetNavigationErrorStrings.
52 // 59 //
53 // Updates the NetErrorHelper with the assumption the page will be loaded 60 // Updates the NetErrorHelper with the assumption the page will be loaded
54 // immediately. 61 // immediately.
55 void GetErrorHTML(blink::WebFrame* frame, 62 void GetErrorHTML(blink::WebFrame* frame,
56 const blink::WebURLError& error, 63 const blink::WebURLError& error,
57 bool is_failed_post, 64 bool is_failed_post,
58 std::string* error_html); 65 std::string* error_html);
59 66
60 private: 67 private:
61 // NetErrorHelperCore::Delegate implementation: 68 // NetErrorHelperCore::Delegate implementation:
62 virtual void GenerateLocalizedErrorPage(const blink::WebURLError& error, 69 virtual void GenerateLocalizedErrorPage(const blink::WebURLError& error,
63 bool is_failed_post, 70 bool is_failed_post,
64 std::string* html) const OVERRIDE; 71 std::string* html) const OVERRIDE;
65 virtual void LoadErrorPageInMainFrame(const std::string& html, 72 virtual void LoadErrorPageInMainFrame(const std::string& html,
66 const GURL& failed_url) OVERRIDE; 73 const GURL& failed_url) OVERRIDE;
67 virtual void UpdateErrorPage(const blink::WebURLError& error, 74 virtual void UpdateErrorPage(const blink::WebURLError& error,
68 bool is_failed_post) OVERRIDE; 75 bool is_failed_post) OVERRIDE;
69 virtual void FetchErrorPage(const GURL& url) OVERRIDE; 76 virtual void FetchErrorPage(const GURL& url) OVERRIDE;
70 virtual void CancelFetchErrorPage() OVERRIDE; 77 virtual void CancelFetchErrorPage() OVERRIDE;
78 virtual void ReloadPage() OVERRIDE;
79 virtual MockableOneShotTimer* NewMockableOneShotTimer() OVERRIDE;
71 80
72 void OnNetErrorInfo(int status); 81 void OnNetErrorInfo(int status);
73 void OnSetAltErrorPageURL(const GURL& alternate_error_page_url); 82 void OnSetAltErrorPageURL(const GURL& alternate_error_page_url);
74 83
75 void OnAlternateErrorPageRetrieved(const blink::WebURLResponse& response, 84 void OnAlternateErrorPageRetrieved(const blink::WebURLResponse& response,
76 const std::string& data); 85 const std::string& data);
77 86
78 scoped_ptr<content::ResourceFetcher> alt_error_page_fetcher_; 87 scoped_ptr<content::ResourceFetcher> alt_error_page_fetcher_;
88 scoped_ptr<content::ResourceFetcher> auto_reload_page_fetcher_;
mmenke 2014/02/05 23:31:43 Not used.
Elly Fong-Jones 2014/02/10 21:42:06 Done.
79 89
80 NetErrorHelperCore core_; 90 NetErrorHelperCore core_;
81 }; 91 };
82 92
83 #endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_H_ 93 #endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698