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

Unified Diff: components/offline_pages/offline_page_model_impl.cc

Issue 2484223005: Store original request URL in offline page metadata table (Closed)
Patch Set: Address feedback 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 577dd26082d8e6984fbfcf1c5a1afeda6ae89955..f29a2c25c8c898fce1b3502fcb8e8a0d8e8464c1 100644
--- a/components/offline_pages/offline_page_model_impl.cc
+++ b/components/offline_pages/offline_page_model_impl.cc
@@ -335,37 +335,36 @@ void OfflinePageModelImpl::RemoveObserver(Observer* observer) {
}
void OfflinePageModelImpl::SavePage(
- const GURL& url,
- const ClientId& client_id,
- int64_t proposed_offline_id,
+ const SavePageParams& save_page_params,
std::unique_ptr<OfflinePageArchiver> archiver,
const SavePageCallback& callback) {
DCHECK(is_loaded_);
// Skip saving the page that is not intended to be saved, like local file
// page.
- if (!OfflinePageModel::CanSaveURL(url)) {
- InformSavePageDone(callback, SavePageResult::SKIPPED, client_id,
- kInvalidOfflineId);
+ if (!OfflinePageModel::CanSaveURL(save_page_params.url)) {
+ InformSavePageDone(callback, SavePageResult::SKIPPED,
+ save_page_params.client_id, kInvalidOfflineId);
return;
}
// The web contents is not available if archiver is not created and passed.
if (!archiver.get()) {
- InformSavePageDone(callback, SavePageResult::CONTENT_UNAVAILABLE, client_id,
- kInvalidOfflineId);
+ InformSavePageDone(callback, SavePageResult::CONTENT_UNAVAILABLE,
+ save_page_params.client_id, kInvalidOfflineId);
return;
}
// If we already have an offline id, use it. If not, generate one.
- if (proposed_offline_id == kInvalidOfflineId)
- proposed_offline_id = GenerateOfflineId();
+ int64_t offline_id = save_page_params.proposed_offline_id;
+ if (offline_id == kInvalidOfflineId)
+ offline_id = GenerateOfflineId();
archiver->CreateArchive(
- archives_dir_, proposed_offline_id,
+ archives_dir_, offline_id,
base::Bind(&OfflinePageModelImpl::OnCreateArchiveDone,
- weak_ptr_factory_.GetWeakPtr(), url, proposed_offline_id,
- client_id, GetCurrentTime(), callback));
+ weak_ptr_factory_.GetWeakPtr(), save_page_params, offline_id,
+ GetCurrentTime(), callback));
pending_archivers_.push_back(std::move(archiver));
}
@@ -726,36 +725,38 @@ OfflineEventLogger* OfflinePageModelImpl::GetLogger() {
return &offline_event_logger_;
}
-void OfflinePageModelImpl::OnCreateArchiveDone(const GURL& requested_url,
- int64_t offline_id,
- const ClientId& client_id,
- const base::Time& start_time,
- const SavePageCallback& callback,
- OfflinePageArchiver* archiver,
- ArchiverResult archiver_result,
- const GURL& url,
- const base::FilePath& file_path,
- const base::string16& title,
- int64_t file_size) {
- if (requested_url != url) {
+void OfflinePageModelImpl::OnCreateArchiveDone(
+ const SavePageParams& save_page_params,
+ int64_t offline_id,
+ const base::Time& start_time,
+ const SavePageCallback& callback,
+ OfflinePageArchiver* archiver,
+ ArchiverResult archiver_result,
+ const GURL& url,
+ const base::FilePath& file_path,
+ const base::string16& title,
+ int64_t file_size) {
+ if (save_page_params.url != url) {
DVLOG(1) << "Saved URL does not match requested URL.";
// TODO(fgorski): We have created an archive for a wrong URL. It should be
// deleted from here, once archiver has the right functionality.
InformSavePageDone(callback, SavePageResult::ARCHIVE_CREATION_FAILED,
- client_id, offline_id);
+ save_page_params.client_id, offline_id);
DeletePendingArchiver(archiver);
return;
}
if (archiver_result != ArchiverResult::SUCCESSFULLY_CREATED) {
SavePageResult result = ToSavePageResult(archiver_result);
- InformSavePageDone(callback, result, client_id, offline_id);
+ InformSavePageDone(
+ callback, result, save_page_params.client_id, offline_id);
DeletePendingArchiver(archiver);
return;
}
- OfflinePageItem offline_page_item(url, offline_id, client_id, file_path,
- file_size, start_time);
+ OfflinePageItem offline_page_item(url, offline_id, save_page_params.client_id,
+ file_path, file_size, start_time);
offline_page_item.title = title;
+ offline_page_item.original_url = save_page_params.original_url;
store_->AddOfflinePage(offline_page_item,
base::Bind(&OfflinePageModelImpl::OnAddOfflinePageDone,
weak_ptr_factory_.GetWeakPtr(), archiver,
« no previous file with comments | « components/offline_pages/offline_page_model_impl.h ('k') | components/offline_pages/offline_page_model_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698