From 8ee4c890d168395f0bd19270185928b58567b9e1 Mon Sep 17 00:00:00 2001
From: "wez@chromium.org"
 <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Date: Wed, 19 Jun 2013 00:59:06 +0000
Subject: Revert 207120 "Move histograms and supporting code that don't be..."

The CL appears to break NoSessionRestoreTest.SessionStorage, CookiesClearedOnExit and LocalStorageClearedOnExit browser tests under ASAN.

> Move histograms and supporting code that don't belong in content out.
>
> R=avi@chromium.org
>
> Review URL: https://codereview.chromium.org/17151010

TBR=jam@chromium.org

Review URL: https://codereview.chromium.org/17438006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207134 0039d316-1c4b-4281-b951-d872f2087c98
---
 chrome/browser/ui/browser_tabstrip.cc              |  5 +--
 .../ui/cocoa/applescript/window_applescript.mm     |  8 +---
 chrome/browser/ui/tab_contents/core_tab_helper.cc  | 48 --------------------
 chrome/browser/ui/tab_contents/core_tab_helper.h   | 46 ++-----------------
 chrome/browser/ui/tabs/tab_strip_model.cc          |  4 +-
 chrome/browser/ui/unload_controller.cc             | 22 +++------
 chrome/browser/ui/unload_controller.h              |  2 +-
 chrome/browser/ui/webui/metrics_handler.cc         | 10 ++---
 content/browser/web_contents/web_contents_impl.cc  | 52 +++++++++++++++++++---
 content/browser/web_contents/web_contents_impl.h   | 18 ++++++++
 content/public/browser/web_contents.h              | 21 +++++++++
 content/public/browser/web_contents_observer.h     |  6 ---
 12 files changed, 102 insertions(+), 140 deletions(-)

diff --git a/chrome/browser/ui/browser_tabstrip.cc b/chrome/browser/ui/browser_tabstrip.cc
index 9ffa615..aa308e0 100644
--- a/chrome/browser/ui/browser_tabstrip.cc
+++ b/chrome/browser/ui/browser_tabstrip.cc
@@ -9,7 +9,6 @@
 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
 #include "chrome/browser/ui/browser.h"
 #include "chrome/browser/ui/browser_navigator.h"
-#include "chrome/browser/ui/tab_contents/core_tab_helper.h"
 #include "chrome/browser/ui/tabs/tab_strip_model.h"
 #include "chrome/common/chrome_switches.h"
 #include "chrome/common/url_constants.h"
@@ -29,9 +28,7 @@ void AddBlankTabAt(Browser* browser, int index, bool foreground) {
   params.disposition = foreground ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB;
   params.tabstrip_index = index;
   chrome::Navigate(&params);
-  CoreTabHelper* core_tab_helper =
-      CoreTabHelper::FromWebContents(params.target_contents);
-  core_tab_helper->set_new_tab_start_time(new_tab_start_time);
+  params.target_contents->SetNewTabStartTime(new_tab_start_time);
 }
 
 content::WebContents* AddSelectedTabWithURL(
diff --git a/chrome/browser/ui/cocoa/applescript/window_applescript.mm b/chrome/browser/ui/cocoa/applescript/window_applescript.mm
index fe6677f..fe9e055 100644
--- a/chrome/browser/ui/cocoa/applescript/window_applescript.mm
+++ b/chrome/browser/ui/cocoa/applescript/window_applescript.mm
@@ -21,7 +21,6 @@
 #include "chrome/browser/ui/cocoa/applescript/error_applescript.h"
 #import "chrome/browser/ui/cocoa/applescript/tab_applescript.h"
 #include "chrome/browser/ui/host_desktop.h"
-#include "chrome/browser/ui/tab_contents/core_tab_helper.h"
 #include "chrome/browser/ui/tabs/tab_strip_model.h"
 #include "chrome/common/url_constants.h"
 #include "content/public/browser/web_contents.h"
@@ -180,8 +179,7 @@
       browser_,
       GURL(chrome::kChromeUINewTabURL),
       content::PAGE_TRANSITION_TYPED);
