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

Side by Side Diff: chrome/browser/metrics/metrics_service.cc

Issue 10917198: Switch NOTIFICATION_TAB_PARENTED to use WebContents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 3 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/metrics/metrics_service.h ('k') | chrome/browser/sessions/session_service.cc » ('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 //------------------------------------------------------------------------------ 5 //------------------------------------------------------------------------------
6 // Description of the life cycle of a instance of MetricsService. 6 // Description of the life cycle of a instance of MetricsService.
7 // 7 //
8 // OVERVIEW 8 // OVERVIEW
9 // 9 //
10 // A MetricsService instance is typically created at application startup. It 10 // A MetricsService instance is typically created at application startup. It
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 #include "chrome/common/net/test_server_locations.h" 190 #include "chrome/common/net/test_server_locations.h"
191 #include "chrome/common/pref_names.h" 191 #include "chrome/common/pref_names.h"
192 #include "chrome/common/render_messages.h" 192 #include "chrome/common/render_messages.h"
193 #include "content/public/browser/child_process_data.h" 193 #include "content/public/browser/child_process_data.h"
194 #include "content/public/browser/histogram_fetcher.h" 194 #include "content/public/browser/histogram_fetcher.h"
195 #include "content/public/browser/load_notification_details.h" 195 #include "content/public/browser/load_notification_details.h"
196 #include "content/public/browser/notification_service.h" 196 #include "content/public/browser/notification_service.h"
197 #include "content/public/browser/plugin_service.h" 197 #include "content/public/browser/plugin_service.h"
198 #include "content/public/browser/render_process_host.h" 198 #include "content/public/browser/render_process_host.h"
199 #include "content/public/browser/user_metrics.h" 199 #include "content/public/browser/user_metrics.h"
200 #include "content/public/browser/web_contents.h"
200 #include "net/base/load_flags.h" 201 #include "net/base/load_flags.h"
201 #include "net/url_request/url_fetcher.h" 202 #include "net/url_request/url_fetcher.h"
202 #include "webkit/plugins/webplugininfo.h" 203 #include "webkit/plugins/webplugininfo.h"
203 204
204 // TODO(port): port browser_distribution.h. 205 // TODO(port): port browser_distribution.h.
205 #if !defined(OS_POSIX) 206 #if !defined(OS_POSIX)
206 #include "chrome/installer/util/browser_distribution.h" 207 #include "chrome/installer/util/browser_distribution.h"
207 #endif 208 #endif
208 209
209 #if defined(OS_CHROMEOS) 210 #if defined(OS_CHROMEOS)
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 if (!CanLogNotification(type, source, details)) 673 if (!CanLogNotification(type, source, details))
673 return; 674 return;
674 675
675 switch (type) { 676 switch (type) {
676 case content::NOTIFICATION_USER_ACTION: 677 case content::NOTIFICATION_USER_ACTION:
677 log_manager_.current_log()->RecordUserAction( 678 log_manager_.current_log()->RecordUserAction(
678 *content::Details<const char*>(details).ptr()); 679 *content::Details<const char*>(details).ptr());
679 break; 680 break;
680 681
681 case chrome::NOTIFICATION_BROWSER_OPENED: 682 case chrome::NOTIFICATION_BROWSER_OPENED:
682 case chrome::NOTIFICATION_BROWSER_CLOSED: 683 case chrome::NOTIFICATION_BROWSER_CLOSED: {
683 LogWindowChange(type, source, details); 684 Browser* browser = content::Source<Browser>(source).ptr();
685 LogWindowOrTabChange(type, reinterpret_cast<uintptr_t>(browser));
684 break; 686 break;
687 }
685 688
686 case chrome::NOTIFICATION_TAB_PARENTED: 689 case chrome::NOTIFICATION_TAB_PARENTED: {
687 case chrome::NOTIFICATION_TAB_CLOSING: 690 content::WebContents* web_contents =
688 LogWindowChange(type, source, details); 691 content::Source<content::WebContents>(source).ptr();
692 LogWindowOrTabChange(type, reinterpret_cast<uintptr_t>(web_contents));
689 break; 693 break;
694 }
695
696 case chrome::NOTIFICATION_TAB_CLOSING: {
697 content::NavigationController* controller =
698 content::Source<content::NavigationController>(source).ptr();
699 content::WebContents* web_contents = controller->GetWebContents();
700 LogWindowOrTabChange(type, reinterpret_cast<uintptr_t>(web_contents));
701 break;
702 }
690 703
691 case content::NOTIFICATION_LOAD_STOP: 704 case content::NOTIFICATION_LOAD_STOP:
692 LogLoadComplete(type, source, details); 705 LogLoadComplete(type, source, details);
693 break; 706 break;
694 707
695 case content::NOTIFICATION_LOAD_START: 708 case content::NOTIFICATION_LOAD_START:
696 LogLoadStarted(); 709 LogLoadStarted();
697 break; 710 break;
698 711
699 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: { 712 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: {
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
1511 1524
1512 // Collect network stats if UMA upload succeeded. 1525 // Collect network stats if UMA upload succeeded.
1513 IOThread* io_thread = g_browser_process->io_thread(); 1526 IOThread* io_thread = g_browser_process->io_thread();
1514 if (server_is_healthy && io_thread) { 1527 if (server_is_healthy && io_thread) {
1515 chrome_browser_net::CollectNetworkStats(network_stats_server_, io_thread); 1528 chrome_browser_net::CollectNetworkStats(network_stats_server_, io_thread);
1516 chrome_browser_net::CollectPipeliningCapabilityStatsOnUIThread( 1529 chrome_browser_net::CollectPipeliningCapabilityStatsOnUIThread(
1517 http_pipelining_test_server_, io_thread); 1530 http_pipelining_test_server_, io_thread);
1518 } 1531 }
1519 } 1532 }
1520 1533
1521 void MetricsService::LogWindowChange( 1534 void MetricsService::LogWindowOrTabChange(int type, uintptr_t window_or_tab) {
1522 int type,
1523 const content::NotificationSource& source,
1524 const content::NotificationDetails& details) {
1525 int controller_id = -1; 1535 int controller_id = -1;
1526 uintptr_t window_or_tab = source.map_key();
1527 MetricsLog::WindowEventType window_type; 1536 MetricsLog::WindowEventType window_type;
1528 1537
1529 // Note: since we stop all logging when a single OTR session is active, it is 1538 // Note: since we stop all logging when a single OTR session is active, it is
1530 // possible that we start getting notifications about a window that we don't 1539 // possible that we start getting notifications about a window that we don't
1531 // know about. 1540 // know about.
1532 if (window_map_.find(window_or_tab) == window_map_.end()) { 1541 if (window_map_.find(window_or_tab) == window_map_.end()) {
1533 controller_id = next_window_id_++; 1542 controller_id = next_window_id_++;
1534 window_map_[window_or_tab] = controller_id; 1543 window_map_[window_or_tab] = controller_id;
1535 } else { 1544 } else {
1536 controller_id = window_map_[window_or_tab]; 1545 controller_id = window_map_[window_or_tab];
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1933 if (local_state) { 1942 if (local_state) {
1934 const PrefService::Preference* uma_pref = 1943 const PrefService::Preference* uma_pref =
1935 local_state->FindPreference(prefs::kMetricsReportingEnabled); 1944 local_state->FindPreference(prefs::kMetricsReportingEnabled);
1936 if (uma_pref) { 1945 if (uma_pref) {
1937 bool success = uma_pref->GetValue()->GetAsBoolean(&result); 1946 bool success = uma_pref->GetValue()->GetAsBoolean(&result);
1938 DCHECK(success); 1947 DCHECK(success);
1939 } 1948 }
1940 } 1949 }
1941 return result; 1950 return result;
1942 } 1951 }
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_service.h ('k') | chrome/browser/sessions/session_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698