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

Side by Side 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: clarifying comment 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_TAB_HELPER_H_ 5 #ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_TAB_HELPER_H_
6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_TAB_HELPER_H_ 6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_TAB_HELPER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "components/offline_pages/offline_page_types.h" 10 #include "components/offline_pages/offline_page_types.h"
11 #include "content/public/browser/web_contents_observer.h" 11 #include "content/public/browser/web_contents_observer.h"
12 #include "content/public/browser/web_contents_user_data.h" 12 #include "content/public/browser/web_contents_user_data.h"
13 #include "url/gurl.h" 13 #include "url/gurl.h"
14 14
15 namespace base {
16 class Clock;
17 }
18
15 namespace content { 19 namespace content {
16 class WebContents; 20 class WebContents;
17 } 21 }
18 22
19 namespace offline_pages { 23 namespace offline_pages {
20 24
21 struct OfflinePageItem; 25 struct OfflinePageItem;
22 26
23 // Per-tab class to manage switch between online version and offline version. 27 // Per-tab class to manage switch between online version and offline version.
24 class OfflinePageTabHelper : 28 class OfflinePageTabHelper :
(...skipping 22 matching lines...) Expand all
47 REDIRECTED_ON_DISCONNECTED_NETWORK = 0, 51 REDIRECTED_ON_DISCONNECTED_NETWORK = 0,
48 PAGE_NOT_FOUND_ON_DISCONNECTED_NETWORK = 1, 52 PAGE_NOT_FOUND_ON_DISCONNECTED_NETWORK = 1,
49 REDIRECTED_ON_FLAKY_NETWORK = 2, 53 REDIRECTED_ON_FLAKY_NETWORK = 2,
50 PAGE_NOT_FOUND_ON_FLAKY_NETWORK = 3, 54 PAGE_NOT_FOUND_ON_FLAKY_NETWORK = 3,
51 IGNORED_FLAKY_NETWORK_FORWARD_BACK = 4, 55 IGNORED_FLAKY_NETWORK_FORWARD_BACK = 4,
52 REDIRECTED_ON_CONNECTED_NETWORK = 5, 56 REDIRECTED_ON_CONNECTED_NETWORK = 5,
53 NO_TAB_ID = 6, 57 NO_TAB_ID = 6,
54 SHOW_NET_ERROR_PAGE = 7, 58 SHOW_NET_ERROR_PAGE = 7,
55 REDIRECT_LOOP_OFFLINE = 8, 59 REDIRECT_LOOP_OFFLINE = 8,
56 REDIRECT_LOOP_ONLINE = 9, 60 REDIRECT_LOOP_ONLINE = 9,
61 REDIRECTED_ON_PROHIBITVELY_SLOW_NETWORK = 10,
tbansal1 2016/07/25 21:43:22 What's the difference between Flaky network and Sl
RyanSturm 2016/07/26 19:48:11 Done.
62 PAGE_NOT_FOUND_ON_PROHIBITVELY_SLOW_NETWORK = 11,
63 PAGE_NOT_FRESH_ON_PROHIBITVELY_SLOW_NETWORK = 12,
57 REDIRECT_RESULT_MAX, 64 REDIRECT_RESULT_MAX,
58 }; 65 };
59 66
60 ~OfflinePageTabHelper() override; 67 ~OfflinePageTabHelper() override;
61 68
62 const OfflinePageItem* offline_page() { return offline_page_.get(); } 69 const OfflinePageItem* offline_page() { return offline_page_.get(); }
63 70
71 // Allow tests to change the freshness of offline pages by using a custom
72 // clock.
73 void SetClockForTesting(std::unique_ptr<base::Clock> clock);
74
64 private: 75 private:
65 friend class content::WebContentsUserData<OfflinePageTabHelper>; 76 friend class content::WebContentsUserData<OfflinePageTabHelper>;
66 friend class OfflinePageTabHelperTest; 77 friend class OfflinePageTabHelperTest;
67 FRIEND_TEST_ALL_PREFIXES(OfflinePageTabHelperTest, 78 FRIEND_TEST_ALL_PREFIXES(OfflinePageTabHelperTest,
68 NewNavigationCancelsPendingRedirects); 79 NewNavigationCancelsPendingRedirects);
69 80
70 explicit OfflinePageTabHelper(content::WebContents* web_contents); 81 explicit OfflinePageTabHelper(content::WebContents* web_contents);
71 82
72 void SetDelegateForTesting(std::unique_ptr<Delegate> delegate); 83 void SetDelegateForTesting(std::unique_ptr<Delegate> delegate);
73 84
(...skipping 26 matching lines...) Expand all
100 // Returns true if a given URL is in redirect chain already. 111 // Returns true if a given URL is in redirect chain already.
101 bool IsInRedirectLoop(const GURL& to_url) const; 112 bool IsInRedirectLoop(const GURL& to_url) const;
102 113
103 void ReportRedirectResultUMA(RedirectResult result); 114 void ReportRedirectResultUMA(RedirectResult result);
104 115
105 // Iff the tab we are associated with is redirected to an offline page, 116 // Iff the tab we are associated with is redirected to an offline page,
106 // |offline_page_| will be non-null. This can be used to synchronously ask 117 // |offline_page_| will be non-null. This can be used to synchronously ask
107 // about the offline state of the current web contents. 118 // about the offline state of the current web contents.
108 std::unique_ptr<OfflinePageItem> offline_page_; 119 std::unique_ptr<OfflinePageItem> offline_page_;
109 std::unique_ptr<Delegate> delegate_; 120 std::unique_ptr<Delegate> delegate_;
121
122 // Typically the default Clock implementation, but can be overriden in tests.
123 std::unique_ptr<base::Clock> clock_;
124
110 base::WeakPtrFactory<OfflinePageTabHelper> weak_ptr_factory_; 125 base::WeakPtrFactory<OfflinePageTabHelper> weak_ptr_factory_;
111 126
112 DISALLOW_COPY_AND_ASSIGN(OfflinePageTabHelper); 127 DISALLOW_COPY_AND_ASSIGN(OfflinePageTabHelper);
113 }; 128 };
114 129
115 } // namespace offline_pages 130 } // namespace offline_pages
116 131
117 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_TAB_HELPER_H_ 132 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_TAB_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698