-  CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(contents);
-  core_tab_helper->set_new_tab_start_time(newTabStartTime);
+  contents->SetNewTabStartTime(newTabStartTime);
   [aTab setWebContents:contents];
 }
 
@@ -198,9 +196,7 @@
   params.disposition = NEW_FOREGROUND_TAB;
   params.tabstrip_index = index;
   chrome::Navigate(&params);
-  CoreTabHelper* core_tab_helper =
-      CoreTabHelper::FromWebContents(params.target_contents);
-  core_tab_helper->set_new_tab_start_time(newTabStartTime);
+  params.target_contents->SetNewTabStartTime(newTabStartTime);
 
   [aTab setWebContents:params.target_contents];
 }
diff --git a/chrome/browser/ui/tab_contents/core_tab_helper.cc b/chrome/browser/ui/tab_contents/core_tab_helper.cc
index f8dc42e..502a3f8 100644
--- a/chrome/browser/ui/tab_contents/core_tab_helper.cc
+++ b/chrome/browser/ui/tab_contents/core_tab_helper.cc
@@ -4,7 +4,6 @@
 
 #include "chrome/browser/ui/tab_contents/core_tab_helper.h"
 
-#include "base/metrics/histogram.h"
 #include "chrome/browser/renderer_host/web_cache_manager.h"
 #include "content/public/browser/render_process_host.h"
 #include "content/public/browser/render_view_host.h"
@@ -85,26 +84,6 @@ string16 CoreTabHelper::GetStatusText() const {
   return string16();
 }
 
-void CoreTabHelper::OnCloseStarted() {
-  if (close_start_time_.is_null())
-    close_start_time_ = base::TimeTicks::Now();
-}
-
-void CoreTabHelper::OnCloseCanceled() {
-  close_start_time_ = base::TimeTicks();
-  before_unload_end_time_ = base::TimeTicks();
-  unload_detached_start_time_ = base::TimeTicks();
-}
-
-void CoreTabHelper::OnUnloadStarted() {
-  before_unload_end_time_ = base::TimeTicks::Now();
-}
-
-void CoreTabHelper::OnUnloadDetachedStarted() {
-  if (unload_detached_start_time_.is_null())
-    unload_detached_start_time_ = base::TimeTicks::Now();
-}
-
 ////////////////////////////////////////////////////////////////////////////////
 // WebContentsObserver overrides
 
@@ -112,30 +91,3 @@ void CoreTabHelper::WasShown() {
   WebCacheManager::GetInstance()->ObserveActivity(
       web_contents()->GetRenderProcessHost()->GetID());
 }
-
-void CoreTabHelper::WebContentsDestroyed(WebContents* web_contents) {
-  // 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);
-
-  }
-}
-
-void CoreTabHelper::BeforeUnloadFired(const base::TimeTicks& proceed_time) {
-  before_unload_end_time_ = proceed_time;
-}
-
-void CoreTabHelper::BeforeUnloadDialogCancelled() {
-  OnCloseCanceled();
-}
diff --git a/chrome/browser/ui/tab_contents/core_tab_helper.h b/chrome/browser/ui/tab_contents/core_tab_helper.h
index e5a37dd..834613e 100644
--- a/chrome/browser/ui/tab_contents/core_tab_helper.h
+++ b/chrome/browser/ui/tab_contents/core_tab_helper.h
@@ -5,7 +5,6 @@
 #ifndef CHROME_BROWSER_UI_TAB_CONTENTS_CORE_TAB_HELPER_H_
 #define CHROME_BROWSER_UI_TAB_CONTENTS_CORE_TAB_HELPER_H_
 
-#include "base/time.h"
 #include "content/public/browser/web_contents_observer.h"
 #include "content/public/browser/web_contents_user_data.h"
 
