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

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: Rebase after base change landed. 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 a4afe4299742d0f2090280ed835ee92c992d38d8..191754d8f56833e26d8c2f413394db8cecaa924f 100644
--- a/chrome/browser/android/offline_pages/recent_tab_helper.cc
+++ b/chrome/browser/android/offline_pages/recent_tab_helper.cc
@@ -270,10 +270,11 @@ void RecentTabHelper::WasHidden() {
// 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_) {
+ 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_
+ << !!last_n_ongoing_snapshot_info_ << ", " << tab_is_closing_
<< ") for: " << web_contents()->GetLastCommittedURL().spec();
return;
}
@@ -300,6 +301,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