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

Side by Side Diff: chrome/browser/ui/uma_browsing_activity_observer.cc

Issue 10968064: Move the NOTIFICATION_APP_TERMINATING notification from content to chrome, since it's fired by chro… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: cros compile Created 8 years, 2 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
« no previous file with comments | « chrome/browser/ui/panels/panel.cc ('k') | chrome/common/chrome_notification_types.h » ('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 (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/uma_browsing_activity_observer.h" 5 #include "chrome/browser/ui/uma_browsing_activity_observer.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_list.h" 9 #include "chrome/browser/ui/browser_list.h"
10 #include "chrome/browser/ui/browser_window.h" 10 #include "chrome/browser/ui/browser_window.h"
(...skipping 12 matching lines...) Expand all
23 // static 23 // static
24 void UMABrowsingActivityObserver::Init() { 24 void UMABrowsingActivityObserver::Init() {
25 DCHECK(!g_instance); 25 DCHECK(!g_instance);
26 DCHECK(BrowserList::empty()); // Must be created before any Browsers are. 26 DCHECK(BrowserList::empty()); // Must be created before any Browsers are.
27 g_instance = new UMABrowsingActivityObserver; 27 g_instance = new UMABrowsingActivityObserver;
28 } 28 }
29 29
30 UMABrowsingActivityObserver::UMABrowsingActivityObserver() { 30 UMABrowsingActivityObserver::UMABrowsingActivityObserver() {
31 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, 31 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
32 content::NotificationService::AllSources()); 32 content::NotificationService::AllSources());
33 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING, 33 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING,
34 content::NotificationService::AllSources()); 34 content::NotificationService::AllSources());
35 } 35 }
36 36
37 UMABrowsingActivityObserver::~UMABrowsingActivityObserver() { 37 UMABrowsingActivityObserver::~UMABrowsingActivityObserver() {
38 } 38 }
39 39
40 void UMABrowsingActivityObserver::Observe( 40 void UMABrowsingActivityObserver::Observe(
41 int type, 41 int type,
42 const content::NotificationSource& source, 42 const content::NotificationSource& source,
43 const content::NotificationDetails& details) { 43 const content::NotificationDetails& details) {
44 if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) { 44 if (type == content::NOTIFICATION_NAV_ENTRY_COMMITTED) {
45 const content::LoadCommittedDetails& load = 45 const content::LoadCommittedDetails& load =
46 *content::Details<content::LoadCommittedDetails>(details).ptr(); 46 *content::Details<content::LoadCommittedDetails>(details).ptr();
47 if (!load.is_navigation_to_different_page()) 47 if (!load.is_navigation_to_different_page())
48 return; // Don't log for subframes or other trivial types. 48 return; // Don't log for subframes or other trivial types.
49 49
50 LogRenderProcessHostCount(); 50 LogRenderProcessHostCount();
51 LogBrowserTabCount(); 51 LogBrowserTabCount();
52 } else if (type == content::NOTIFICATION_APP_TERMINATING) { 52 } else if (type == chrome::NOTIFICATION_APP_TERMINATING) {
53 delete g_instance; 53 delete g_instance;
54 g_instance = NULL; 54 g_instance = NULL;
55 } 55 }
56 } 56 }
57 57
58 void UMABrowsingActivityObserver::LogRenderProcessHostCount() const { 58 void UMABrowsingActivityObserver::LogRenderProcessHostCount() const {
59 int hosts_count = 0; 59 int hosts_count = 0;
60 for (content::RenderProcessHost::iterator i( 60 for (content::RenderProcessHost::iterator i(
61 content::RenderProcessHost::AllHostsIterator()); 61 content::RenderProcessHost::AllHostsIterator());
62 !i.IsAtEnd(); i.Advance()) 62 !i.IsAtEnd(); i.Advance())
(...skipping 16 matching lines...) Expand all
79 // Record how many tabs the active window has open. 79 // Record how many tabs the active window has open.
80 UMA_HISTOGRAM_CUSTOM_COUNTS("Tabs.TabCountActiveWindow", 80 UMA_HISTOGRAM_CUSTOM_COUNTS("Tabs.TabCountActiveWindow",
81 browser->tab_count(), 1, 200, 50); 81 browser->tab_count(), 1, 200, 50);
82 } 82 }
83 } 83 }
84 // Record how many tabs total are open (across all windows). 84 // Record how many tabs total are open (across all windows).
85 UMA_HISTOGRAM_CUSTOM_COUNTS("Tabs.TabCountPerLoad", tab_count, 1, 200, 50); 85 UMA_HISTOGRAM_CUSTOM_COUNTS("Tabs.TabCountPerLoad", tab_count, 1, 200, 50);
86 } 86 }
87 87
88 } // namespace chrome 88 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/panel.cc ('k') | chrome/common/chrome_notification_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698