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

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

Issue 2166363003: Offline pages using NQE 2G Slow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebasing, renaming method to match rebase Created 4 years, 5 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 22ff4a148d1db2f201c57e451d954748580ddd62..ef9c711d9951a2e551d5493975def6cb26c76131 100644
--- a/chrome/browser/android/offline_pages/offline_page_tab_helper.h
+++ b/chrome/browser/android/offline_pages/offline_page_tab_helper.h
@@ -5,62 +5,74 @@
#ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_TAB_HELPER_H_
#define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_TAB_HELPER_H_
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "components/offline_pages/offline_page_types.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
#include "url/gurl.h"
+namespace base {
+class Time;
+}
+
namespace content {
class WebContents;
}
namespace offline_pages {
struct OfflinePageItem;
// Per-tab class to manage switch between online version and offline version.
class OfflinePageTabHelper :
public content::WebContentsObserver,
public content::WebContentsUserData<OfflinePageTabHelper> {
public:
// Delegate that is used to better handle external dependencies.
// Default implementation is in .cc file, while tests provide an override.
class Delegate {
public:
virtual ~Delegate() {}
virtual bool GetTabId(content::WebContents* web_contents,
std::string* tab_id) const = 0;
+ virtual base::Time Now() const = 0;
Lei Zhang 2016/07/28 20:41:52 a) I'm not sure you can forward declare if it's re
RyanSturm 2016/07/28 22:07:18 Done. You're absolutely right. Time is included vi
};
// This enum is used for UMA reporting. It contains all possible outcomes of
// redirect intent and result. Generally one of these outcomes will happen.
// The fringe errors (like no OfflinePageModel, etc.) are not reported due
// to their low probability.
// NOTE: because this is used for UMA reporting, these values should not be
// changed or reused; new values should be ended immediately before the MAX
// value. Make sure to update the histogram enum
// (OfflinePagesRedirectResult in histograms.xml) accordingly.
// Public for testing.
enum class RedirectResult {
REDIRECTED_ON_DISCONNECTED_NETWORK = 0,
PAGE_NOT_FOUND_ON_DISCONNECTED_NETWORK = 1,
+ // Flaky Network means the network reported an error when trying to fetch
+ // the resource.
REDIRECTED_ON_FLAKY_NETWORK = 2,
PAGE_NOT_FOUND_ON_FLAKY_NETWORK = 3,
IGNORED_FLAKY_NETWORK_FORWARD_BACK = 4,
REDIRECTED_ON_CONNECTED_NETWORK = 5,
NO_TAB_ID = 6,
SHOW_NET_ERROR_PAGE = 7,
REDIRECT_LOOP_OFFLINE = 8,
REDIRECT_LOOP_ONLINE = 9,
+ // Prohibitively slow means that the NetworkQualityEstimator reported a
+ // connection slow enough to warrant showing an offline page if available.
+ REDIRECTED_ON_PROHIBITIVELY_SLOW_NETWORK = 10,
+ PAGE_NOT_FOUND_ON_PROHIBITIVELY_SLOW_NETWORK = 11,
+ PAGE_NOT_FRESH_ON_PROHIBITIVELY_SLOW_NETWORK = 12,
REDIRECT_RESULT_MAX,
};
~OfflinePageTabHelper() override;
const OfflinePageItem* offline_page() { return offline_page_.get(); }
private:
friend class content::WebContentsUserData<OfflinePageTabHelper>;
friend class OfflinePageTabHelperTest;
@@ -100,18 +112,19 @@ class OfflinePageTabHelper :
// 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.
std::unique_ptr<OfflinePageItem> offline_page_;
std::unique_ptr<Delegate> delegate_;
+
base::WeakPtrFactory<OfflinePageTabHelper> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(OfflinePageTabHelper);
};
} // namespace offline_pages
#endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_TAB_HELPER_H_

Powered by Google App Engine
This is Rietveld 408576698