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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 #include "chrome/browser/metrics/histogram_synchronizer.h" 174 #include "chrome/browser/metrics/histogram_synchronizer.h"
175 #include "chrome/browser/metrics/metrics_log.h" 175 #include "chrome/browser/metrics/metrics_log.h"
176 #include "chrome/browser/metrics/metrics_reporting_scheduler.h" 176 #include "chrome/browser/metrics/metrics_reporting_scheduler.h"
177 #include "chrome/browser/net/network_stats.h" 177 #include "chrome/browser/net/network_stats.h"
178 #include "chrome/browser/prefs/pref_service.h" 178 #include "chrome/browser/prefs/pref_service.h"
179 #include "chrome/browser/prefs/scoped_user_pref_update.h" 179 #include "chrome/browser/prefs/scoped_user_pref_update.h"
180 #include "chrome/browser/profiles/profile.h" 180 #include "chrome/browser/profiles/profile.h"
181 #include "chrome/browser/search_engines/template_url_service.h" 181 #include "chrome/browser/search_engines/template_url_service.h"
182 #include "chrome/browser/ui/browser_list.h" 182 #include "chrome/browser/ui/browser_list.h"
183 #include "chrome/common/child_process_logging.h" 183 #include "chrome/common/child_process_logging.h"
184 #include "chrome/common/chrome_notification_types.h"
184 #include "chrome/common/chrome_switches.h" 185 #include "chrome/common/chrome_switches.h"
185 #include "chrome/common/guid.h" 186 #include "chrome/common/guid.h"
186 #include "chrome/common/pref_names.h" 187 #include "chrome/common/pref_names.h"
187 #include "chrome/common/render_messages.h" 188 #include "chrome/common/render_messages.h"
188 #include "content/browser/load_notification_details.h" 189 #include "content/browser/load_notification_details.h"
189 #include "content/browser/renderer_host/render_process_host.h" 190 #include "content/browser/renderer_host/render_process_host.h"
190 #include "content/common/child_process_info.h" 191 #include "content/common/child_process_info.h"
191 #include "content/common/notification_service.h" 192 #include "content/common/notification_service.h"
192 #include "webkit/plugins/npapi/plugin_list.h" 193 #include "webkit/plugins/npapi/plugin_list.h"
193 #include "webkit/plugins/npapi/webplugininfo.h" 194 #include "webkit/plugins/npapi/webplugininfo.h"
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 } 527 }
527 528
528 bool MetricsService::reporting_active() const { 529 bool MetricsService::reporting_active() const {
529 DCHECK(IsSingleThreaded()); 530 DCHECK(IsSingleThreaded());
530 return reporting_active_; 531 return reporting_active_;
531 } 532 }
532 533
533 // static 534 // static
534 void MetricsService::SetUpNotifications(NotificationRegistrar* registrar, 535 void MetricsService::SetUpNotifications(NotificationRegistrar* registrar,
535 NotificationObserver* observer) { 536 NotificationObserver* observer) {
536 registrar->Add(observer, NotificationType::BROWSER_OPENED, 537 registrar->Add(observer, chrome::BROWSER_OPENED,
537 NotificationService::AllSources()); 538 NotificationService::AllSources());
538 registrar->Add(observer, NotificationType::BROWSER_CLOSED, 539 registrar->Add(observer, chrome::BROWSER_CLOSED,
539 NotificationService::AllSources()); 540 NotificationService::AllSources());
540 registrar->Add(observer, NotificationType::USER_ACTION, 541 registrar->Add(observer, NotificationType::USER_ACTION,
541 NotificationService::AllSources()); 542 NotificationService::AllSources());
542 registrar->Add(observer, NotificationType::TAB_PARENTED, 543 registrar->Add(observer, NotificationType::TAB_PARENTED,
543 NotificationService::AllSources()); 544 NotificationService::AllSources());
544 registrar->Add(observer, NotificationType::TAB_CLOSING, 545 registrar->Add(observer, NotificationType::TAB_CLOSING,
545 NotificationService::AllSources()); 546 NotificationService::AllSources());
546 registrar->Add(observer, NotificationType::LOAD_START, 547 registrar->Add(observer, NotificationType::LOAD_START,
547 NotificationService::AllSources()); 548 NotificationService::AllSources());
548 registrar->Add(observer, NotificationType::LOAD_STOP, 549 registrar->Add(observer, NotificationType::LOAD_STOP,
549 NotificationService::AllSources()); 550 NotificationService::AllSources());
550 registrar->Add(observer, NotificationType::RENDERER_PROCESS_CLOSED, 551 registrar->Add(observer, NotificationType::RENDERER_PROCESS_CLOSED,
551 NotificationService::AllSources()); 552 NotificationService::AllSources());
552 registrar->Add(observer, NotificationType::RENDERER_PROCESS_HANG, 553 registrar->Add(observer, NotificationType::RENDERER_PROCESS_HANG,
553 NotificationService::AllSources()); 554 NotificationService::AllSources());
554 registrar->Add(observer, NotificationType::CHILD_PROCESS_HOST_CONNECTED, 555 registrar->Add(observer, NotificationType::CHILD_PROCESS_HOST_CONNECTED,
555 NotificationService::AllSources()); 556 NotificationService::AllSources());
556 registrar->Add(observer, NotificationType::CHILD_INSTANCE_CREATED, 557 registrar->Add(observer, NotificationType::CHILD_INSTANCE_CREATED,
557 NotificationService::AllSources()); 558 NotificationService::AllSources());
558 registrar->Add(observer, NotificationType::CHILD_PROCESS_CRASHED, 559 registrar->Add(observer, NotificationType::CHILD_PROCESS_CRASHED,
559 NotificationService::AllSources()); 560 NotificationService::AllSources());
560 registrar->Add(observer, NotificationType::TEMPLATE_URL_SERVICE_LOADED, 561 registrar->Add(observer, chrome::TEMPLATE_URL_SERVICE_LOADED,
561 NotificationService::AllSources()); 562 NotificationService::AllSources());
562 registrar->Add(observer, NotificationType::OMNIBOX_OPENED_URL, 563 registrar->Add(observer, chrome::OMNIBOX_OPENED_URL,
563 NotificationService::AllSources()); 564 NotificationService::AllSources());
564 registrar->Add(observer, NotificationType::BOOKMARK_MODEL_LOADED, 565 registrar->Add(observer, chrome::BOOKMARK_MODEL_LOADED,
565 NotificationService::AllSources()); 566 NotificationService::AllSources());
566 } 567 }
567 568
568 void MetricsService::Observe(NotificationType type, 569 void MetricsService::Observe(NotificationType type,
569 const NotificationSource& source, 570 const NotificationSource& source,
570 const NotificationDetails& details) { 571 const NotificationDetails& details) {
571 DCHECK(current_log_); 572 DCHECK(current_log_);
572 DCHECK(IsSingleThreaded()); 573 DCHECK(IsSingleThreaded());
573 574
574 if (!CanLogNotification(type, source, details)) 575 if (!CanLogNotification(type, source, details))
575 return; 576 return;
576 577
577 switch (type.value) { 578 switch (type.value) {
578 case NotificationType::USER_ACTION: 579 case NotificationType::USER_ACTION:
579 current_log_->RecordUserAction(*Details<const char*>(details).ptr()); 580 current_log_->RecordUserAction(*Details<const char*>(details).ptr());
580 break; 581 break;
581 582
582 case NotificationType::BROWSER_OPENED: 583 case chrome::BROWSER_OPENED:
583 case NotificationType::BROWSER_CLOSED: 584 case chrome::BROWSER_CLOSED:
584 LogWindowChange(type, source, details); 585 LogWindowChange(type, source, details);
585 break; 586 break;
586 587
587 case NotificationType::TAB_PARENTED: 588 case NotificationType::TAB_PARENTED:
588 case NotificationType::TAB_CLOSING: 589 case NotificationType::TAB_CLOSING:
589 LogWindowChange(type, source, details); 590 LogWindowChange(type, source, details);
590 break; 591 break;
591 592
592 case NotificationType::LOAD_STOP: 593 case NotificationType::LOAD_STOP:
593 LogLoadComplete(type, source, details); 594 LogLoadComplete(type, source, details);
(...skipping 22 matching lines...) Expand all
616 case NotificationType::RENDERER_PROCESS_HANG: 617 case NotificationType::RENDERER_PROCESS_HANG:
617 LogRendererHang(); 618 LogRendererHang();
618 break; 619 break;
619 620
620 case NotificationType::CHILD_PROCESS_HOST_CONNECTED: 621 case NotificationType::CHILD_PROCESS_HOST_CONNECTED:
621 case NotificationType::CHILD_PROCESS_CRASHED: 622 case NotificationType::CHILD_PROCESS_CRASHED:
622 case NotificationType::CHILD_INSTANCE_CREATED: 623 case NotificationType::CHILD_INSTANCE_CREATED:
623 LogChildProcessChange(type, source, details); 624 LogChildProcessChange(type, source, details);
624 break; 625 break;
625 626
626 case NotificationType::TEMPLATE_URL_SERVICE_LOADED: 627 case chrome::TEMPLATE_URL_SERVICE_LOADED:
627 LogKeywords(Source<TemplateURLService>(source).ptr()); 628 LogKeywords(Source<TemplateURLService>(source).ptr());
628 break; 629 break;
629 630
630 case NotificationType::OMNIBOX_OPENED_URL: { 631 case chrome::OMNIBOX_OPENED_URL: {
631 MetricsLog* current_log = current_log_->AsMetricsLog(); 632 MetricsLog* current_log = current_log_->AsMetricsLog();
632 DCHECK(current_log); 633 DCHECK(current_log);
633 current_log->RecordOmniboxOpenedURL( 634 current_log->RecordOmniboxOpenedURL(
634 *Details<AutocompleteLog>(details).ptr()); 635 *Details<AutocompleteLog>(details).ptr());
635 break; 636 break;
636 } 637 }
637 638
638 case NotificationType::BOOKMARK_MODEL_LOADED: { 639 case chrome::BOOKMARK_MODEL_LOADED: {
639 Profile* p = Source<Profile>(source).ptr(); 640 Profile* p = Source<Profile>(source).ptr();
640 if (p) 641 if (p)
641 LogBookmarks(p->GetBookmarkModel()); 642 LogBookmarks(p->GetBookmarkModel());
642 break; 643 break;
643 } 644 }
644 default: 645 default:
645 NOTREACHED(); 646 NOTREACHED();
646 break; 647 break;
647 } 648 }
648 649
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
1397 if (window_map_.find(window_or_tab) == window_map_.end()) { 1398 if (window_map_.find(window_or_tab) == window_map_.end()) {
1398 controller_id = next_window_id_++; 1399 controller_id = next_window_id_++;
1399 window_map_[window_or_tab] = controller_id; 1400 window_map_[window_or_tab] = controller_id;
1400 } else { 1401 } else {
1401 controller_id = window_map_[window_or_tab]; 1402 controller_id = window_map_[window_or_tab];
1402 } 1403 }
1403 DCHECK_NE(controller_id, -1); 1404 DCHECK_NE(controller_id, -1);
1404 1405
1405 switch (type.value) { 1406 switch (type.value) {
1406 case NotificationType::TAB_PARENTED: 1407 case NotificationType::TAB_PARENTED:
1407 case NotificationType::BROWSER_OPENED: 1408 case chrome::BROWSER_OPENED:
1408 window_type = MetricsLog::WINDOW_CREATE; 1409 window_type = MetricsLog::WINDOW_CREATE;
1409 break; 1410 break;
1410 1411
1411 case NotificationType::TAB_CLOSING: 1412 case NotificationType::TAB_CLOSING:
1412 case NotificationType::BROWSER_CLOSED: 1413 case chrome::BROWSER_CLOSED:
1413 window_map_.erase(window_map_.find(window_or_tab)); 1414 window_map_.erase(window_map_.find(window_or_tab));
1414 window_type = MetricsLog::WINDOW_DESTROY; 1415 window_type = MetricsLog::WINDOW_DESTROY;
1415 break; 1416 break;
1416 1417
1417 default: 1418 default:
1418 NOTREACHED(); 1419 NOTREACHED();
1419 return; 1420 return;
1420 } 1421 }
1421 1422
1422 // TODO(brettw) we should have some kind of ID for the parent. 1423 // TODO(brettw) we should have some kind of ID for the parent.
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1690 thread_id = base::PlatformThread::CurrentId(); 1691 thread_id = base::PlatformThread::CurrentId();
1691 return base::PlatformThread::CurrentId() == thread_id; 1692 return base::PlatformThread::CurrentId() == thread_id;
1692 } 1693 }
1693 1694
1694 #if defined(OS_CHROMEOS) 1695 #if defined(OS_CHROMEOS)
1695 void MetricsService::StartExternalMetrics() { 1696 void MetricsService::StartExternalMetrics() {
1696 external_metrics_ = new chromeos::ExternalMetrics; 1697 external_metrics_ = new chromeos::ExternalMetrics;
1697 external_metrics_->Start(); 1698 external_metrics_->Start();
1698 } 1699 }
1699 #endif 1700 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698