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

Unified Diff: components/offline_pages/core/snapshot_controller.cc

Issue 2602473004: Offline Page Cache uses user interaction triggers for saving pages. (Closed)
Patch Set: Minor changes. Created 3 years, 11 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/core/snapshot_controller.cc
diff --git a/components/offline_pages/core/snapshot_controller.cc b/components/offline_pages/core/snapshot_controller.cc
index aa0b4270b0231bd28701289a48a6b4c76ee9fabc..4f7d3370e09127f3ca2bbb87bd7a9e2e7a3b544d 100644
--- a/components/offline_pages/core/snapshot_controller.cc
+++ b/components/offline_pages/core/snapshot_controller.cc
@@ -53,6 +53,7 @@ void SnapshotController::Reset() {
// Cancel potentially delayed tasks that relate to the previous 'session'.
weak_ptr_factory_.InvalidateWeakPtrs();
state_ = State::READY;
+ current_page_quality_ = PageQuality::POOR;
}
void SnapshotController::Stop() {
@@ -68,10 +69,12 @@ void SnapshotController::PendingSnapshotCompleted() {
}
void SnapshotController::DocumentAvailableInMainFrame() {
+ DCHECK_EQ(PageQuality::POOR, current_page_quality_);
// Post a delayed task to snapshot.
task_runner_->PostDelayedTask(
FROM_HERE, base::Bind(&SnapshotController::MaybeStartSnapshot,
- weak_ptr_factory_.GetWeakPtr()),
+ weak_ptr_factory_.GetWeakPtr(),
+ PageQuality::FAIR_AND_IMPROVING),
base::TimeDelta::FromMilliseconds(delay_after_document_available_ms_));
}
@@ -84,15 +87,17 @@ void SnapshotController::DocumentOnLoadCompletedInMainFrame() {
delay_after_document_on_load_completed_ms_));
}
-void SnapshotController::MaybeStartSnapshot() {
+void SnapshotController::MaybeStartSnapshot(PageQuality updated_page_quality) {
if (state_ != State::READY)
return;
+ DCHECK_LT(current_page_quality_, updated_page_quality);
+ current_page_quality_ = updated_page_quality;
state_ = State::SNAPSHOT_PENDING;
client_->StartSnapshot();
}
void SnapshotController::MaybeStartSnapshotThenStop() {
- MaybeStartSnapshot();
+ MaybeStartSnapshot(PageQuality::HIGH);
Stop();
}

Powered by Google App Engine
This is Rietveld 408576698