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

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

Issue 293013002: Create OmniboxMetricsProvider class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 7 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 //------------------------------------------------------------------------------ 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 is 10 // A MetricsService instance is typically created at application startup. It is
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 #include "base/tracked_objects.h" 182 #include "base/tracked_objects.h"
183 #include "base/values.h" 183 #include "base/values.h"
184 #include "chrome/browser/browser_process.h" 184 #include "chrome/browser/browser_process.h"
185 #include "chrome/browser/chrome_notification_types.h" 185 #include "chrome/browser/chrome_notification_types.h"
186 #include "chrome/browser/io_thread.h" 186 #include "chrome/browser/io_thread.h"
187 #include "chrome/browser/memory_details.h" 187 #include "chrome/browser/memory_details.h"
188 #include "chrome/browser/metrics/compression_utils.h" 188 #include "chrome/browser/metrics/compression_utils.h"
189 #include "chrome/browser/metrics/metrics_log.h" 189 #include "chrome/browser/metrics/metrics_log.h"
190 #include "chrome/browser/metrics/metrics_reporting_scheduler.h" 190 #include "chrome/browser/metrics/metrics_reporting_scheduler.h"
191 #include "chrome/browser/metrics/metrics_state_manager.h" 191 #include "chrome/browser/metrics/metrics_state_manager.h"
192 #include "chrome/browser/metrics/omnibox_metrics_provider.h"
192 #include "chrome/browser/metrics/time_ticks_experiment_win.h" 193 #include "chrome/browser/metrics/time_ticks_experiment_win.h"
193 #include "chrome/browser/metrics/tracking_synchronizer.h" 194 #include "chrome/browser/metrics/tracking_synchronizer.h"
194 #include "chrome/common/metrics/variations/variations_util.h" 195 #include "chrome/common/metrics/variations/variations_util.h"
195 #include "chrome/browser/net/http_pipelining_compatibility_client.h" 196 #include "chrome/browser/net/http_pipelining_compatibility_client.h"
196 #include "chrome/browser/net/network_stats.h" 197 #include "chrome/browser/net/network_stats.h"
197 #include "chrome/browser/omnibox/omnibox_log.h"
198 #include "chrome/browser/ui/browser_otr_state.h" 198 #include "chrome/browser/ui/browser_otr_state.h"
199 #include "chrome/common/chrome_constants.h" 199 #include "chrome/common/chrome_constants.h"
200 #include "chrome/common/chrome_switches.h" 200 #include "chrome/common/chrome_switches.h"
201 #include "chrome/common/crash_keys.h" 201 #include "chrome/common/crash_keys.h"
202 #include "chrome/common/net/test_server_locations.h" 202 #include "chrome/common/net/test_server_locations.h"
203 #include "chrome/common/pref_names.h" 203 #include "chrome/common/pref_names.h"
204 #include "chrome/common/render_messages.h" 204 #include "chrome/common/render_messages.h"
205 #include "components/metrics/metrics_log_manager.h" 205 #include "components/metrics/metrics_log_manager.h"
206 #include "components/metrics/metrics_pref_names.h" 206 #include "components/metrics/metrics_pref_names.h"
207 #include "components/variations/entropy_provider.h" 207 #include "components/variations/entropy_provider.h"
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 idle_since_last_transmission_(false), 470 idle_since_last_transmission_(false),
471 session_id_(-1), 471 session_id_(-1),
472 next_window_id_(0), 472 next_window_id_(0),
473 self_ptr_factory_(this), 473 self_ptr_factory_(this),
474 state_saver_factory_(this), 474 state_saver_factory_(this),
475 waiting_for_asynchronous_reporting_step_(false), 475 waiting_for_asynchronous_reporting_step_(false),
476 num_async_histogram_fetches_in_progress_(0) { 476 num_async_histogram_fetches_in_progress_(0) {
477 DCHECK(IsSingleThreaded()); 477 DCHECK(IsSingleThreaded());
478 DCHECK(state_manager_); 478 DCHECK(state_manager_);
479 479
480 // TODO(asvitkine): Move this out of MetricsService.
481 RegisterMetricsProvider(
482 scoped_ptr<metrics::MetricsProvider>(new OmniboxMetricsProvider));
483
480 BrowserChildProcessObserver::Add(this); 484 BrowserChildProcessObserver::Add(this);
481 } 485 }
482 486
483 MetricsService::~MetricsService() { 487 MetricsService::~MetricsService() {
484 DisableRecording(); 488 DisableRecording();
485 489
486 BrowserChildProcessObserver::Remove(this); 490 BrowserChildProcessObserver::Remove(this);
487 } 491 }
488 492
489 void MetricsService::InitializeMetricsRecordingState() { 493 void MetricsService::InitializeMetricsRecordingState() {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 DCHECK(IsSingleThreaded()); 644 DCHECK(IsSingleThreaded());
641 645
642 // Check for notifications related to core stability metrics, or that are 646 // Check for notifications related to core stability metrics, or that are
643 // just triggers to end idle mode. Anything else should be added in the later 647 // just triggers to end idle mode. Anything else should be added in the later
644 // switch statement, where they take effect only if general metrics should be 648 // switch statement, where they take effect only if general metrics should be
645 // logged. 649 // logged.
646 bool handled = false; 650 bool handled = false;
647 switch (type) { 651 switch (type) {
648 case chrome::NOTIFICATION_BROWSER_OPENED: 652 case chrome::NOTIFICATION_BROWSER_OPENED:
649 case chrome::NOTIFICATION_BROWSER_CLOSED: 653 case chrome::NOTIFICATION_BROWSER_CLOSED:
654 case chrome::NOTIFICATION_OMNIBOX_OPENED_URL:
650 case chrome::NOTIFICATION_TAB_PARENTED: 655 case chrome::NOTIFICATION_TAB_PARENTED:
651 case chrome::NOTIFICATION_TAB_CLOSING: 656 case chrome::NOTIFICATION_TAB_CLOSING:
652 case content::NOTIFICATION_LOAD_STOP: 657 case content::NOTIFICATION_LOAD_STOP:
653 // These notifications are used only to break out of idle mode. 658 // These notifications are used only to break out of idle mode.
654 handled = true; 659 handled = true;
655 break; 660 break;
656 661
657 case content::NOTIFICATION_LOAD_START: { 662 case content::NOTIFICATION_LOAD_START: {
658 content::NavigationController* controller = 663 content::NavigationController* controller =
659 content::Source<content::NavigationController>(source).ptr(); 664 content::Source<content::NavigationController>(source).ptr();
(...skipping 15 matching lines...) Expand all
675 handled = true; 680 handled = true;
676 break; 681 break;
677 } 682 }
678 683
679 case content::NOTIFICATION_RENDER_WIDGET_HOST_HANG: 684 case content::NOTIFICATION_RENDER_WIDGET_HOST_HANG:
680 LogRendererHang(); 685 LogRendererHang();
681 handled = true; 686 handled = true;
682 break; 687 break;
683 688
684 default: 689 default:
685 // Everything else is handled after the early return check below. 690 NOTREACHED();
686 break; 691 break;
687 } 692 }
688 693
689 // If it wasn't one of the stability-related notifications, and event
690 // logging isn't suppressed, handle it.
691 if (!handled && ShouldLogEvents()) {
692 switch (type) {
693 case chrome::NOTIFICATION_OMNIBOX_OPENED_URL: {
694 MetricsLog* current_log =
695 static_cast<MetricsLog*>(log_manager_.current_log());
696 DCHECK(current_log);
697 current_log->RecordOmniboxOpenedURL(
698 *content::Details<OmniboxLog>(details).ptr());
699 break;
700 }
701
702 default:
703 NOTREACHED();
704 break;
705 }
706 }
707
708 HandleIdleSinceLastTransmission(false); 694 HandleIdleSinceLastTransmission(false);
709 } 695 }
710 696
711 void MetricsService::HandleIdleSinceLastTransmission(bool in_idle) { 697 void MetricsService::HandleIdleSinceLastTransmission(bool in_idle) {
712 // If there wasn't a lot of action, maybe the computer was asleep, in which 698 // If there wasn't a lot of action, maybe the computer was asleep, in which
713 // case, the log transmissions should have stopped. Here we start them up 699 // case, the log transmissions should have stopped. Here we start them up
714 // again. 700 // again.
715 if (!in_idle && idle_since_last_transmission_) 701 if (!in_idle && idle_since_last_transmission_)
716 StartSchedulerIfNecessary(); 702 StartSchedulerIfNecessary();
717 idle_since_last_transmission_ = in_idle; 703 idle_since_last_transmission_ = in_idle;
(...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1992 if (metrics_service) 1978 if (metrics_service)
1993 metrics_service->AddObserver(observer); 1979 metrics_service->AddObserver(observer);
1994 } 1980 }
1995 1981
1996 void MetricsServiceHelper::RemoveMetricsServiceObserver( 1982 void MetricsServiceHelper::RemoveMetricsServiceObserver(
1997 MetricsServiceObserver* observer) { 1983 MetricsServiceObserver* observer) {
1998 MetricsService* metrics_service = g_browser_process->metrics_service(); 1984 MetricsService* metrics_service = g_browser_process->metrics_service();
1999 if (metrics_service) 1985 if (metrics_service)
2000 metrics_service->RemoveObserver(observer); 1986 metrics_service->RemoveObserver(observer);
2001 } 1987 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698