Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_RENDERER_NET_NET_ERROR_HELPER_CORE_H_ | 5 #ifndef CHROME_RENDERER_NET_NET_ERROR_HELPER_CORE_H_ |
| 6 #define CHROME_RENDERER_NET_NET_ERROR_HELPER_CORE_H_ | 6 #define CHROME_RENDERER_NET_NET_ERROR_HELPER_CORE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | |
| 10 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 11 #include "chrome/common/net/net_error_info.h" | 12 #include "chrome/common/net/net_error_info.h" |
| 13 #include "chrome/renderer/net/mockable_one_shot_timer.h" | |
| 12 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 13 | 15 |
| 14 namespace blink { | 16 namespace blink { |
| 15 struct WebURLError; | 17 struct WebURLError; |
| 16 } | 18 } |
| 17 | 19 |
| 18 // Class that contains the logic for how the NetErrorHelper. This allows for | 20 // Class that contains the logic for how the NetErrorHelper. This allows for |
| 19 // testing the logic without a RenderView or WebFrame, which are difficult to | 21 // testing the logic without a RenderView or WebFrame, which are difficult to |
| 20 // mock, and for testing races which are impossible to reliably reproduce | 22 // mock, and for testing races which are impossible to reliably reproduce |
| 21 // with real RenderViews or WebFrames. | 23 // with real RenderViews or WebFrames. |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 51 bool is_failed_post) = 0; | 53 bool is_failed_post) = 0; |
| 52 | 54 |
| 53 // Fetches an error page and calls into OnErrorPageFetched when done. Any | 55 // Fetches an error page and calls into OnErrorPageFetched when done. Any |
| 54 // previous fetch must either be canceled or finished before calling. Can't | 56 // previous fetch must either be canceled or finished before calling. Can't |
| 55 // be called synchronously after a previous fetch completes. | 57 // be called synchronously after a previous fetch completes. |
| 56 virtual void FetchErrorPage(const GURL& url) = 0; | 58 virtual void FetchErrorPage(const GURL& url) = 0; |
| 57 | 59 |
| 58 // Cancels an error page fetch. Does nothing if no fetch is ongoing. | 60 // Cancels an error page fetch. Does nothing if no fetch is ongoing. |
| 59 virtual void CancelFetchErrorPage() = 0; | 61 virtual void CancelFetchErrorPage() = 0; |
| 60 | 62 |
| 63 // Starts a reload of the page in the observed frame. | |
| 64 virtual void ReloadPage() = 0; | |
| 65 | |
| 66 // Allocates a new MockableOneShotTimer. | |
| 67 virtual MockableOneShotTimer* NewMockableOneShotTimer() = 0; | |
| 68 | |
| 61 protected: | 69 protected: |
| 62 virtual ~Delegate() {} | 70 virtual ~Delegate() {} |
| 63 }; | 71 }; |
| 64 | 72 |
| 65 explicit NetErrorHelperCore(Delegate* delegate); | 73 explicit NetErrorHelperCore(Delegate* delegate); |
| 66 ~NetErrorHelperCore(); | 74 ~NetErrorHelperCore(); |
| 67 | 75 |
| 68 // Examines |frame| and |error| to see if this is an error worthy of a DNS | 76 // Examines |frame| and |error| to see if this is an error worthy of a DNS |
| 69 // probe. If it is, initializes |error_strings| based on |error|, | 77 // probe. If it is, initializes |error_strings| based on |error|, |
| 70 // |is_failed_post|, and |locale| with suitable strings and returns true. | 78 // |is_failed_post|, and |locale| with suitable strings and returns true. |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 85 void OnStop(); | 93 void OnStop(); |
| 86 | 94 |
| 87 // Called when an error page have has been retrieved over the network. |html| | 95 // Called when an error page have has been retrieved over the network. |html| |
| 88 // must be an empty string on error. | 96 // must be an empty string on error. |
| 89 void OnAlternateErrorPageFetched(const std::string& html); | 97 void OnAlternateErrorPageFetched(const std::string& html); |
| 90 | 98 |
| 91 // Notifies |this| that network error information from the browser process | 99 // Notifies |this| that network error information from the browser process |
| 92 // has been received. | 100 // has been received. |
| 93 void OnNetErrorInfo(chrome_common_net::DnsProbeStatus status); | 101 void OnNetErrorInfo(chrome_common_net::DnsProbeStatus status); |
| 94 | 102 |
| 103 // Notifies |this| that the network's online status changed. | |
| 104 void NetworkStateChanged(bool online); | |
| 105 | |
| 95 void set_alt_error_page_url(const GURL& alt_error_page_url) { | 106 void set_alt_error_page_url(const GURL& alt_error_page_url) { |
| 96 alt_error_page_url_ = alt_error_page_url; | 107 alt_error_page_url_ = alt_error_page_url; |
| 97 } | 108 } |
| 98 | 109 |
| 110 void set_auto_reload_enabled(bool auto_reload_enabled) { | |
| 111 auto_reload_enabled_ = auto_reload_enabled; | |
| 112 } | |
| 113 | |
| 114 virtual void StartAutoReloadTimer(); | |
| 115 virtual bool IsAutoReloading() const; | |
|
mmenke
2014/02/05 23:31:43
Neither of these needs to be virtual.
mmenke
2014/02/05 23:31:43
Suggest calling this IsAutoReloadingForTesting().
Elly Fong-Jones
2014/02/10 21:42:06
Done.
Elly Fong-Jones
2014/02/10 21:42:06
Done.
| |
| 116 | |
| 99 private: | 117 private: |
| 100 struct ErrorPageInfo; | 118 struct ErrorPageInfo; |
| 101 | 119 |
| 102 // Updates the currently displayed error page with a new error based on the | 120 // Updates the currently displayed error page with a new error based on the |
| 103 // most recently received DNS probe result. The page must have finished | 121 // most recently received DNS probe result. The page must have finished |
| 104 // loading before this is called. | 122 // loading before this is called. |
| 105 void UpdateErrorPage(); | 123 void UpdateErrorPage(); |
| 106 | 124 |
| 107 void GenerateLocalErrorPage( | 125 void GenerateLocalErrorPage( |
| 108 FrameType frame_type, | 126 FrameType frame_type, |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 119 | 137 |
| 120 // Information for the provisional / "pre-provisional" error page. NULL when | 138 // Information for the provisional / "pre-provisional" error page. NULL when |
| 121 // there's no page pending, or the pending page is not an error page. | 139 // there's no page pending, or the pending page is not an error page. |
| 122 scoped_ptr<ErrorPageInfo> pending_error_page_info_; | 140 scoped_ptr<ErrorPageInfo> pending_error_page_info_; |
| 123 | 141 |
| 124 // Information for the committed error page. NULL when the committed page is | 142 // Information for the committed error page. NULL when the committed page is |
| 125 // not an error page. | 143 // not an error page. |
| 126 scoped_ptr<ErrorPageInfo> committed_error_page_info_; | 144 scoped_ptr<ErrorPageInfo> committed_error_page_info_; |
| 127 | 145 |
| 128 GURL alt_error_page_url_; | 146 GURL alt_error_page_url_; |
| 147 | |
| 148 bool auto_reload_enabled_; | |
| 149 scoped_ptr<MockableOneShotTimer> auto_reload_timer_; | |
| 150 int auto_reload_count_; | |
|
mmenke
2014/02/05 23:31:43
Think this needs a comment - it's not the number o
Elly Fong-Jones
2014/02/10 21:42:06
Done.
| |
| 151 | |
| 152 void AutoReload(); | |
|
mmenke
2014/02/05 23:31:43
Methods should be declared before member variables
mmenke
2014/02/05 23:31:43
Suggest calling this "Reload" instead, since it do
Elly Fong-Jones
2014/02/10 21:42:06
Done.
Elly Fong-Jones
2014/02/10 21:42:06
Done.
| |
| 129 }; | 153 }; |
| 130 | 154 |
| 131 #endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_CORE_H_ | 155 #endif // CHROME_RENDERER_NET_NET_ERROR_HELPER_CORE_H_ |
| OLD | NEW |