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

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

Issue 2705323006: Last_n: Do not save a snapshot of a closing tab. (Closed)
Patch Set: Minor comment changes. Created 3 years, 10 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: 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 a2019a31586b8f1c5fda136110dfc058743c1c1f..3e9bc62f549c6bf009ede639f2cfbd7faea9c02d 100644
--- a/chrome/browser/android/offline_pages/recent_tab_helper.cc
+++ b/chrome/browser/android/offline_pages/recent_tab_helper.cc
@@ -247,10 +247,16 @@ void RecentTabHelper::WasHidden() {
if (!IsOffliningRecentPagesEnabled())
return;
- // Return immediately if last_n is not listening to tab hidden events or if a
- // last_n snapshot is currently being saved.
- if (!last_n_listen_to_tab_hidden_ || last_n_ongoing_snapshot_info_)
+ // Return immediately if last_n is not listening to tab hidden events, if a
+ // last_n snapshot is currently being saved or if the tab is closing.
+ if (!last_n_listen_to_tab_hidden_ || last_n_ongoing_snapshot_info_ ||
+ tab_is_closing) {
+ DVLOG(1) << "Will not snapshot for last_n (reasons: "
+ << !last_n_listen_to_tab_hidden_ << ", "
+ << !!last_n_ongoing_snapshot_info_ << ", " << tab_is_closing
+ << ") for: " << web_contents()->GetLastCommittedURL().spec();
return;
+ }
// Do not save if page quality is too low.
// Note: we assume page quality for a page can only increase.
@@ -269,6 +275,19 @@ void RecentTabHelper::WasHidden() {
last_n_ongoing_snapshot_info_.get()));
}
+void RecentTabHelper::WasShown() {
+ // If the tab was closing and is now being shown, the closure was reverted.
+ DVLOG_IF(0, tab_is_closing) << "Tab is not closing anymore: "
+ << web_contents()->GetLastCommittedURL().spec();
+ tab_is_closing = false;
+}
+
+void RecentTabHelper::WillCloseTab() {
+ DVLOG(1) << "Tab is now closing: "
+ << web_contents()->GetLastCommittedURL().spec();
+ tab_is_closing = true;
+}
+
// TODO(carlosk): rename this to RequestSnapshot and make it return a bool
// representing the acceptance of the snapshot request.
void RecentTabHelper::StartSnapshot() {

Powered by Google App Engine
This is Rietveld 408576698