| OLD | NEW |
| 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_state_manager.h" | 190 #include "chrome/browser/metrics/metrics_state_manager.h" |
| 191 #include "chrome/browser/metrics/omnibox_metrics_provider.h" | 191 #include "chrome/browser/metrics/omnibox_metrics_provider.h" |
| 192 #include "chrome/browser/metrics/time_ticks_experiment_win.h" | 192 #include "chrome/browser/metrics/time_ticks_experiment_win.h" |
| 193 #include "chrome/browser/metrics/tracking_synchronizer.h" | 193 #include "chrome/browser/metrics/tracking_synchronizer.h" |
| 194 #include "chrome/browser/net/http_pipelining_compatibility_client.h" | |
| 195 #include "chrome/browser/net/network_stats.h" | 194 #include "chrome/browser/net/network_stats.h" |
| 196 #include "chrome/browser/ui/browser_otr_state.h" | 195 #include "chrome/browser/ui/browser_otr_state.h" |
| 197 #include "chrome/common/chrome_constants.h" | 196 #include "chrome/common/chrome_constants.h" |
| 198 #include "chrome/common/chrome_switches.h" | 197 #include "chrome/common/chrome_switches.h" |
| 199 #include "chrome/common/crash_keys.h" | 198 #include "chrome/common/crash_keys.h" |
| 200 #include "chrome/common/metrics/variations/variations_util.h" | 199 #include "chrome/common/metrics/variations/variations_util.h" |
| 201 #include "chrome/common/net/test_server_locations.h" | 200 #include "chrome/common/net/test_server_locations.h" |
| 202 #include "chrome/common/pref_names.h" | 201 #include "chrome/common/pref_names.h" |
| 203 #include "chrome/common/render_messages.h" | 202 #include "chrome/common/render_messages.h" |
| 204 #include "components/metrics/metrics_log_manager.h" | 203 #include "components/metrics/metrics_log_manager.h" |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 // private methods | 817 // private methods |
| 819 //------------------------------------------------------------------------------ | 818 //------------------------------------------------------------------------------ |
| 820 | 819 |
| 821 | 820 |
| 822 //------------------------------------------------------------------------------ | 821 //------------------------------------------------------------------------------ |
| 823 // Initialization methods | 822 // Initialization methods |
| 824 | 823 |
| 825 void MetricsService::InitializeMetricsState() { | 824 void MetricsService::InitializeMetricsState() { |
| 826 #if defined(OS_POSIX) | 825 #if defined(OS_POSIX) |
| 827 network_stats_server_ = chrome_common_net::kEchoTestServerLocation; | 826 network_stats_server_ = chrome_common_net::kEchoTestServerLocation; |
| 828 http_pipelining_test_server_ = chrome_common_net::kPipelineTestServerBaseUrl; | |
| 829 #else | 827 #else |
| 830 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 828 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 831 network_stats_server_ = dist->GetNetworkStatsServer(); | 829 network_stats_server_ = dist->GetNetworkStatsServer(); |
| 832 http_pipelining_test_server_ = dist->GetHttpPipeliningTestServer(); | |
| 833 #endif | 830 #endif |
| 834 | 831 |
| 835 PrefService* pref = g_browser_process->local_state(); | 832 PrefService* pref = g_browser_process->local_state(); |
| 836 DCHECK(pref); | 833 DCHECK(pref); |
| 837 | 834 |
| 838 pref->SetString(prefs::kStabilityStatsVersion, | 835 pref->SetString(prefs::kStabilityStatsVersion, |
| 839 MetricsLog::GetVersionString()); | 836 MetricsLog::GetVersionString()); |
| 840 pref->SetInt64(prefs::kStabilityStatsBuildTime, MetricsLog::GetBuildTime()); | 837 pref->SetInt64(prefs::kStabilityStatsBuildTime, MetricsLog::GetBuildTime()); |
| 841 | 838 |
| 842 session_id_ = pref->GetInteger(prefs::kMetricsSessionID); | 839 session_id_ = pref->GetInteger(prefs::kMetricsSessionID); |
| (...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1636 // two as a single unit of work as far as the scheduler is concerned). | 1633 // two as a single unit of work as far as the scheduler is concerned). |
| 1637 if (state_ != SENDING_INITIAL_METRICS_LOG) { | 1634 if (state_ != SENDING_INITIAL_METRICS_LOG) { |
| 1638 scheduler_->UploadFinished(server_is_healthy, | 1635 scheduler_->UploadFinished(server_is_healthy, |
| 1639 log_manager_.has_unsent_logs()); | 1636 log_manager_.has_unsent_logs()); |
| 1640 } | 1637 } |
| 1641 | 1638 |
| 1642 // Collect network stats if UMA upload succeeded. | 1639 // Collect network stats if UMA upload succeeded. |
| 1643 IOThread* io_thread = g_browser_process->io_thread(); | 1640 IOThread* io_thread = g_browser_process->io_thread(); |
| 1644 if (server_is_healthy && io_thread) { | 1641 if (server_is_healthy && io_thread) { |
| 1645 chrome_browser_net::CollectNetworkStats(network_stats_server_, io_thread); | 1642 chrome_browser_net::CollectNetworkStats(network_stats_server_, io_thread); |
| 1646 chrome_browser_net::CollectPipeliningCapabilityStatsOnUIThread( | |
| 1647 http_pipelining_test_server_, io_thread); | |
| 1648 #if defined(OS_WIN) | 1643 #if defined(OS_WIN) |
| 1649 chrome::CollectTimeTicksStats(); | 1644 chrome::CollectTimeTicksStats(); |
| 1650 #endif | 1645 #endif |
| 1651 } | 1646 } |
| 1652 } | 1647 } |
| 1653 | 1648 |
| 1654 void MetricsService::IncrementPrefValue(const char* path) { | 1649 void MetricsService::IncrementPrefValue(const char* path) { |
| 1655 PrefService* pref = g_browser_process->local_state(); | 1650 PrefService* pref = g_browser_process->local_state(); |
| 1656 DCHECK(pref); | 1651 DCHECK(pref); |
| 1657 int value = pref->GetInteger(path); | 1652 int value = pref->GetInteger(path); |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1972 if (metrics_service) | 1967 if (metrics_service) |
| 1973 metrics_service->AddObserver(observer); | 1968 metrics_service->AddObserver(observer); |
| 1974 } | 1969 } |
| 1975 | 1970 |
| 1976 void MetricsServiceHelper::RemoveMetricsServiceObserver( | 1971 void MetricsServiceHelper::RemoveMetricsServiceObserver( |
| 1977 MetricsServiceObserver* observer) { | 1972 MetricsServiceObserver* observer) { |
| 1978 MetricsService* metrics_service = g_browser_process->metrics_service(); | 1973 MetricsService* metrics_service = g_browser_process->metrics_service(); |
| 1979 if (metrics_service) | 1974 if (metrics_service) |
| 1980 metrics_service->RemoveObserver(observer); | 1975 metrics_service->RemoveObserver(observer); |
| 1981 } | 1976 } |
| OLD | NEW |