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

Unified Diff: chrome/browser/android/offline_pages/offline_page_tab_helper.h

Issue 2105173002: Add enum-based UMA reporting to automatic redirect logic of Offline Pages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed feedback Created 4 years, 6 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/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..bde8df35b43cb45c43eaec55a5b64443066159ad 100644
--- a/chrome/browser/android/offline_pages/offline_page_tab_helper.h
+++ b/chrome/browser/android/offline_pages/offline_page_tab_helper.h
@@ -38,13 +38,28 @@ class OfflinePageTabHelper :
const OfflinePageItem* offline_page() { return offline_page_.get(); }
- private:
- enum class RedirectReason {
- DISCONNECTED_NETWORK,
- FLAKY_NETWORK,
- FLAKY_NETWORK_FORWARD_BACK
+ // 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.
+ // Public for testing.
+ enum class RedirectResult {
fgorski 2016/06/29 17:01:16 nit: Could you move this above the desctructor? It
Dmitry Titov 2016/06/29 18:25:45 Done.
+ 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,
+ 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,
};
+ private:
friend class content::WebContentsUserData<OfflinePageTabHelper>;
friend class OfflinePageTabHelperTest;
FRIEND_TEST_ALL_PREFIXES(OfflinePageTabHelperTest,
@@ -67,17 +82,21 @@ class OfflinePageTabHelper :
// 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 result);
void SelectBestPageForRedirectToOffline(
const GURL& online_url,
- RedirectReason reason,
+ RedirectResult result,
const MultipleOfflinePageItemResult& pages);
- void TryRedirectToOffline(RedirectReason redirect_reason,
+ void TryRedirectToOffline(RedirectResult result,
fgorski 2016/06/29 17:01:16 nit: please reorder parameters for consistency, if
Dmitry Titov 2016/06/29 18:25:44 Done.
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;
+ 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.

Powered by Google App Engine
This is Rietveld 408576698