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

Unified Diff: chrome/browser/android/offline_pages/recent_tab_helper.cc

Issue 2561163002: Fix snapshots from Downloads being deleted by last_n. (Closed)
Patch Set: Minor test simplification. Created 4 years 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/recent_tab_helper.cc
diff --git a/chrome/browser/android/offline_pages/recent_tab_helper.cc b/chrome/browser/android/offline_pages/recent_tab_helper.cc
index 9863079958f565624cd0d3be5cc64406afeee76e..cdc9d8445dbe024e9c4cb61bc473ea53ec4da73b 100644
--- a/chrome/browser/android/offline_pages/recent_tab_helper.cc
+++ b/chrome/browser/android/offline_pages/recent_tab_helper.cc
@@ -59,7 +59,6 @@ RecentTabHelper::RecentTabHelper(content::WebContents* web_contents)
page_model_(nullptr),
snapshots_enabled_(false),
is_page_ready_for_snapshot_(false),
- previous_request_id_for_load_(OfflinePageModel::kInvalidOfflineId),
delegate_(new DefaultDelegate()),
weak_ptr_factory_(this) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
@@ -160,7 +159,6 @@ void RecentTabHelper::DidFinishNavigation(
}
is_page_ready_for_snapshot_ = false;
- previous_request_id_for_load_ = OfflinePageModel::kInvalidOfflineId;
// New navigation, new snapshot session.
snapshot_url_ = web_contents()->GetLastCommittedURL();
@@ -226,17 +224,9 @@ void RecentTabHelper::ContinueSnapshotWithIdsToPurge(
if (!download_info_)
return;
- std::vector<int64_t> ids(page_ids);
// Also remove the download page if this is not a first snapshot.
+ std::vector<int64_t> ids(page_ids);
ids.push_back(download_info_->request_id_);
- // Do not delete a previous save from the same page load right now as it's
- // unknown at this point in time if this snapshot will succeed.
- for (auto it = ids.begin(); it != ids.end(); ++it) {
- if (*it == previous_request_id_for_load_) {
- ids.erase(it);
- break;
- }
- }
page_model_->DeletePagesByOfflineId(
ids, base::Bind(&RecentTabHelper::ContinueSnapshotAfterPurge,
@@ -268,30 +258,6 @@ void RecentTabHelper::SavePageCallback(OfflinePageModel::SavePageResult result,
return;
download_info_->page_snapshot_completed_ =
(result == SavePageResult::SUCCESS);
-
- if (download_info_->page_snapshot_completed_) {
- int64_t previous_request_id = previous_request_id_for_load_;
- previous_request_id_for_load_ = offline_id;
-
- // If there is a previous snapshot saved during the same page load it must
- // be deleted before finishing the snapshot process.
- if (previous_request_id != OfflinePageModel::kInvalidOfflineId) {
- std::vector<int64_t> page_id = {previous_request_id};
- page_model_->DeletePagesByOfflineId(
- page_id, base::Bind(&RecentTabHelper::PreviousSaveWasPurged,
- weak_ptr_factory_.GetWeakPtr()));
- return;
- }
- }
-
- ReportSnapshotCompleted();
-}
-
-void RecentTabHelper::PreviousSaveWasPurged(
- OfflinePageModel::DeletePageResult result) {
- if (!download_info_)
- return;
-
ReportSnapshotCompleted();
}

Powered by Google App Engine
This is Rietveld 408576698