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

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

Issue 17571018: Reland fast tab closure behind a flag (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Diff against original patch Created 7 years, 6 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/ui/fast_unload_controller.cc
diff --git a/chrome/browser/ui/unload_controller.cc b/chrome/browser/ui/fast_unload_controller.cc
similarity index 83%
copy from chrome/browser/ui/unload_controller.cc
copy to chrome/browser/ui/fast_unload_controller.cc
index 5101ab823bbd4f70267caba6644abf8161aa5d91..ab66e7a9e024c9e8127d845436be1250c8cc7f27 100644
--- a/chrome/browser/ui/unload_controller.cc
+++ b/chrome/browser/ui/fast_unload_controller.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/unload_controller.h"
+#include "chrome/browser/ui/fast_unload_controller.h"
#include "base/logging.h"
#include "base/message_loop.h"
@@ -24,7 +24,7 @@ namespace chrome {
////////////////////////////////////////////////////////////////////////////////
// DetachedWebContentsDelegate will delete web contents when they close.
-class UnloadController::DetachedWebContentsDelegate
+class FastUnloadController::DetachedWebContentsDelegate
: public content::WebContentsDelegate {
public:
DetachedWebContentsDelegate() { }
@@ -38,7 +38,7 @@ class UnloadController::DetachedWebContentsDelegate
virtual void CloseContents(content::WebContents* source) OVERRIDE {
// Finished detached close.
- // UnloadController will observe
+ // FastUnloadController will observe
// |NOTIFICATION_WEB_CONTENTS_DISCONNECTED|.
delete source;
}
@@ -47,9 +47,9 @@ class UnloadController::DetachedWebContentsDelegate
};
////////////////////////////////////////////////////////////////////////////////
-// UnloadController, public:
+// FastUnloadController, public:
-UnloadController::UnloadController(Browser* browser)
+FastUnloadController::FastUnloadController(Browser* browser)
: browser_(browser),
tab_needing_before_unload_ack_(NULL),
is_attempting_to_close_browser_(false),
@@ -58,18 +58,18 @@ UnloadController::UnloadController(Browser* browser)
browser_->tab_strip_model()->AddObserver(this);
}
-UnloadController::~UnloadController() {
+FastUnloadController::~FastUnloadController() {
browser_->tab_strip_model()->RemoveObserver(this);
}
-bool UnloadController::CanCloseContents(content::WebContents* contents) {
+bool FastUnloadController::CanCloseContents(content::WebContents* contents) {
// Don't try to close the tab when the whole browser is being closed, since
// that avoids the fast shutdown path where we just kill all the renderers.
return !is_attempting_to_close_browser_;
}
-bool UnloadController::BeforeUnloadFired(content::WebContents* contents,
- bool proceed) {
+bool FastUnloadController::BeforeUnloadFired(content::WebContents* contents,
+ bool proceed) {
if (!is_attempting_to_close_browser_) {
if (!proceed) {
contents->SetClosedByUserGesture(false);
@@ -102,7 +102,7 @@ bool UnloadController::BeforeUnloadFired(content::WebContents* contents,
return true;
}
-bool UnloadController::ShouldCloseWindow() {
+bool FastUnloadController::ShouldCloseWindow() {
if (HasCompletedUnloadProcessing())
return true;
@@ -115,7 +115,7 @@ bool UnloadController::ShouldCloseWindow() {
return false;
}
-bool UnloadController::TabsNeedBeforeUnloadFired() {
+bool FastUnloadController::TabsNeedBeforeUnloadFired() {
if (!tabs_needing_before_unload_.empty() ||
tab_needing_before_unload_ack_ != NULL)
return true;
@@ -133,11 +133,12 @@ bool UnloadController::TabsNeedBeforeUnloadFired() {
}
////////////////////////////////////////////////////////////////////////////////
-// UnloadController, content::NotificationObserver implementation:
+// FastUnloadController, content::NotificationObserver implementation:
-void UnloadController::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
+void FastUnloadController::Observe(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
switch (type) {
case content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED: {
registrar_.Remove(this,
@@ -154,37 +155,37 @@ void UnloadController::Observe(int type,
}
////////////////////////////////////////////////////////////////////////////////
-// UnloadController, TabStripModelObserver implementation:
+// FastUnloadController, TabStripModelObserver implementation:
-void UnloadController::TabInsertedAt(content::WebContents* contents,
- int index,
- bool foreground) {
+void FastUnloadController::TabInsertedAt(content::WebContents* contents,
+ int index,
+ bool foreground) {
TabAttachedImpl(contents);
}
-void UnloadController::TabDetachedAt(content::WebContents* contents,
- int index) {
+void FastUnloadController::TabDetachedAt(content::WebContents* contents,
+ int index) {
TabDetachedImpl(contents);
}
-void UnloadController::TabReplacedAt(TabStripModel* tab_strip_model,
- content::WebContents* old_contents,
- content::WebContents* new_contents,
- int index) {
+void FastUnloadController::TabReplacedAt(TabStripModel* tab_strip_model,
+ content::WebContents* old_contents,
+ content::WebContents* new_contents,
+ int index) {
TabDetachedImpl(old_contents);
TabAttachedImpl(new_contents);
}
-void UnloadController::TabStripEmpty() {
+void FastUnloadController::TabStripEmpty() {
// Set is_attempting_to_close_browser_ here, so that extensions, etc, do not
// attempt to add tabs to the browser before it closes.
is_attempting_to_close_browser_ = true;
}
////////////////////////////////////////////////////////////////////////////////
-// UnloadController, private:
+// FastUnloadController, private:
-void UnloadController::TabAttachedImpl(content::WebContents* contents) {
+void FastUnloadController::TabAttachedImpl(content::WebContents* contents) {
// If the tab crashes in the beforeunload or unload handler, it won't be
// able to ack. But we know we can close it.
registrar_.Add(
@@ -193,7 +194,7 @@ void UnloadController::TabAttachedImpl(content::WebContents* contents) {
content::Source<content::WebContents>(contents));
}
-void UnloadController::TabDetachedImpl(content::WebContents* contents) {
+void FastUnloadController::TabDetachedImpl(content::WebContents* contents) {
if (tabs_needing_unload_ack_.find(contents) !=
tabs_needing_unload_ack_.end()) {
// Tab needs unload to complete.
@@ -217,7 +218,7 @@ void UnloadController::TabDetachedImpl(content::WebContents* contents) {
ClearUnloadState(contents);
}
-bool UnloadController::DetachWebContents(content::WebContents* contents) {
+bool FastUnloadController::DetachWebContents(content::WebContents* contents) {
int index = browser_->tab_strip_model()->GetIndexOfWebContents(contents);
if (index != TabStripModel::kNoTab &&
contents->NeedToFireBeforeUnload()) {
@@ -231,7 +232,7 @@ bool UnloadController::DetachWebContents(content::WebContents* contents) {
return false;
}
-void UnloadController::ProcessPendingTabs() {
+void FastUnloadController::ProcessPendingTabs() {
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
@@ -308,7 +309,7 @@ void UnloadController::ProcessPendingTabs() {
}
}
-bool UnloadController::HasCompletedUnloadProcessing() const {
+bool FastUnloadController::HasCompletedUnloadProcessing() const {
return is_attempting_to_close_browser_ &&
tabs_needing_before_unload_.empty() &&
tab_needing_before_unload_ack_ == NULL &&
@@ -316,7 +317,7 @@ bool UnloadController::HasCompletedUnloadProcessing() const {
tabs_needing_unload_ack_.empty();
}
-void UnloadController::CancelWindowClose() {
+void FastUnloadController::CancelWindowClose() {
// Closing of window can be canceled from a beforeunload handler.
DCHECK(is_attempting_to_close_browser_);
tabs_needing_before_unload_.clear();
@@ -346,7 +347,7 @@ void UnloadController::CancelWindowClose() {
content::NotificationService::NoDetails());
}
-void UnloadController::ClearUnloadState(content::WebContents* contents) {
+void FastUnloadController::ClearUnloadState(content::WebContents* contents) {
if (tabs_needing_unload_ack_.erase(contents) > 0) {
if (HasCompletedUnloadProcessing())
PostTaskForProcessPendingTabs();
@@ -369,10 +370,10 @@ void UnloadController::ClearUnloadState(content::WebContents* contents) {
}
}
-void UnloadController::PostTaskForProcessPendingTabs() {
+void FastUnloadController::PostTaskForProcessPendingTabs() {
base::MessageLoop::current()->PostTask(
FROM_HERE,
- base::Bind(&UnloadController::ProcessPendingTabs,
+ base::Bind(&FastUnloadController::ProcessPendingTabs,
weak_factory_.GetWeakPtr()));
}

Powered by Google App Engine
This is Rietveld 408576698