diff options
Diffstat (limited to 'content/browser/web_contents')
-rw-r--r-- | content/browser/web_contents/web_contents_impl.cc | 52 | ||||
-rw-r--r-- | content/browser/web_contents/web_contents_impl.h | 18 |
2 files changed, 65 insertions, 5 deletions
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index 6ab5f2f..5ac82c8 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -397,6 +397,23 @@ WebContentsImpl::~WebContentsImpl() { } #endif + // 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_; + 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, observers_, WebContentsImplDestroyed()); @@ -1934,10 +1951,38 @@ RendererPreferences* WebContentsImpl::GetMutableRendererPrefs() { return &renderer_preferences_; } +void WebContentsImpl::SetNewTabStartTime(const base::TimeTicks& time) { + new_tab_start_time_ = time; +} + +base::TimeTicks WebContentsImpl::GetNewTabStartTime() const { + return new_tab_start_time_; +} + void WebContentsImpl::Close() { Close(GetRenderViewHost()); } +void WebContentsImpl::OnCloseStarted() { + if (close_start_time_.is_null()) + 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()) @@ -3460,10 +3505,9 @@ void WebContentsImpl::WorkerCrashed() { void WebContentsImpl::BeforeUnloadFiredFromRenderManager( bool proceed, const base::TimeTicks& proceed_time, bool* proceed_to_fire_unload) { + before_unload_end_time_ = proceed_time; if (delegate_) delegate_->BeforeUnloadFired(this, proceed, proceed_to_fire_unload); - FOR_EACH_OBSERVER(WebContentsObserver, observers_, - BeforeUnloadFired(proceed_time)); } void WebContentsImpl::RenderViewGoneFromRenderManager( @@ -3603,9 +3647,7 @@ void WebContentsImpl::OnDialogClosed(RenderViewHost* rvh, // spinning, since we forced it to start spinning in Navigate. DidStopLoading(rvh); controller_.DiscardNonCommittedEntries(); - - FOR_EACH_OBSERVER(WebContentsObserver, observers_, - BeforeUnloadDialogCancelled()); + OnCloseCanceled(); } is_showing_before_unload_dialog_ = false; static_cast<RenderViewHostImpl*>( diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h index 0b6c36a..f18b7c4 100644 --- a/content/browser/web_contents/web_contents_impl.h +++ b/content/browser/web_contents/web_contents_impl.h @@ -264,7 +264,13 @@ class CONTENT_EXPORT WebContentsImpl virtual void SetOverrideEncoding(const std::string& encoding) OVERRIDE; virtual void ResetOverrideEncoding() OVERRIDE; virtual RendererPreferences* GetMutableRendererPrefs() OVERRIDE; + virtual void SetNewTabStartTime(const base::TimeTicks& time) OVERRIDE; + virtual base::TimeTicks GetNewTabStartTime() const OVERRIDE; virtual void Close() OVERRIDE; + virtual void OnCloseStarted() OVERRIDE; + virtual void OnCloseCanceled() OVERRIDE; + virtual void OnUnloadStarted() OVERRIDE; + virtual void OnUnloadDetachedStarted() OVERRIDE; virtual void SystemDragEnded() OVERRIDE; virtual void UserGestureDone() OVERRIDE; virtual void SetClosedByUserGesture(bool value) OVERRIDE; @@ -862,6 +868,18 @@ class CONTENT_EXPORT WebContentsImpl // Settings that get passed to the renderer process. RendererPreferences renderer_preferences_; + // The time that we started to create the new tab page. + base::TimeTicks new_tab_start_time_; + + // The time that we started to close this WebContents. + base::TimeTicks close_start_time_; + + // The time when onbeforeunload ended. + base::TimeTicks before_unload_end_time_; + + // The time when the tab was removed from view during close. + base::TimeTicks unload_detached_start_time_; + // The time that this tab was last selected. base::TimeTicks last_selected_time_; |