| OLD | NEW |
| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 #include "base/threading/platform_thread.h" | 167 #include "base/threading/platform_thread.h" |
| 168 #include "base/threading/thread.h" | 168 #include "base/threading/thread.h" |
| 169 #include "base/utf_string_conversions.h" | 169 #include "base/utf_string_conversions.h" |
| 170 #include "base/values.h" | 170 #include "base/values.h" |
| 171 #include "chrome/browser/bookmarks/bookmark_model.h" | 171 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 172 #include "chrome/browser/browser_process.h" | 172 #include "chrome/browser/browser_process.h" |
| 173 #include "chrome/browser/memory_details.h" | 173 #include "chrome/browser/memory_details.h" |
| 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/prefs/pref_service.h" | 178 #include "chrome/browser/prefs/pref_service.h" |
| 178 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 179 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 179 #include "chrome/browser/profiles/profile.h" | 180 #include "chrome/browser/profiles/profile.h" |
| 180 #include "chrome/browser/search_engines/template_url_model.h" | 181 #include "chrome/browser/search_engines/template_url_model.h" |
| 181 #include "chrome/browser/ui/browser_list.h" | 182 #include "chrome/browser/ui/browser_list.h" |
| 182 #include "chrome/common/child_process_logging.h" | 183 #include "chrome/common/child_process_logging.h" |
| 183 #include "chrome/common/chrome_switches.h" | 184 #include "chrome/common/chrome_switches.h" |
| 184 #include "chrome/common/guid.h" | 185 #include "chrome/common/guid.h" |
| 185 #include "chrome/common/pref_names.h" | 186 #include "chrome/common/pref_names.h" |
| 186 #include "chrome/common/render_messages.h" | 187 #include "chrome/common/render_messages.h" |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 // private methods | 688 // private methods |
| 688 //------------------------------------------------------------------------------ | 689 //------------------------------------------------------------------------------ |
| 689 | 690 |
| 690 | 691 |
| 691 //------------------------------------------------------------------------------ | 692 //------------------------------------------------------------------------------ |
| 692 // Initialization methods | 693 // Initialization methods |
| 693 | 694 |
| 694 void MetricsService::InitializeMetricsState() { | 695 void MetricsService::InitializeMetricsState() { |
| 695 #if defined(OS_POSIX) | 696 #if defined(OS_POSIX) |
| 696 server_url_ = L"https://clients4.google.com/firefox/metrics/collect"; | 697 server_url_ = L"https://clients4.google.com/firefox/metrics/collect"; |
| 698 // TODO(rtenneti): Return the network stats server name. |
| 699 network_stats_server_ = ""; |
| 697 #else | 700 #else |
| 698 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 701 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 699 server_url_ = dist->GetStatsServerURL(); | 702 server_url_ = dist->GetStatsServerURL(); |
| 703 network_stats_server_ = dist->GetNetworkStatsServer(); |
| 700 #endif | 704 #endif |
| 701 | 705 |
| 702 PrefService* pref = g_browser_process->local_state(); | 706 PrefService* pref = g_browser_process->local_state(); |
| 703 DCHECK(pref); | 707 DCHECK(pref); |
| 704 | 708 |
| 705 if ((pref->GetInt64(prefs::kStabilityStatsBuildTime) | 709 if ((pref->GetInt64(prefs::kStabilityStatsBuildTime) |
| 706 != MetricsLog::GetBuildTime()) || | 710 != MetricsLog::GetBuildTime()) || |
| 707 (pref->GetString(prefs::kStabilityStatsVersion) | 711 (pref->GetString(prefs::kStabilityStatsVersion) |
| 708 != MetricsLog::GetVersionString())) { | 712 != MetricsLog::GetVersionString())) { |
| 709 // This is a new version, so we don't want to confuse the stats about the | 713 // This is a new version, so we don't want to confuse the stats about the |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1358 | 1362 |
| 1359 if (unsent_logs()) | 1363 if (unsent_logs()) |
| 1360 DCHECK(state_ < SENDING_CURRENT_LOGS); | 1364 DCHECK(state_ < SENDING_CURRENT_LOGS); |
| 1361 } | 1365 } |
| 1362 | 1366 |
| 1363 // Error 400 indicates a problem with the log, not with the server, so | 1367 // Error 400 indicates a problem with the log, not with the server, so |
| 1364 // don't consider that a sign that the server is in trouble. | 1368 // don't consider that a sign that the server is in trouble. |
| 1365 bool server_is_healthy = upload_succeeded || response_code == 400; | 1369 bool server_is_healthy = upload_succeeded || response_code == 400; |
| 1366 | 1370 |
| 1367 scheduler_->UploadFinished(server_is_healthy, unsent_logs()); | 1371 scheduler_->UploadFinished(server_is_healthy, unsent_logs()); |
| 1372 |
| 1373 // Collect network stats if UMA upload succeeded. |
| 1374 if (server_is_healthy) |
| 1375 chrome_browser_net::CollectNetworkStats(network_stats_server_); |
| 1368 } | 1376 } |
| 1369 | 1377 |
| 1370 void MetricsService::LogBadResponseCode() { | 1378 void MetricsService::LogBadResponseCode() { |
| 1371 VLOG(1) << "Verify your metrics logs are formatted correctly. Verify server " | 1379 VLOG(1) << "Verify your metrics logs are formatted correctly. Verify server " |
| 1372 "is active at " << server_url_; | 1380 "is active at " << server_url_; |
| 1373 if (!pending_log()) { | 1381 if (!pending_log()) { |
| 1374 VLOG(1) << "METRICS: Recorder shutdown during log transmission."; | 1382 VLOG(1) << "METRICS: Recorder shutdown during log transmission."; |
| 1375 } else { | 1383 } else { |
| 1376 VLOG(1) << "METRICS: transmission retry being scheduled for " | 1384 VLOG(1) << "METRICS: transmission retry being scheduled for " |
| 1377 << compressed_log_; | 1385 << compressed_log_; |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1684 thread_id = base::PlatformThread::CurrentId(); | 1692 thread_id = base::PlatformThread::CurrentId(); |
| 1685 return base::PlatformThread::CurrentId() == thread_id; | 1693 return base::PlatformThread::CurrentId() == thread_id; |
| 1686 } | 1694 } |
| 1687 | 1695 |
| 1688 #if defined(OS_CHROMEOS) | 1696 #if defined(OS_CHROMEOS) |
| 1689 void MetricsService::StartExternalMetrics() { | 1697 void MetricsService::StartExternalMetrics() { |
| 1690 external_metrics_ = new chromeos::ExternalMetrics; | 1698 external_metrics_ = new chromeos::ExternalMetrics; |
| 1691 external_metrics_->Start(); | 1699 external_metrics_->Start(); |
| 1692 } | 1700 } |
| 1693 #endif | 1701 #endif |
| OLD | NEW |