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

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 11016023: Quickly close tabs/window with long-running unload handlers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Keep original TabsNeedBeforeUnloadFired implementation. Created 8 years, 1 month 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: content/browser/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 3408d0ac25759ae0bc6c71969f58b02b2665a53a..f2b612c77bed8c1f5a9ae8d3a9b361497008ab59 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -358,11 +358,17 @@ WebContentsImpl::~WebContentsImpl() {
// OnCloseStarted isn't called in unit tests.
if (!close_start_time_.is_null()) {
base::TimeTicks now = base::TimeTicks::Now();
+ base::TimeDelta close_time = now - close_start_time_;
+ UMA_HISTOGRAM_TIMES("Tab.Close", close_time);
+
base::TimeTicks unload_start_time = close_start_time_;
+ base::TimeTicks unload_end_time = now;
if (!before_unload_end_time_.is_null())
unload_start_time = before_unload_end_time_;
- UMA_HISTOGRAM_TIMES("Tab.Close", now - close_start_time_);
- UMA_HISTOGRAM_TIMES("Tab.Close.UnloadTime", now - unload_start_time);
+ if (!unload_detached_start_time_.is_null())
+ unload_end_time = unload_detached_start_time_;
+ base::TimeDelta unload_time = unload_end_time - unload_start_time;
+ UMA_HISTOGRAM_TIMES("Tab.Close.UnloadTime", unload_time);
}
FOR_EACH_OBSERVER(WebContentsObserver,
@@ -1743,6 +1749,21 @@ void WebContentsImpl::OnCloseStarted() {
close_start_time_ = base::TimeTicks::Now();
}
+void WebContentsImpl::OnCloseCanceled() {
+ close_start_time_ = base::TimeTicks();
+ before_unload_end_time_ = base::TimeTicks();
+ unload_detached_start_time_ = base::TimeTicks();
+}
+
+void WebContentsImpl::OnUnloadStarted() {
+ before_unload_end_time_ = base::TimeTicks::Now();
+}
+
+void WebContentsImpl::OnUnloadDetachedStarted() {
+ if (unload_detached_start_time_.is_null())
+ unload_detached_start_time_ = base::TimeTicks::Now();
+}
+
bool WebContentsImpl::ShouldAcceptDragAndDrop() const {
#if defined(OS_CHROMEOS)
// ChromeOS panels (pop-ups) do not take drag-n-drop.
@@ -3270,9 +3291,7 @@ void WebContentsImpl::OnDialogClosed(RenderViewHost* rvh,
// spinning, since we forced it to start spinning in Navigate.
DidStopLoading(rvh);
controller_.DiscardNonCommittedEntries();
-
- close_start_time_ = base::TimeTicks();
- before_unload_end_time_ = base::TimeTicks();
+ OnCloseCanceled();
}
is_showing_before_unload_dialog_ = false;
static_cast<RenderViewHostImpl*>(

Powered by Google App Engine
This is Rietveld 408576698