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

Unified Diff: chrome/browser/ui/unload_controller.cc

Issue 2695233003: Fix unload controller. (Closed)
Patch Set: Fix review note. 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
« no previous file with comments | « chrome/browser/lifetime/browser_close_manager_browsertest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/unload_controller.cc
diff --git a/chrome/browser/ui/unload_controller.cc b/chrome/browser/ui/unload_controller.cc
index 8da59883131c958fbd7a16fe9daa400225b43eb7..7a30244ff82a5b5d2a596bc747714e12bc18e913 100644
--- a/chrome/browser/ui/unload_controller.cc
+++ b/chrome/browser/ui/unload_controller.cc
@@ -291,6 +291,9 @@ void UnloadController::TabDetachedImpl(content::WebContents* contents) {
}
void UnloadController::ProcessPendingTabs() {
+ // Cancel posted/queued ProcessPendingTabs task if there is any.
+ weak_factory_.InvalidateWeakPtrs();
+
if (!is_attempting_to_close_browser_) {
// Because we might invoke this after a delay it's possible for the value of
// is_attempting_to_close_browser_ to have changed since we scheduled the
@@ -298,7 +301,7 @@ void UnloadController::ProcessPendingTabs() {
return;
}
- if (HasCompletedUnloadProcessing()) {
+ if (HasCompletedUnloadProcessing() && !TabsNeedBeforeUnloadFired()) {
// We've finished all the unload events and can proceed to close the
// browser.
browser_->OnWindowClosing();
@@ -379,6 +382,9 @@ void UnloadController::ClearUnloadState(content::WebContents* web_contents,
if (process_now) {
ProcessPendingTabs();
} else {
+ // Do not post a new task if there is already any.
+ if (weak_factory_.HasWeakPtrs())
+ return;
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::Bind(&UnloadController::ProcessPendingTabs,
weak_factory_.GetWeakPtr()));
« no previous file with comments | « chrome/browser/lifetime/browser_close_manager_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698