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

Unified Diff: components/offline_pages/offline_page_model.h

Issue 1959393002: Choose the best offline page when given an online URL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address nits. Created 4 years, 7 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: components/offline_pages/offline_page_model.h
diff --git a/components/offline_pages/offline_page_model.h b/components/offline_pages/offline_page_model.h
index 90ed8bfbe1ad4a2b63a99b0904d76cee594b186d..3b3ead1dce0453073b41fd3ae7f826c65db81303 100644
--- a/components/offline_pages/offline_page_model.h
+++ b/components/offline_pages/offline_page_model.h
@@ -242,9 +242,19 @@ class OfflinePageModel : public KeyedService, public base::SupportsUserData {
void GetPagesByOnlineURL(const GURL& online_url,
const MultipleOfflinePageItemCallback& callback);
+ // Returns via callback an offline page saved for |online_url|, if any. The
+ // best page is chosen based on creation date; a more recently created offline
+ // page will be preferred over an older one. This API function does not
+ // respect namespaces, as it is used to choose which page is rendered in a
+ // tab. Today all namespaces are treated equally for the purposes of this
+ // selection.
+ void GetBestPageForOnlineURL(const GURL& online_url,
+ const SingleOfflinePageItemCallback callback);
+
// Returns an offline page saved for |online_url|. A nullptr is returned if
- // not found.
- const OfflinePageItem* MaybeGetPageByOnlineURL(const GURL& online_url) const;
+ // not found. See |GetBestPageForOnlineURL| for selection criteria.
+ const OfflinePageItem* MaybeGetBestPageForOnlineURL(
+ const GURL& online_url) const;
// Checks that all of the offline pages have corresponding offline copies.
// If a page is discovered to be missing an offline copy, its offline page
@@ -305,6 +315,9 @@ class OfflinePageModel : public KeyedService, public base::SupportsUserData {
void GetPageByOfflineURLWhenLoadDone(
const GURL& offline_url,
const SingleOfflinePageItemCallback& callback) const;
+ void GetBestPageForOnlineURLWhenLoadDone(
+ const GURL& online_url,
+ const SingleOfflinePageItemCallback& callback) const;
// Callback for checking whether we have offline pages.
void HasPagesAfterLoadDone(const std::string& name_space,
« no previous file with comments | « chrome/browser/android/offline_pages/offline_page_utils.cc ('k') | components/offline_pages/offline_page_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698