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

Unified Diff: chrome/renderer/net/net_error_helper_core.h

Issue 136203009: Support auto-reload on errors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Add MockableOneShotTimer tests. Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
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..c1e4fbfae2ed4674781c01019e4ca5b39bb4bf5f 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;
mmenke 2014/03/11 20:07:54 Think you can just rename this to auto_reload_coun
Elly Fong-Jones 2014/03/12 15:08:58 Done.
+
+ bool ShouldSuppressErrorPage(FrameType frame_type, const GURL& url);
+
private:
struct ErrorPageInfo;
@@ -112,6 +141,12 @@ class NetErrorHelperCore {
blink::WebURLError GetUpdatedError(const blink::WebURLError& error) const;
+ void Reload();
+ bool MaybeStartAutoReloadTimer();
+ void StartAutoReloadTimer();
+
+ static bool IsReloadableError(const ErrorPageInfo& info);
+
Delegate* delegate_;
// The last DnsProbeStatus received from the browser.
@@ -126,6 +161,15 @@ 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_;
+
+ int auto_reload_count_;
+ bool can_auto_reload_page_;
};
#endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_CORE_H_

Powered by Google App Engine
This is Rietveld 408576698