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

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: MockableOneShotTimer -> base::Timer (now mockable!) 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
« no previous file with comments | « chrome/renderer/net/net_error_helper.cc ('k') | chrome/renderer/net/net_error_helper_core.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 f2e810966ef0b6fd62e2a12a5ee37950ac6c8e6d..e52a3a4f306c5222cee9a6c4ddd79004c9d89c04 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/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
+#include "base/timer/timer.h"
#include "chrome/common/localized_error.h"
#include "chrome/common/net/net_error_info.h"
#include "url/gurl.h"
@@ -69,6 +71,9 @@ class NetErrorHelperCore {
// ongoing.
virtual void CancelFetchNavigationCorrections() = 0;
+ // Starts a reload of the page in the observed frame.
+ virtual void ReloadPage() = 0;
+
protected:
virtual ~Delegate() {}
};
@@ -95,6 +100,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 OnNavigationCorrectionsFetched(const std::string& corrections,
@@ -110,6 +117,30 @@ class NetErrorHelperCore {
const std::string& country_code,
const std::string& api_key,
const GURL& search_url);
+ // 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_auto_reload_enabled(bool auto_reload_enabled) {
+ auto_reload_enabled_ = auto_reload_enabled;
+ }
+
+ int auto_reload_count() const { return auto_reload_count_; }
+
+ bool ShouldSuppressErrorPage(FrameType frame_type, const GURL& url);
+
+ void set_timer_for_testing(scoped_ptr<base::Timer> timer) {
+ auto_reload_timer_.reset(timer.release());
+ }
private:
struct ErrorPageInfo;
@@ -128,6 +159,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.
@@ -146,6 +183,15 @@ class NetErrorHelperCore {
std::string country_code_;
std::string api_key_;
GURL search_url_;
+
+ bool auto_reload_enabled_;
+ scoped_ptr<base::Timer> 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_
« no previous file with comments | « chrome/renderer/net/net_error_helper.cc ('k') | chrome/renderer/net/net_error_helper_core.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698