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

Side by Side Diff: chrome/browser/ui/tab_contents/core_tab_helper.cc

Issue 17151010: Move histograms and supporting code that don't belong in content out. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" 5 #include "chrome/browser/ui/tab_contents/core_tab_helper.h"
6 6
7 #include "base/metrics/histogram.h"
7 #include "chrome/browser/renderer_host/web_cache_manager.h" 8 #include "chrome/browser/renderer_host/web_cache_manager.h"
8 #include "content/public/browser/render_process_host.h" 9 #include "content/public/browser/render_process_host.h"
9 #include "content/public/browser/render_view_host.h" 10 #include "content/public/browser/render_view_host.h"
10 #include "content/public/browser/web_contents.h" 11 #include "content/public/browser/web_contents.h"
11 #include "net/base/load_states.h" 12 #include "net/base/load_states.h"
12 #include "grit/generated_resources.h" 13 #include "grit/generated_resources.h"
13 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
14 15
15 using content::WebContents; 16 using content::WebContents;
16 17
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 web_contents()->GetLoadStateHost()); 78 web_contents()->GetLoadStateHost());
78 // Ignore net::LOAD_STATE_READING_RESPONSE and net::LOAD_STATE_IDLE 79 // Ignore net::LOAD_STATE_READING_RESPONSE and net::LOAD_STATE_IDLE
79 case net::LOAD_STATE_IDLE: 80 case net::LOAD_STATE_IDLE:
80 case net::LOAD_STATE_READING_RESPONSE: 81 case net::LOAD_STATE_READING_RESPONSE:
81 break; 82 break;
82 } 83 }
83 84
84 return string16(); 85 return string16();
85 } 86 }
86 87
88 void CoreTabHelper::OnCloseStarted() {
89 if (close_start_time_.is_null())
90 close_start_time_ = base::TimeTicks::Now();
91 }
92
93 void CoreTabHelper::OnCloseCanceled() {
94 close_start_time_ = base::TimeTicks();
95 before_unload_end_time_ = base::TimeTicks();
96 unload_detached_start_time_ = base::TimeTicks();
97 }
98
99 void CoreTabHelper::OnUnloadStarted() {
100 before_unload_end_time_ = base::TimeTicks::Now();
101 }
102
103 void CoreTabHelper::OnUnloadDetachedStarted() {
104 if (unload_detached_start_time_.is_null())
105 unload_detached_start_time_ = base::TimeTicks::Now();
106 }
107
87 //////////////////////////////////////////////////////////////////////////////// 108 ////////////////////////////////////////////////////////////////////////////////
88 // WebContentsObserver overrides 109 // WebContentsObserver overrides
89 110
90 void CoreTabHelper::WasShown() { 111 void CoreTabHelper::WasShown() {
91 WebCacheManager::GetInstance()->ObserveActivity( 112 WebCacheManager::GetInstance()->ObserveActivity(
92 web_contents()->GetRenderProcessHost()->GetID()); 113 web_contents()->GetRenderProcessHost()->GetID());
93 } 114 }
115
116 void CoreTabHelper::WebContentsDestroyed(WebContents* web_contents) {
117 // OnCloseStarted isn't called in unit tests.
118 if (!close_start_time_.is_null()) {
119 base::TimeTicks now = base::TimeTicks::Now();
120 base::TimeDelta close_time = now - close_start_time_;
121 UMA_HISTOGRAM_TIMES("Tab.Close", close_time);
122
123 base::TimeTicks unload_start_time = close_start_time_;
124 base::TimeTicks unload_end_time = now;
125 if (!before_unload_end_time_.is_null())
126 unload_start_time = before_unload_end_time_;
127 if (!unload_detached_start_time_.is_null())
128 unload_end_time = unload_detached_start_time_;
129 base::TimeDelta unload_time = unload_end_time - unload_start_time;
130 UMA_HISTOGRAM_TIMES("Tab.Close.UnloadTime", unload_time);
131
132 }
133 }
134
135 void CoreTabHelper::BeforeUnloadFired(const base::TimeTicks& proceed_time) {
136 before_unload_end_time_ = proceed_time;
137 }
138
139 void CoreTabHelper::BeforeUnloadDialogCancelled() {
140 OnCloseCanceled();
141 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698