Chromium Code Reviews| Index: chrome/browser/android/offline_pages/offline_page_tab_helper.h |
| diff --git a/chrome/browser/android/offline_pages/offline_page_tab_helper.h b/chrome/browser/android/offline_pages/offline_page_tab_helper.h |
| index af283e22b529c82a9280c3a39737383927bd13c7..4227905a1b9ff2022fe88c5fdde07d716e0f8fb6 100644 |
| --- a/chrome/browser/android/offline_pages/offline_page_tab_helper.h |
| +++ b/chrome/browser/android/offline_pages/offline_page_tab_helper.h |
| @@ -34,17 +34,32 @@ class OfflinePageTabHelper : |
| std::string* tab_id) const = 0; |
| }; |
| + // This enum is used for UMA reporting. It contains all possible outcomes of |
| + // redirect intent and result. One of these outcomes will happen. The fringe |
| + // errors (like no OfflinePageModel etc) are not included. |
|
Mark P
2016/06/29 19:18:27
Please add something in here that because this is
Mark P
2016/06/29 19:18:27
If "fringe errors are not included" yet "one of th
Dmitry Titov
2016/06/29 20:27:42
Done.
Moved and re-phrased the comment that was ne
Dmitry Titov
2016/06/29 20:27:42
Nothing is emitted for those. These are the cases
Mark P
2016/06/30 05:09:02
Apologies, somehow I missed that comment.
|
| + // Public for testing. |
| + enum class RedirectResult { |
|
Mark P
2016/06/29 19:18:27
nit: why a class?
Dmitry Titov
2016/06/29 20:27:42
We seem to be getting a suggestion to use enum cla
Mark P
2016/06/30 05:09:02
Thanks for the link and explanation. class sgtm.
|
| + REDIRECTED_ON_DISCONNECTED_NETWORK, |
| + PAGE_NOT_FOUND_ON_DISCONNECTED_NETWORK, |
| + REDIRECTED_ON_FLAKY_NETWORK, |
| + PAGE_NOT_FOUND_ON_FLAKY_NETWORK, |
| + IGNORED_FLAKY_NETWORK_FORWARD_BACK, |
| + REDIRECTED_ON_CONNECTED_NETWORK, |
|
Mark P
2016/06/29 19:18:27
No PAGE_NOT_FOUND_ON_CONNECTED_NETWORK?
Dmitry Titov
2016/06/29 20:27:42
Right, not applicable to connected network. "Page
Mark P
2016/06/30 05:09:02
Acknowledged.
|
| + NO_TAB_ID, |
| + SHOW_NET_ERROR_PAGE, |
| + REDIRECT_LOOP_OFFLINE, |
| + REDIRECT_LOOP_ONLINE, |
| + // NOTE: always keep this entry at the end. Add new redirect results only |
| + // immediately above this line. Make sure to update the histogram enum |
| + // (OfflinePagesRedirectResult in histograms.xml) accordingly. |
| + REDIRECT_RESULT_MAX, |
| + }; |
| + |
| ~OfflinePageTabHelper() override; |
| const OfflinePageItem* offline_page() { return offline_page_.get(); } |
| private: |
| - enum class RedirectReason { |
| - DISCONNECTED_NETWORK, |
| - FLAKY_NETWORK, |
| - FLAKY_NETWORK_FORWARD_BACK |
| - }; |
| - |
| friend class content::WebContentsUserData<OfflinePageTabHelper>; |
| friend class OfflinePageTabHelperTest; |
| FRIEND_TEST_ALL_PREFIXES(OfflinePageTabHelperTest, |
| @@ -66,18 +81,24 @@ class OfflinePageTabHelper : |
| // 3 step redirection to the offline page. First getting all the pages, then |
| // selecting appropriate page to redirect to and finally attempting to |
| // redirect to that offline page, and caching metadata of that page locally. |
| - void GetPagesForRedirectToOffline(const GURL& online_url, |
| - RedirectReason reason); |
| + // RedirectResult is accumulated along the codepath to reflect the overall |
| + // result of redirection - and be reported to UMA at the end. |
| + void GetPagesForRedirectToOffline(RedirectResult result, |
| + const GURL& online_url); |
| void SelectBestPageForRedirectToOffline( |
| + RedirectResult result, |
| const GURL& online_url, |
| - RedirectReason reason, |
| const MultipleOfflinePageItemResult& pages); |
| - void TryRedirectToOffline(RedirectReason redirect_reason, |
| + void TryRedirectToOffline(RedirectResult result, |
| const GURL& from_url, |
| const OfflinePageItem& offline_page); |
| void Redirect(const GURL& from_url, const GURL& to_url); |
| + // Returns true if a given URL is in redirect chain already. |
| + bool IsInRedirectLoop(const GURL& to_url) const; |
|
jianli
2016/06/29 20:20:16
nit: add empty line
Dmitry Titov
2016/06/29 20:38:03
Done.
|
| + void ReportRedirectResultUMA(RedirectResult result); |
| + |
| // Iff the tab we are associated with is redirected to an offline page, |
| // |offline_page_| will be non-null. This can be used to synchronously ask |
| // about the offline state of the current web contents. |