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

Unified Diff: components/offline_pages/offline_page_model_impl.cc

Issue 2503853004: Support getting offline pages also by original URL (Closed)
Patch Set: Rebase Created 4 years, 1 month 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_impl.cc
diff --git a/components/offline_pages/offline_page_model_impl.cc b/components/offline_pages/offline_page_model_impl.cc
index 094dab25e128153b166610e74db5f884e2a17c93..6cec9f511558c8903c5f62d01c39b920f83b3333 100644
--- a/components/offline_pages/offline_page_model_impl.cc
+++ b/components/offline_pages/offline_page_model_impl.cc
@@ -608,35 +608,39 @@ void OfflinePageModelImpl::GetPageByOfflineId(
multiple_callback));
}
-void OfflinePageModelImpl::GetPagesByOnlineURL(
- const GURL& online_url,
+void OfflinePageModelImpl::GetPagesByURL(
+ const GURL& url,
+ bool search_by_final_url_only,
const MultipleOfflinePageItemCallback& callback) {
RunWhenLoaded(
- base::Bind(&OfflinePageModelImpl::GetPagesByOnlineURLWhenLoadDone,
- weak_ptr_factory_.GetWeakPtr(), online_url, callback));
+ base::Bind(&OfflinePageModelImpl::GetPagesByURLWhenLoadDone,
+ weak_ptr_factory_.GetWeakPtr(), url,
+ search_by_final_url_only, callback));
}
-void OfflinePageModelImpl::GetPagesByOnlineURLWhenLoadDone(
- const GURL& online_url,
+void OfflinePageModelImpl::GetPagesByURLWhenLoadDone(
+ const GURL& url,
+ bool search_by_final_url_only,
const MultipleOfflinePageItemCallback& callback) const {
std::vector<OfflinePageItem> result;
GURL::Replacements remove_params;
remove_params.ClearRef();
- GURL online_url_without_fragment =
- online_url.ReplaceComponents(remove_params);
+ GURL url_without_fragment = url.ReplaceComponents(remove_params);
for (const auto& id_page_pair : offline_pages_) {
if (id_page_pair.second.IsExpired())
continue;
- if (online_url == id_page_pair.second.url) {
+ if (url == id_page_pair.second.url ||
fgorski 2016/11/16 23:43:46 this does exact matching, whereas outside of this
jianli 2016/11/17 01:12:14 With more thought, changed to also search against
+ (!search_by_final_url_only && url ==
+ id_page_pair.second.original_url)) {
result.push_back(id_page_pair.second);
continue;
}
// If the full URL does not match, try with the fragment identifier
// stripped.
- if (online_url_without_fragment ==
+ if (url_without_fragment ==
id_page_pair.second.url.ReplaceComponents(remove_params)) {
result.push_back(id_page_pair.second);
}
@@ -877,8 +881,9 @@ void OfflinePageModelImpl::DeleteExistingPagesWithSameURL(
.pages_allowed_per_url;
if (pages_allowed == kUnlimitedPages)
return;
- GetPagesByOnlineURL(
+ GetPagesByURL(
offline_page.url,
+ true /* search_by_final_url_only */,
base::Bind(&OfflinePageModelImpl::OnPagesFoundWithSameURL,
weak_ptr_factory_.GetWeakPtr(), offline_page, pages_allowed));
}

Powered by Google App Engine
This is Rietveld 408576698