OLD | NEW |
---|---|
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> | |
9 | |
8 #include "chrome/common/net/net_error_info.h" | 10 #include "chrome/common/net/net_error_info.h" |
9 #include "chrome/common/net/net_error_tracker.h" | |
10 #include "content/public/renderer/render_view_observer.h" | 11 #include "content/public/renderer/render_view_observer.h" |
12 #include "googleurl/src/gurl.h" | |
13 #include "third_party/WebKit/public/platform/WebURLError.h" | |
14 | |
15 namespace base { | |
16 class DictionaryValue; | |
17 } | |
11 | 18 |
12 namespace WebKit { | 19 namespace WebKit { |
13 class WebFrame; | 20 class WebFrame; |
14 } | 21 } |
15 | 22 |
16 class NetErrorHelper : public content::RenderViewObserver { | 23 class NetErrorHelper : public content::RenderViewObserver { |
szym
2013/06/07 19:31:28
I think a short class-level or file-level comment
Deprecated (see juliatuttle)
2013/06/11 01:07:34
Done.
| |
17 public: | 24 public: |
18 explicit NetErrorHelper(content::RenderView* render_view); | 25 explicit NetErrorHelper(content::RenderView* render_view); |
19 virtual ~NetErrorHelper(); | 26 virtual ~NetErrorHelper(); |
20 | 27 |
21 // RenderViewObserver implementation. | 28 // RenderViewObserver implementation. |
22 virtual void DidStartProvisionalLoad(WebKit::WebFrame* frame) OVERRIDE; | 29 virtual void DidStartProvisionalLoad(WebKit::WebFrame* frame) OVERRIDE; |
23 virtual void DidFailProvisionalLoad( | 30 virtual void DidFailProvisionalLoad( |
24 WebKit::WebFrame* frame, | 31 WebKit::WebFrame* frame, |
25 const WebKit::WebURLError& error) OVERRIDE; | 32 const WebKit::WebURLError& error) OVERRIDE; |
26 virtual void DidCommitProvisionalLoad( | 33 virtual void DidCommitProvisionalLoad( |
27 WebKit::WebFrame* frame, | 34 WebKit::WebFrame* frame, |
28 bool is_new_navigation) OVERRIDE; | 35 bool is_new_navigation) OVERRIDE; |
29 virtual void DidFinishLoad(WebKit::WebFrame* frame) OVERRIDE; | 36 virtual void DidFinishLoad(WebKit::WebFrame* frame) OVERRIDE; |
30 | 37 |
31 // IPC::Listener implementation. | 38 // IPC::Listener implementation. |
32 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 39 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
33 | 40 |
41 static bool GetErrorStringsForDnsProbe( | |
42 WebKit::WebFrame* frame, | |
43 const WebKit::WebURLError& error, | |
44 bool is_failed_post, | |
45 const std::string& locale, | |
46 base::DictionaryValue* error_strings); | |
47 | |
48 protected: | |
49 // These methods handle tracking the actual state of the page; this allows | |
50 // us to unit-test the state tracking without having to mock out WebFrames | |
51 // and such. | |
52 void OnStartLoad(bool is_main_frame, bool is_error_page); | |
53 void OnFailLoad(bool is_main_frame, bool is_dns_error); | |
54 void OnCommitLoad(bool is_main_frame); | |
55 void OnFinishLoad(bool is_main_frame); | |
56 | |
57 void OnNetErrorInfo(int status); | |
58 virtual void UpdateErrorPage(); | |
59 | |
60 // The last DnsProbeStatus received from the browser. | |
61 chrome_common_net::DnsProbeStatus last_status_; | |
62 | |
34 private: | 63 private: |
35 void OnNetErrorInfo(int dns_probe_result); | 64 WebKit::WebURLError GetUpdatedError() const; |
36 void TrackerCallback(NetErrorTracker::DnsErrorPageState state); | |
37 void UpdateErrorPage(chrome_common_net::DnsProbeResult dns_probe_result); | |
38 | 65 |
39 NetErrorTracker tracker_; | 66 // True if the last provisional load start the helper saw was an error page. |
40 NetErrorTracker::DnsErrorPageState dns_error_page_state_; | 67 bool is_error_page_; |
41 bool updated_error_page_; | 68 |
69 // True if the helper has seen a main frame page load fail with a DNS error, | |
70 // but has not yet seen a new page load successfully afterwards. | |
71 bool dns_error_active_; | |
72 | |
73 // True if the helper has seen the page finish loading, but has not yet seen | |
74 // a new provisional load commit. | |
75 bool page_loaded_; | |
76 | |
77 // The last main frame error seen by the helper. | |
78 WebKit::WebURLError last_error_; | |
79 | |
42 bool is_failed_post_; | 80 bool is_failed_post_; |
43 }; | 81 }; |
44 | 82 |
45 #endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_H_ | 83 #endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_H_ |
OLD | NEW |