| Index: chrome/renderer/net/net_error_helper_core.h
|
| diff --git a/chrome/renderer/net/net_error_helper_core.h b/chrome/renderer/net/net_error_helper_core.h
|
| index cfbc8a154e2089a31da691f09567f5f2d23b2630..0654f1922a5edb701a83920519539c7f4f0a9a6d 100644
|
| --- a/chrome/renderer/net/net_error_helper_core.h
|
| +++ b/chrome/renderer/net/net_error_helper_core.h
|
| @@ -7,8 +7,10 @@
|
|
|
| #include <string>
|
|
|
| +#include "base/callback.h"
|
| #include "base/memory/weak_ptr.h"
|
| #include "chrome/common/net/net_error_info.h"
|
| +#include "chrome/renderer/net/mockable_one_shot_timer.h"
|
| #include "url/gurl.h"
|
|
|
| namespace blink {
|
| @@ -58,11 +60,15 @@ class NetErrorHelperCore {
|
| // Cancels an error page fetch. Does nothing if no fetch is ongoing.
|
| virtual void CancelFetchErrorPage() = 0;
|
|
|
| + // Starts a reload of the page in the observed frame.
|
| + virtual void ReloadPage() = 0;
|
| +
|
| protected:
|
| virtual ~Delegate() {}
|
| };
|
|
|
| - explicit NetErrorHelperCore(Delegate* delegate);
|
| + NetErrorHelperCore(Delegate* delegate,
|
| + scoped_ptr<MockableOneShotTimer> reload_timer);
|
| ~NetErrorHelperCore();
|
|
|
| // Examines |frame| and |error| to see if this is an error worthy of a DNS
|
| @@ -84,6 +90,8 @@ class NetErrorHelperCore {
|
| void OnFinishLoad(FrameType frame_type);
|
| void OnStop();
|
|
|
| + void CancelPendingFetches();
|
| +
|
| // Called when an error page have has been retrieved over the network. |html|
|
| // must be an empty string on error.
|
| void OnAlternateErrorPageFetched(const std::string& html);
|
| @@ -92,10 +100,31 @@ class NetErrorHelperCore {
|
| // has been received.
|
| void OnNetErrorInfo(chrome_common_net::DnsProbeStatus status);
|
|
|
| + // Notifies |this| that the network's online status changed.
|
| + // Handler for NetworkStateChanged notification from the browser process. If
|
| + // the network state changes to online, this method is responsible for
|
| + // starting the auto-reload process.
|
| + //
|
| + // Warning: if there are many tabs sitting at an error page, this handler will
|
| + // be run at the same time for each of their top-level renderframes, which can
|
| + // cause many requests to be started at the same time. There's no current
|
| + // protection against this kind of "reload storm".
|
| + //
|
| + // TODO(rdsmith): prevent the reload storm.
|
| + void NetworkStateChanged(bool online);
|
| +
|
| void set_alt_error_page_url(const GURL& alt_error_page_url) {
|
| alt_error_page_url_ = alt_error_page_url;
|
| }
|
|
|
| + void set_auto_reload_enabled(bool auto_reload_enabled) {
|
| + auto_reload_enabled_ = auto_reload_enabled;
|
| + }
|
| +
|
| + int GetAutoReloadCount() const;
|
| +
|
| + bool ShouldSuppressErrorPage(const GURL& url);
|
| +
|
| private:
|
| struct ErrorPageInfo;
|
|
|
| @@ -112,6 +141,10 @@ class NetErrorHelperCore {
|
|
|
| blink::WebURLError GetUpdatedError(const blink::WebURLError& error) const;
|
|
|
| + void Reload();
|
| + bool MaybeStartAutoReloadTimer();
|
| + void StartAutoReloadTimer();
|
| +
|
| Delegate* delegate_;
|
|
|
| // The last DnsProbeStatus received from the browser.
|
| @@ -126,6 +159,12 @@ class NetErrorHelperCore {
|
| scoped_ptr<ErrorPageInfo> committed_error_page_info_;
|
|
|
| GURL alt_error_page_url_;
|
| +
|
| + bool auto_reload_enabled_;
|
| + scoped_ptr<MockableOneShotTimer> auto_reload_timer_;
|
| +
|
| + // Is the browser online?
|
| + bool online_;
|
| };
|
|
|
| #endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_CORE_H_
|
|
|