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

Side by Side Diff: chrome/browser/net/net_error_tab_helper.h

Issue 13270005: Display DNS probe results. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Tweak things, clean up unit tests 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_BROWSER_NET_NET_ERROR_TAB_HELPER_H_ 5 #ifndef CHROME_BROWSER_NET_NET_ERROR_TAB_HELPER_H_
6 #define CHROME_BROWSER_NET_NET_ERROR_TAB_HELPER_H_ 6 #define CHROME_BROWSER_NET_NET_ERROR_TAB_HELPER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/prefs/pref_member.h" 11 #include "base/prefs/pref_member.h"
12 #include "chrome/browser/net/dns_probe_service.h" 12 #include "chrome/browser/net/dns_probe_service.h"
13 #include "chrome/common/net/net_error_info.h" 13 #include "chrome/common/net/net_error_info.h"
14 #include "chrome/common/net/net_error_tracker.h"
15 #include "content/public/browser/web_contents_observer.h" 14 #include "content/public/browser/web_contents_observer.h"
16 #include "content/public/browser/web_contents_user_data.h" 15 #include "content/public/browser/web_contents_user_data.h"
17 16
18 namespace chrome_browser_net { 17 namespace chrome_browser_net {
19 18
20 // A TabHelper that monitors loads for certain types of network errors and 19 // A TabHelper that monitors loads for certain types of network errors and
21 // does interesting things with them. Currently, starts DNS probes using the 20 // does interesting things with them. Currently, starts DNS probes using the
22 // DnsProbeService whenever a page fails to load with a DNS-related error. 21 // DnsProbeService whenever a page fails to load with a DNS-related error.
23 class NetErrorTabHelper 22 class NetErrorTabHelper
24 : public content::WebContentsObserver, 23 : public content::WebContentsObserver,
(...skipping 27 matching lines...) Expand all
52 content::RenderViewHost* render_view_host) OVERRIDE; 51 content::RenderViewHost* render_view_host) OVERRIDE;
53 52
54 virtual void DidFailProvisionalLoad( 53 virtual void DidFailProvisionalLoad(
55 int64 frame_id, 54 int64 frame_id,
56 bool is_main_frame, 55 bool is_main_frame,
57 const GURL& validated_url, 56 const GURL& validated_url,
58 int error_code, 57 int error_code,
59 const string16& error_description, 58 const string16& error_description,
60 content::RenderViewHost* render_view_host) OVERRIDE; 59 content::RenderViewHost* render_view_host) OVERRIDE;
61 60
62 virtual void DidFinishLoad( 61 protected:
63 int64 frame_id, 62 // |contents| is the WebContents of the tab this NetErrorTabHelper is
64 const GURL& validated_url, 63 // attached to.
65 bool is_main_frame, 64 explicit NetErrorTabHelper(content::WebContents* contents);
66 content::RenderViewHost* render_view_host) OVERRIDE; 65 virtual void StartDnsProbe();
66 virtual void SendInfo();
67 void OnDnsProbeFinished(chrome_common_net::DnsProbeStatus result);
68
69 // The status of a DNS probe that may or may not have started or finished.
70 // Since the renderer can change out from under the helper (in cross-process
71 // navigations), it re-sends the status whenever an error page commits.
72 chrome_common_net::DnsProbeStatus dns_probe_status_;
67 73
68 private: 74 private:
69 friend class content::WebContentsUserData<NetErrorTabHelper>; 75 friend class content::WebContentsUserData<NetErrorTabHelper>;
70 76
71 enum DnsProbeState { 77 void OnMainFrameDnsError();
72 DNS_PROBE_NONE,
73 DNS_PROBE_STARTED,
74 DNS_PROBE_FINISHED
75 };
76
77 // |contents| is the WebContents of the tab this NetErrorTabHelper is
78 // attached to.
79 explicit NetErrorTabHelper(content::WebContents* contents);
80
81 void TrackerCallback(NetErrorTracker::DnsErrorPageState state);
82 void MaybePostStartDnsProbeTask();
83 void OnDnsProbeFinished(chrome_common_net::DnsProbeResult result);
84 void MaybeSendInfo();
85 78
86 void InitializePref(content::WebContents* contents); 79 void InitializePref(content::WebContents* contents);
87 bool ProbesAllowed() const; 80 bool ProbesAllowed() const;
88 81
89 base::WeakPtrFactory<NetErrorTabHelper> weak_factory_; 82 base::WeakPtrFactory<NetErrorTabHelper> weak_factory_;
90 83
91 NetErrorTracker tracker_; 84 // True if the last provisional load that started was for an error page.
92 NetErrorTracker::DnsErrorPageState dns_error_page_state_; 85 bool is_error_page_;
93 86
94 DnsProbeState dns_probe_state_; 87 // True if the helper has seen a main frame page load fail with a DNS error,
95 chrome_common_net::DnsProbeResult dns_probe_result_; 88 // but has not yet seen a new page load successfully afterwards.
89 bool dns_error_active_;
96 90
97 // Whether we are enabled to run by the DnsProbe-Enable field trial. 91 // Whether we are enabled to run by the DnsProbe-Enable field trial.
98 const bool enabled_by_trial_; 92 const bool enabled_by_trial_;
93
99 // "Use a web service to resolve navigation errors" preference is required 94 // "Use a web service to resolve navigation errors" preference is required
100 // to allow probes. 95 // to allow probes.
101 BooleanPrefMember resolve_errors_with_web_service_; 96 BooleanPrefMember resolve_errors_with_web_service_;
102 97
103 DISALLOW_COPY_AND_ASSIGN(NetErrorTabHelper); 98 DISALLOW_COPY_AND_ASSIGN(NetErrorTabHelper);
104 }; 99 };
105 100
106 } // namespace chrome_browser_net 101 } // namespace chrome_browser_net
107 102
108 #endif // CHROME_BROWSER_NET_NET_ERROR_TAB_HELPER_H_ 103 #endif // CHROME_BROWSER_NET_NET_ERROR_TAB_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698