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

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: Don't break DnsProbe histograms Created 7 years, 5 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 "third_party/WebKit/public/platform/WebURLError.h"
13
14 namespace base {
15 class DictionaryValue;
16 }
11 17
12 namespace WebKit { 18 namespace WebKit {
13 class WebFrame; 19 class WebFrame;
14 } 20 }
15 21
22 // Listens for NetErrorInfo messages from the NetErrorTabHelper on the
23 // browser side and updates the error page with more details (currently, just
24 // DNS probe results) if/when available.
16 class NetErrorHelper : public content::RenderViewObserver { 25 class NetErrorHelper : public content::RenderViewObserver {
17 public: 26 public:
18 explicit NetErrorHelper(content::RenderView* render_view); 27 explicit NetErrorHelper(content::RenderView* render_view);
19 virtual ~NetErrorHelper(); 28 virtual ~NetErrorHelper();
20 29
21 // RenderViewObserver implementation. 30 // RenderViewObserver implementation.
22 virtual void DidStartProvisionalLoad(WebKit::WebFrame* frame) OVERRIDE; 31 virtual void DidStartProvisionalLoad(WebKit::WebFrame* frame) OVERRIDE;
23 virtual void DidFailProvisionalLoad( 32 virtual void DidFailProvisionalLoad(
24 WebKit::WebFrame* frame, 33 WebKit::WebFrame* frame,
25 const WebKit::WebURLError& error) OVERRIDE; 34 const WebKit::WebURLError& error) OVERRIDE;
26 virtual void DidCommitProvisionalLoad( 35 virtual void DidCommitProvisionalLoad(
27 WebKit::WebFrame* frame, 36 WebKit::WebFrame* frame,
28 bool is_new_navigation) OVERRIDE; 37 bool is_new_navigation) OVERRIDE;
29 virtual void DidFinishLoad(WebKit::WebFrame* frame) OVERRIDE; 38 virtual void DidFinishLoad(WebKit::WebFrame* frame) OVERRIDE;
30 39
31 // IPC::Listener implementation. 40 // IPC::Listener implementation.
32 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 41 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
33 42
43 static bool GetErrorStringsForDnsProbe(
44 WebKit::WebFrame* frame,
45 const WebKit::WebURLError& error,
46 bool is_failed_post,
47 const std::string& locale,
48 base::DictionaryValue* error_strings);
49
50 protected:
51 // These methods handle tracking the actual state of the page; this allows
52 // unit-testing of the state tracking without having to mock out WebFrames
53 // and such.
54 void OnStartLoad(bool is_main_frame, bool is_error_page);
55 void OnFailLoad(bool is_main_frame, bool is_dns_error);
56 void OnCommitLoad(bool is_main_frame);
57 void OnFinishLoad(bool is_main_frame);
58
59 void OnNetErrorInfo(int status);
60 virtual void UpdateErrorPage();
61
62 // The last DnsProbeStatus received from the browser.
63 chrome_common_net::DnsProbeStatus last_probe_status_;
64
34 private: 65 private:
35 void OnNetErrorInfo(int dns_probe_result); 66 WebKit::WebURLError GetUpdatedError() const;
36 void TrackerCallback(NetErrorTracker::DnsErrorPageState state);
37 void UpdateErrorPage(chrome_common_net::DnsProbeResult dns_probe_result);
38 67
39 NetErrorTracker tracker_; 68 // Whether the last provisional load started was for an error page.
40 NetErrorTracker::DnsErrorPageState dns_error_page_state_; 69 bool last_start_was_error_page_;
41 bool updated_error_page_; 70
71 // Whether the last provisional load failure failed with a DNS error.
72 bool last_fail_was_dns_error_;
73
74 // This is an odd variable.
75 //
76 // Ideally, it would be simply "last_commit_was_dns_error_page_".
77 //
78 // Unfortunately, that breaks if two DNS errors occur in a row; after the
79 // second failure, but before the second page commits, the helper can receive
80 // probe results. If all it knows is that the last commit was a DNS error
81 // page, it will cheerfully forward the results for the second probe to the
82 // first page.
83 //
84 // Thus, the semantics of this flag are a little weird. It is set whenever
85 // a DNS error page commits, and cleared whenever any other page commits,
86 // but it is also cleared whenever a DNS error occurs, to prevent the race
87 // described above.
88 bool forwarding_probe_results_;
89
90 // The last main frame error seen by the helper.
91 WebKit::WebURLError last_error_;
92
42 bool is_failed_post_; 93 bool is_failed_post_;
43 }; 94 };
44 95
45 #endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_H_ 96 #endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698