@@ -17,64 +16,25 @@ class CoreTabHelper : public content::WebContentsObserver,
  public:
   virtual ~CoreTabHelper();
 
+  CoreTabHelperDelegate* delegate() const { return delegate_; }
+  void set_delegate(CoreTabHelperDelegate* d) { delegate_ = d; }
+
   // Initial title assigned to NavigationEntries from Navigate.
   static string16 GetDefaultTitle();
 
   // Returns a human-readable description the tab's loading state.
   string16 GetStatusText() const;
 
-  // Notification that tab closing has started.  This can be called multiple
-  // times, subsequent calls are ignored.
-  void OnCloseStarted();
-
-  // Notification that tab closing was cancelled. This can happen when a user
-  // cancels a window close via another tab's beforeunload dialog.
-  void OnCloseCanceled();
-
-  // Set the time during close when unload is started. Normally, this is set
-  // after the beforeunload dialog. However, for a window close, it is set
-  // after all the beforeunload dialogs have finished.
-  void OnUnloadStarted();
-
-  // Set the time during close when the tab is no longer visible.
-  void OnUnloadDetachedStarted();
-
-  CoreTabHelperDelegate* delegate() const { return delegate_; }
-  void set_delegate(CoreTabHelperDelegate* d) { delegate_ = d; }
-
-  void set_new_tab_start_time(const base::TimeTicks& time) {
-    new_tab_start_time_ = time;
-  }
-
-  base::TimeTicks new_tab_start_time() const { return new_tab_start_time_; }
-
  private:
   explicit CoreTabHelper(content::WebContents* web_contents);
   friend class content::WebContentsUserData<CoreTabHelper>;
 
   // content::WebContentsObserver overrides:
   virtual void WasShown() OVERRIDE;
-  virtual void WebContentsDestroyed(
-      content::WebContents* web_contents) OVERRIDE;
-  virtual void BeforeUnloadFired(const base::TimeTicks& proceed_time) OVERRIDE;
-  virtual void BeforeUnloadDialogCancelled() OVERRIDE;
 
   // Delegate for notifying our owner about stuff. Not owned by us.
   CoreTabHelperDelegate* delegate_;
 
-  // The time when we started to create the new tab page.  This time is from
-  // before we created this WebContents.
-  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_;
-
   DISALLOW_COPY_AND_ASSIGN(CoreTabHelper);
 };
 
