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 ea88e0c8b8a00743fe05980826b621c3e951308c..6c8f28a2162495cb116ff7f6110830f190959481 100644 |
--- a/content/browser/web_contents/web_contents_impl.cc |
+++ b/content/browser/web_contents/web_contents_impl.cc |
@@ -8,6 +8,7 @@ |
#include "base/command_line.h" |
#include "base/lazy_instance.h" |
+#include "base/logging.h" |
#include "base/metrics/histogram.h" |
#include "base/metrics/stats_counters.h" |
#include "base/string16.h" |
@@ -398,11 +399,18 @@ 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, |
@@ -1930,6 +1938,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(); |
+} |
+ |
void WebContentsImpl::DragSourceEndedAt(int client_x, int client_y, |
int screen_x, int screen_y, WebKit::WebDragOperation operation) { |
if (browser_plugin_embedder_.get()) |
@@ -3583,9 +3606,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*>( |