// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_NET_NET_ERROR_TAB_HELPER_H_ #define CHROME_BROWSER_NET_NET_ERROR_TAB_HELPER_H_ #include "base/basictypes.h" #include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_user_data.h" namespace chrome_browser_net { // A TabHelper that monitors loads for certain types of network errors and // does interesting things with them. Currently, starts DNS probes using the // DnsProbeService whenever a page fails to load with a DNS-related error. class NetErrorTabHelper : public content::WebContentsObserver, public content::WebContentsUserData { public: virtual ~NetErrorTabHelper(); // content::WebContentsObserver implementation. virtual void DidFailProvisionalLoad( int64 frame_id, bool is_main_frame, const GURL& validated_url, int error_code, const string16& error_description, content::RenderViewHost* render_view_host) OVERRIDE; protected: friend class content::WebContentsUserData; // |contents| is the WebContents of the tab this NetErrorTabHelper is // attached to. explicit NetErrorTabHelper(content::WebContents* contents); // Starts a DNS probe. virtual void StartDnsProbe(); bool dns_probe_running() { return dns_probe_running_; } void set_dns_probe_running(bool running) { dns_probe_running_ = running; } private: // Whether the tab helper has started a DNS probe that has not yet returned // a result. bool dns_probe_running_; DISALLOW_COPY_AND_ASSIGN(NetErrorTabHelper); }; } // namespace chrome_browser_net #endif // CHROME_BROWSER_NET_NET_ERROR_TAB_HELPER_H_