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

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

Issue 2337363002: Load live version when reloading an offline page on connected network (Closed)
Patch Set: Update BUILD.gn Created 4 years, 3 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 717dc040cff622a34d46e70551e9cb2f7cf8758d..8ded15dff9f73a0f2da25095d9520ed0315bb29d 100644
--- a/chrome/browser/android/offline_pages/offline_page_tab_helper.h
+++ b/chrome/browser/android/offline_pages/offline_page_tab_helper.h
@@ -8,6 +8,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
+#include "components/offline_pages/request_header/offline_page_header.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
#include "url/gurl.h"
@@ -28,12 +29,20 @@ class OfflinePageTabHelper :
public:
~OfflinePageTabHelper() override;
- const OfflinePageItem* offline_page() { return offline_page_.get(); }
void SetOfflinePage(const OfflinePageItem& offline_page,
+ const OfflinePageHeader& offline_header,
bool is_offline_preview);
+ const OfflinePageItem* offline_page() {
+ return offline_info_.offline_page.get();
+ }
+
+ const OfflinePageHeader& offline_header() const {
+ return offline_info_.offline_header;
+ }
+
// Whether the page is an offline preview.
- bool is_offline_preview() const { return is_offline_preview_; }
+ bool is_offline_preview() const { return offline_info_.is_offline_preview; }
// Returns provisional offline page since actual navigation does not happen
// during unit tests.
@@ -42,6 +51,24 @@ class OfflinePageTabHelper :
private:
friend class content::WebContentsUserData<OfflinePageTabHelper>;
+ // Contains the info about the offline page being loaded.
+ struct LoadedOfflinePageInfo {
+ LoadedOfflinePageInfo();
+ ~LoadedOfflinePageInfo();
+
+ // The cached copy of OfflinePageItem.
+ std::unique_ptr<OfflinePageItem> offline_page;
+
+ // The offline header that is provided when offline page is loaded.
+ OfflinePageHeader offline_header;
+
+ // Whether the page is an offline preview. Offline page previews are shown
+ // when a user's effective connection type is prohibitively slow.
+ bool is_offline_preview;
+
+ void Clear();
+ };
+
explicit OfflinePageTabHelper(content::WebContents* web_contents);
// Overridden from content::WebContentsObserver:
@@ -52,22 +79,19 @@ class OfflinePageTabHelper :
void SelectPageForOnlineURLDone(const OfflinePageItem* offline_page);
- // The cached copy of OfflinePageItem if offline page is loaded for current
- // tab. This can be used to by the Tab to synchronously ask about the offline
+ // The provisional info about the offline page being loaded. This is set when
+ // the offline interceptor decides to serve the offline page and it will be
+ // moved to |offline_info_| once the navigation is committed without error.
+ LoadedOfflinePageInfo provisional_offline_info_;
+
+ // The info about offline page being loaded. This is set from
+ // |provisional_offline_info_| when the navigation is committed without error.
+ // This can be used to by the Tab to synchronously ask about the offline
// info.
- std::unique_ptr<OfflinePageItem> offline_page_;
- // Potential new offline page copy. This is reset to nullptr at the start
- // of every navigation and set by network request interceptor. If the
- // interceptor decided to not use offline page for the navigation or was not
- // even invoked (as in case with fragment navigation), this stays nullptr.
- std::unique_ptr<OfflinePageItem> provisional_offline_page_;
+ LoadedOfflinePageInfo offline_info_;
bool reloading_url_on_net_error_ = false;
- // Whether the page is an offline preview. Offline page previews are shown
- // when a user's effective connection type is prohibitively slow.
- bool is_offline_preview_;
-
base::WeakPtrFactory<OfflinePageTabHelper> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(OfflinePageTabHelper);

Powered by Google App Engine
This is Rietveld 408576698