diff --git a/chrome/browser/ui/tabs/tab_strip_model.cc b/chrome/browser/ui/tabs/tab_strip_model.cc
index a550ca0..78c8f0e 100644
--- a/chrome/browser/ui/tabs/tab_strip_model.cc
+++ b/chrome/browser/ui/tabs/tab_strip_model.cc
@@ -1115,9 +1115,7 @@ bool TabStripModel::InternalCloseTabs(const std::vector<int>& indices,
     if (index == kNoTab)
       continue;
 
-    CoreTabHelper* core_tab_helper =
-        CoreTabHelper::FromWebContents(closing_contents);
-    core_tab_helper->OnCloseStarted();
+    closing_contents->OnCloseStarted();
 
     // Update the explicitly closed state. If the unload handlers cancel the
     // close the state is reset in Browser. We don't update the explicitly
diff --git a/chrome/browser/ui/unload_controller.cc b/chrome/browser/ui/unload_controller.cc
index 19d6154..b52348c 100644
--- a/chrome/browser/ui/unload_controller.cc
+++ b/chrome/browser/ui/unload_controller.cc
@@ -8,7 +8,6 @@
 #include "base/message_loop.h"
 #include "chrome/browser/ui/browser.h"
 #include "chrome/browser/ui/browser_tabstrip.h"
-#include "chrome/browser/ui/tab_contents/core_tab_helper.h"
 #include "chrome/browser/ui/tabs/tab_strip_model.h"
 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h"
 #include "chrome/common/chrome_notification_types.h"
@@ -223,8 +222,7 @@ bool UnloadController::DetachWebContents(content::WebContents* contents) {
     tabs_needing_unload_ack_.insert(contents);
     browser_->tab_strip_model()->DetachWebContentsAt(index);
     contents->SetDelegate(detached_delegate_.get());
-    CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(contents);
-    core_tab_helper->OnUnloadDetachedStarted();
+    contents->OnUnloadDetachedStarted();
     return true;
   }
   return false;
@@ -252,10 +250,7 @@ void UnloadController::ProcessPendingTabs() {
     // the tab's render_view_host may have been nulled out.
     if (contents->GetRenderViewHost()) {
       tab_needing_before_unload_ack_ = contents;
-
-      CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(contents);
-      core_tab_helper->OnCloseStarted();
-
+      contents->OnCloseStarted();
       contents->GetRenderViewHost()->FirePageBeforeUnload(false);
     } else {
       ProcessPendingTabs();
@@ -276,9 +271,7 @@ void UnloadController::ProcessPendingTabs() {
       // Null check render_view_host here as this gets called on a PostTask
       // and the tab's render_view_host may have been nulled out.
       if (contents->GetRenderViewHost()) {
-        CoreTabHelper* core_tab_helper =
-            CoreTabHelper::FromWebContents(contents);
-        core_tab_helper->OnUnloadStarted();
+        contents->OnUnloadStarted();
         DetachWebContents(contents);
         contents->GetRenderViewHost()->ClosePage();
       }
@@ -320,18 +313,13 @@ void UnloadController::CancelWindowClose() {
   DCHECK(is_attempting_to_close_browser_);
   tabs_needing_before_unload_.clear();
   if (tab_needing_before_unload_ack_ != NULL) {
-
-    CoreTabHelper* core_tab_helper =
-        CoreTabHelper::FromWebContents(tab_needing_before_unload_ack_);
-    core_tab_helper->OnCloseCanceled();
+    tab_needing_before_unload_ack_->OnCloseCanceled();
     tab_needing_before_unload_ack_ = NULL;
   }
   for (WebContentsSet::iterator it = tabs_needing_unload_.begin();
        it != tabs_needing_unload_.end(); it++) {
     content::WebContents* contents = *it;
-
-    CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(contents);
-    core_tab_helper->OnCloseCanceled();
+    contents->OnCloseCanceled();
   }
   tabs_needing_unload_.clear();
 
diff --git a/chrome/browser/ui/unload_controller.h b/chrome/browser/ui/unload_controller.h
index 47e50b0..d18ba8d 100644
--- a/chrome/browser/ui/unload_controller.h
+++ b/chrome/browser/ui/unload_controller.h
@@ -41,7 +41,7 @@ namespace chrome {
 //     If beforeunload/unload handlers need to run, UnloadController returns
 //     true and calls ProcessPendingTabs() (private method).
 //  2. For each tab with a beforeunload/unload handler, ProcessPendingTabs()
-//        calls |CoreTabHelper::OnCloseStarted()|
+//        calls |web_contents->OnCloseStarted()|
 //        and   |web_contents->GetRenderViewHost()->FirePageBeforeUnload()|.
 //  3. If the user allowed the close to continue, we detach all the tabs with
 //     unload handlers, remove them from the tab strip, and finish closing
diff --git a/chrome/browser/ui/webui/metrics_handler.cc b/chrome/browser/ui/webui/metrics_handler.cc
index 9394e07..b57ce0f 100644
--- a/chrome/browser/ui/webui/metrics_handler.cc
+++ b/chrome/browser/ui/webui/metrics_handler.cc
@@ -11,7 +11,6 @@
 #include "base/strings/utf_string_conversions.h"
 #include "base/values.h"
 #include "chrome/browser/metrics/metric_event_duration_details.h"
-#include "chrome/browser/ui/tab_contents/core_tab_helper.h"
 #include "chrome/common/chrome_notification_types.h"
 #include "content/public/browser/notification_service.h"
 #include "content/public/browser/user_metrics.h"
@@ -83,12 +82,10 @@ void MetricsHandler::HandleLogEventTime(const ListValue* args) {
 
   // Not all new tab pages get timed. In those cases, we don't have a
   // new_tab_start_time_.
-  CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(tab);
-  if (core_tab_helper->new_tab_start_time().is_null())
+  if (tab->GetNewTabStartTime().is_null())
     return;
 
-  base::TimeDelta duration =
-      base::TimeTicks::Now() - core_tab_helper->new_tab_start_time();
+  base::TimeDelta duration = base::TimeTicks::Now() - tab->GetNewTabStartTime();
   MetricEventDurationDetails details(event_name,
       static_cast<int>(duration.InMilliseconds()));
 
@@ -99,8 +96,7 @@ void MetricsHandler::HandleLogEventTime(const ListValue* args) {
   } else if (event_name == "Tab.NewTabOnload") {
     UMA_HISTOGRAM_TIMES("Tab.NewTabOnload", duration);
     // The new tab page has finished loading; reset it.
-    CoreTabHelper* core_tab_helper = CoreTabHelper::FromWebContents(tab);
-    core_tab_helper->set_new_tab_start_time(base::TimeTicks());
+    tab->SetNewTabStartTime(base::TimeTicks());
   } else {
     NOTREACHED();
   }
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_;
 
diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h
index b915ff0..dbac697 100644
--- a/content/public/browser/web_contents.h
+++ b/content/public/browser/web_contents.h
@@ -361,10 +361,31 @@ class WebContents : public PageNavigator,
   // Returns the settings which get passed to the renderer.
   virtual content::RendererPreferences* GetMutableRendererPrefs() = 0;
 
+  // Set the time when we started to create the new tab page.  This time is
+  // from before we created this WebContents.
+  virtual void SetNewTabStartTime(const base::TimeTicks& time) = 0;
+  virtual base::TimeTicks GetNewTabStartTime() const = 0;
+
   // Tells the tab to close now. The tab will take care not to close until it's
   // out of nested message loops.
   virtual void Close() = 0;
 
+  // Notification that tab closing has started.  This can be called multiple
+  // times, subsequent calls are ignored.
+  virtual void OnCloseStarted() = 0;
+
+  // Notification that tab closing was cancelled. This can happen when a user
+  // cancels a window close via another tab's beforeunload dialog.
+  virtual void OnCloseCanceled() = 0;
+
+  // Set the time during close when unload is started. Normally, this is set
+  // after the beforeunload dialog. However, for a window close, it is set
+  // after all the beforeunload dialogs have finished.
+  virtual void OnUnloadStarted() = 0;
+
+  // Set the time during close when the tab is no longer visible.
+  virtual void OnUnloadDetachedStarted() = 0;
+
   // A render view-originated drag has ended. Informs the render view host and
   // WebContentsDelegate.
   virtual void SystemDragEnded() = 0;
diff --git a/content/public/browser/web_contents_observer.h b/content/public/browser/web_contents_observer.h
index b9ce1e6..0a01171 100644
--- a/content/public/browser/web_contents_observer.h
+++ b/content/public/browser/web_contents_observer.h
@@ -259,12 +259,6 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Listener,
   // Invoked before a form repost warning is shown.
   virtual void BeforeFormRepostWarningShow() {}
 
-  // Invoked when the before unload fires. The time is from the renderer.
-  virtual void BeforeUnloadFired(const base::TimeTicks& proceed_time) {}
-
-  // Invoked when a user cancels a before unload dialog.
-  virtual void BeforeUnloadDialogCancelled() {}
-
   // IPC::Listener implementation.
   virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
 
-- 
cgit v1.1