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

Side by Side Diff: extensions/browser/extension_host.cc

Issue 902963002: Replace the ExtensionHost load UMAs (Extensions.BackgroundPageLoadTime and friends) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: extensions.popuploadtime Created 5 years, 10 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
« no previous file with comments | « extensions/browser/extension_host.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/extension_host.h" 5 #include "extensions/browser/extension_host.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/singleton.h" 11 #include "base/memory/singleton.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/metrics/field_trial.h" 14 #include "base/metrics/field_trial.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram_macros.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "content/public/browser/browser_context.h" 18 #include "content/public/browser/browser_context.h"
19 #include "content/public/browser/content_browser_client.h" 19 #include "content/public/browser/content_browser_client.h"
20 #include "content/public/browser/native_web_keyboard_event.h" 20 #include "content/public/browser/native_web_keyboard_event.h"
21 #include "content/public/browser/notification_service.h" 21 #include "content/public/browser/notification_service.h"
22 #include "content/public/browser/notification_source.h" 22 #include "content/public/browser/notification_source.h"
23 #include "content/public/browser/notification_types.h" 23 #include "content/public/browser/notification_types.h"
24 #include "content/public/browser/render_process_host.h" 24 #include "content/public/browser/render_process_host.h"
25 #include "content/public/browser/render_view_host.h" 25 #include "content/public/browser/render_view_host.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 registrar_.Add(this, 145 registrar_.Add(this,
146 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, 146 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
147 content::Source<BrowserContext>(browser_context_)); 147 content::Source<BrowserContext>(browser_context_));
148 148
149 // Set up web contents observers and pref observers. 149 // Set up web contents observers and pref observers.
150 delegate_->OnExtensionHostCreated(host_contents()); 150 delegate_->OnExtensionHostCreated(host_contents());
151 } 151 }
152 152
153 ExtensionHost::~ExtensionHost() { 153 ExtensionHost::~ExtensionHost() {
154 if (extension_host_type_ == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE && 154 if (extension_host_type_ == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE &&
155 extension_ && BackgroundInfo::HasLazyBackgroundPage(extension_)) { 155 extension_ && BackgroundInfo::HasLazyBackgroundPage(extension_) &&
156 UMA_HISTOGRAM_LONG_TIMES("Extensions.EventPageActiveTime", 156 load_start_.get()) {
157 since_created_.Elapsed()); 157 UMA_HISTOGRAM_LONG_TIMES("Extensions.EventPageActiveTime2",
158 load_start_->Elapsed());
158 } 159 }
159 content::NotificationService::current()->Notify( 160 content::NotificationService::current()->Notify(
160 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED, 161 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED,
161 content::Source<BrowserContext>(browser_context_), 162 content::Source<BrowserContext>(browser_context_),
162 content::Details<ExtensionHost>(this)); 163 content::Details<ExtensionHost>(this));
163 FOR_EACH_OBSERVER(ExtensionHostObserver, observer_list_, 164 FOR_EACH_OBSERVER(ExtensionHostObserver, observer_list_,
164 OnExtensionHostDestroyed(this)); 165 OnExtensionHostDestroyed(this));
165 ProcessCreationQueue::GetInstance()->Remove(this); 166 ProcessCreationQueue::GetInstance()->Remove(this);
166 } 167 }
167 168
168 content::RenderProcessHost* ExtensionHost::render_process_host() const { 169 content::RenderProcessHost* ExtensionHost::render_process_host() const {
169 return render_view_host()->GetProcess(); 170 return render_view_host()->GetProcess();
170 } 171 }
171 172
172 RenderViewHost* ExtensionHost::render_view_host() const { 173 RenderViewHost* ExtensionHost::render_view_host() const {
173 // TODO(mpcomplete): This can be NULL. How do we handle that? 174 // TODO(mpcomplete): This can be NULL. How do we handle that?
174 return render_view_host_; 175 return render_view_host_;
175 } 176 }
176 177
177 bool ExtensionHost::IsRenderViewLive() const { 178 bool ExtensionHost::IsRenderViewLive() const {
178 return render_view_host()->IsRenderViewLive(); 179 return render_view_host()->IsRenderViewLive();
179 } 180 }
180 181
181 void ExtensionHost::CreateRenderViewSoon() { 182 void ExtensionHost::CreateRenderViewSoon() {
182 if ((render_process_host() && render_process_host()->HasConnection())) { 183 if (render_process_host() && render_process_host()->HasConnection()) {
183 // If the process is already started, go ahead and initialize the RenderView 184 // If the process is already started, go ahead and initialize the RenderView
184 // synchronously. The process creation is the real meaty part that we want 185 // synchronously. The process creation is the real meaty part that we want
185 // to defer. 186 // to defer.
186 CreateRenderViewNow(); 187 CreateRenderViewNow();
187 } else { 188 } else {
188 ProcessCreationQueue::GetInstance()->CreateSoon(this); 189 ProcessCreationQueue::GetInstance()->CreateSoon(this);
189 } 190 }
190 } 191 }
191 192
192 void ExtensionHost::CreateRenderViewNow() { 193 void ExtensionHost::CreateRenderViewNow() {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 void ExtensionHost::OnNetworkRequestDone(uint64 request_id) { 232 void ExtensionHost::OnNetworkRequestDone(uint64 request_id) {
232 FOR_EACH_OBSERVER(ExtensionHostObserver, observer_list_, 233 FOR_EACH_OBSERVER(ExtensionHostObserver, observer_list_,
233 OnNetworkRequestDone(this, request_id)); 234 OnNetworkRequestDone(this, request_id));
234 } 235 }
235 236
236 const GURL& ExtensionHost::GetURL() const { 237 const GURL& ExtensionHost::GetURL() const {
237 return host_contents()->GetURL(); 238 return host_contents()->GetURL();
238 } 239 }
239 240
240 void ExtensionHost::LoadInitialURL() { 241 void ExtensionHost::LoadInitialURL() {
242 load_start_.reset(new base::ElapsedTimer());
241 host_contents_->GetController().LoadURL( 243 host_contents_->GetController().LoadURL(
242 initial_url_, content::Referrer(), ui::PAGE_TRANSITION_LINK, 244 initial_url_, content::Referrer(), ui::PAGE_TRANSITION_LINK,
243 std::string()); 245 std::string());
244 } 246 }
245 247
246 bool ExtensionHost::IsBackgroundPage() const { 248 bool ExtensionHost::IsBackgroundPage() const {
247 DCHECK(extension_host_type_ == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); 249 DCHECK(extension_host_type_ == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE);
248 return true; 250 return true;
249 } 251 }
250 252
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 extensions::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, 301 extensions::NOTIFICATION_EXTENSION_PROCESS_TERMINATED,
300 content::Source<BrowserContext>(browser_context_), 302 content::Source<BrowserContext>(browser_context_),
301 content::Details<ExtensionHost>(this)); 303 content::Details<ExtensionHost>(this));
302 } 304 }
303 305
304 void ExtensionHost::DidStopLoading(content::RenderViewHost* render_view_host) { 306 void ExtensionHost::DidStopLoading(content::RenderViewHost* render_view_host) {
305 bool notify = !did_stop_loading_; 307 bool notify = !did_stop_loading_;
306 did_stop_loading_ = true; 308 did_stop_loading_ = true;
307 OnDidStopLoading(); 309 OnDidStopLoading();
308 if (notify) { 310 if (notify) {
311 CHECK(load_start_.get());
309 if (extension_host_type_ == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { 312 if (extension_host_type_ == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
310 if (extension_ && BackgroundInfo::HasLazyBackgroundPage(extension_)) { 313 if (extension_ && BackgroundInfo::HasLazyBackgroundPage(extension_)) {
311 UMA_HISTOGRAM_TIMES("Extensions.EventPageLoadTime", 314 UMA_HISTOGRAM_MEDIUM_TIMES("Extensions.EventPageLoadTime2",
312 since_created_.Elapsed()); 315 load_start_->Elapsed());
313 } else { 316 } else {
314 UMA_HISTOGRAM_TIMES("Extensions.BackgroundPageLoadTime", 317 UMA_HISTOGRAM_MEDIUM_TIMES("Extensions.BackgroundPageLoadTime2",
315 since_created_.Elapsed()); 318 load_start_->Elapsed());
316 } 319 }
317 } else if (extension_host_type_ == VIEW_TYPE_EXTENSION_DIALOG) {
318 UMA_HISTOGRAM_TIMES("Extensions.DialogLoadTime",
319 since_created_.Elapsed());
320 } else if (extension_host_type_ == VIEW_TYPE_EXTENSION_POPUP) { 320 } else if (extension_host_type_ == VIEW_TYPE_EXTENSION_POPUP) {
321 UMA_HISTOGRAM_TIMES("Extensions.PopupLoadTime", 321 UMA_HISTOGRAM_MEDIUM_TIMES("Extensions.PopupLoadTime2",
322 since_created_.Elapsed()); 322 load_start_->Elapsed());
323 } else if (extension_host_type_ == VIEW_TYPE_EXTENSION_INFOBAR) {
324 UMA_HISTOGRAM_TIMES("Extensions.InfobarLoadTime",
325 since_created_.Elapsed());
326 } 323 }
327 324
328 // Send the notification last, because it might result in this being 325 // Send the notification last, because it might result in this being
329 // deleted. 326 // deleted.
330 content::NotificationService::current()->Notify( 327 content::NotificationService::current()->Notify(
331 extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, 328 extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING,
332 content::Source<BrowserContext>(browser_context_), 329 content::Source<BrowserContext>(browser_context_),
333 content::Details<ExtensionHost>(this)); 330 content::Details<ExtensionHost>(this));
334 } 331 }
335 } 332 }
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 return delegate_->CheckMediaAccessPermission( 483 return delegate_->CheckMediaAccessPermission(
487 web_contents, security_origin, type, extension()); 484 web_contents, security_origin, type, extension());
488 } 485 }
489 486
490 bool ExtensionHost::IsNeverVisible(content::WebContents* web_contents) { 487 bool ExtensionHost::IsNeverVisible(content::WebContents* web_contents) {
491 ViewType view_type = extensions::GetViewType(web_contents); 488 ViewType view_type = extensions::GetViewType(web_contents);
492 return view_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE; 489 return view_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE;
493 } 490 }
494 491
495 } // namespace extensions 492 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/extension_host.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698