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

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

Issue 13270005: Display DNS probe results. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Refactor a bit again (DnsProbeRunner is now tied to a single DnsClient), other fixes Created 7 years, 6 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>
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"
mmenke 2013/06/12 19:17:12 Don't think this is needed.
Deprecated (see juliatuttle) 2013/06/13 14:37:04 Done.
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
23 // Listens for NetErrorInfo messages from the NetErrorTabHelper on the
24 // browser side and updates the error page with more details (currently, just
25 // DNS probe results) if/when available.
16 class NetErrorHelper : public content::RenderViewObserver { 26 class NetErrorHelper : public content::RenderViewObserver {
17 public: 27 public:
18 explicit NetErrorHelper(content::RenderView* render_view); 28 explicit NetErrorHelper(content::RenderView* render_view);
19 virtual ~NetErrorHelper(); 29 virtual ~NetErrorHelper();
20 30
21 // RenderViewObserver implementation. 31 // RenderViewObserver implementation.
22 virtual void DidStartProvisionalLoad(WebKit::WebFrame* frame) OVERRIDE; 32 virtual void DidStartProvisionalLoad(WebKit::WebFrame* frame) OVERRIDE;
23 virtual void DidFailProvisionalLoad( 33 virtual void DidFailProvisionalLoad(
24 WebKit::WebFrame* frame, 34 WebKit::WebFrame* frame,
25 const WebKit::WebURLError& error) OVERRIDE; 35 const WebKit::WebURLError& error) OVERRIDE;
26 virtual void DidCommitProvisionalLoad( 36 virtual void DidCommitProvisionalLoad(
27 WebKit::WebFrame* frame, 37 WebKit::WebFrame* frame,
28 bool is_new_navigation) OVERRIDE; 38 bool is_new_navigation) OVERRIDE;
29 virtual void DidFinishLoad(WebKit::WebFrame* frame) OVERRIDE; 39 virtual void DidFinishLoad(WebKit::WebFrame* frame) OVERRIDE;
30 40
31 // IPC::Listener implementation. 41 // IPC::Listener implementation.
32 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 42 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
33 43
44 static bool GetErrorStringsForDnsProbe(
45 WebKit::WebFrame* frame,
46 const WebKit::WebURLError& error,
47 bool is_failed_post,
48 const std::string& locale,
49 base::DictionaryValue* error_strings);
50
51 protected:
52 // These methods handle tracking the actual state of the page; this allows
53 // us to unit-test the state tracking without having to mock out WebFrames
mmenke 2013/06/12 19:17:12 nit: Many reviewers don't like we/us in comments.
Deprecated (see juliatuttle) 2013/06/13 14:37:04 Done.
54 // and such.
55 void OnStartLoad(bool is_main_frame, bool is_error_page);
56 void OnFailLoad(bool is_main_frame, bool is_dns_error);
57 void OnCommitLoad(bool is_main_frame);
58 void OnFinishLoad(bool is_main_frame);
59
60 void OnNetErrorInfo(int status);
61 virtual void UpdateErrorPage();
62
63 // The last DnsProbeStatus received from the browser.
64 chrome_common_net::DnsProbeStatus last_status_;
65
34 private: 66 private:
35 void OnNetErrorInfo(int dns_probe_result); 67 WebKit::WebURLError GetUpdatedError() const;
36 void TrackerCallback(NetErrorTracker::DnsErrorPageState state);
37 void UpdateErrorPage(chrome_common_net::DnsProbeResult dns_probe_result);
38 68
39 NetErrorTracker tracker_; 69 // True if the last provisional load start the helper saw was an error page.
mmenke 2013/06/12 19:17:12 nit: Suggest "True if the last started load was a
Deprecated (see juliatuttle) 2013/06/13 14:37:04 Done.
40 NetErrorTracker::DnsErrorPageState dns_error_page_state_; 70 bool is_error_page_;
41 bool updated_error_page_; 71
72 // True if the helper has seen a main frame page load fail with a DNS error,
73 // but has not yet seen a new page load successfully afterwards.
74 bool dns_error_active_;
75
76 // True if the helper has seen the page finish loading, but has not yet seen
77 // a new provisional load commit.
78 bool page_loaded_;
79
80 // The last main frame error seen by the helper.
81 WebKit::WebURLError last_error_;
82
42 bool is_failed_post_; 83 bool is_failed_post_;
43 }; 84 };
44 85
45 #endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_H_ 86 #endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698