OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/metrics/chrome_metrics_service_client.h" | 5 #include "chrome/browser/metrics/chrome_metrics_service_client.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "base/threading/platform_thread.h" | 21 #include "base/threading/platform_thread.h" |
22 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
23 #include "chrome/browser/chrome_notification_types.h" | 23 #include "chrome/browser/chrome_notification_types.h" |
24 #include "chrome/browser/google/google_brand.h" | 24 #include "chrome/browser/google/google_brand.h" |
25 #include "chrome/browser/metrics/chrome_stability_metrics_provider.h" | 25 #include "chrome/browser/metrics/chrome_stability_metrics_provider.h" |
26 #include "chrome/browser/metrics/drive_metrics_provider.h" | 26 #include "chrome/browser/metrics/drive_metrics_provider.h" |
27 #include "chrome/browser/metrics/omnibox_metrics_provider.h" | 27 #include "chrome/browser/metrics/omnibox_metrics_provider.h" |
28 #include "chrome/browser/ui/browser_otr_state.h" | 28 #include "chrome/browser/ui/browser_otr_state.h" |
29 #include "chrome/common/chrome_constants.h" | 29 #include "chrome/common/chrome_constants.h" |
30 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
31 #include "chrome/common/chrome_version_info.h" | |
32 #include "chrome/common/crash_keys.h" | 31 #include "chrome/common/crash_keys.h" |
| 32 #include "chrome/common/metrics/version_utils.h" |
33 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
34 #include "chrome/common/render_messages.h" | 34 #include "chrome/common/render_messages.h" |
35 #include "components/metrics/gpu/gpu_metrics_provider.h" | 35 #include "components/metrics/gpu/gpu_metrics_provider.h" |
36 #include "components/metrics/metrics_service.h" | 36 #include "components/metrics/metrics_service.h" |
37 #include "components/metrics/net/net_metrics_log_uploader.h" | 37 #include "components/metrics/net/net_metrics_log_uploader.h" |
38 #include "components/metrics/net/network_metrics_provider.h" | 38 #include "components/metrics/net/network_metrics_provider.h" |
39 #include "components/metrics/profiler/profiler_metrics_provider.h" | 39 #include "components/metrics/profiler/profiler_metrics_provider.h" |
40 #include "components/metrics/profiler/tracking_synchronizer.h" | 40 #include "components/metrics/profiler/tracking_synchronizer.h" |
41 #include "components/metrics/url_constants.h" | 41 #include "components/metrics/url_constants.h" |
42 #include "content/public/browser/browser_thread.h" | 42 #include "content/public/browser/browser_thread.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 #if !defined(OS_CHROMEOS) && !defined(OS_IOS) | 75 #if !defined(OS_CHROMEOS) && !defined(OS_IOS) |
76 #include "chrome/browser/metrics/signin_status_metrics_provider.h" | 76 #include "chrome/browser/metrics/signin_status_metrics_provider.h" |
77 #endif // !defined(OS_CHROMEOS) && !defined(OS_IOS) | 77 #endif // !defined(OS_CHROMEOS) && !defined(OS_IOS) |
78 | 78 |
79 namespace { | 79 namespace { |
80 | 80 |
81 // This specifies the amount of time to wait for all renderers to send their | 81 // This specifies the amount of time to wait for all renderers to send their |
82 // data. | 82 // data. |
83 const int kMaxHistogramGatheringWaitDuration = 60000; // 60 seconds. | 83 const int kMaxHistogramGatheringWaitDuration = 60000; // 60 seconds. |
84 | 84 |
85 metrics::SystemProfileProto::Channel AsProtobufChannel( | |
86 chrome::VersionInfo::Channel channel) { | |
87 switch (channel) { | |
88 case chrome::VersionInfo::CHANNEL_UNKNOWN: | |
89 return metrics::SystemProfileProto::CHANNEL_UNKNOWN; | |
90 case chrome::VersionInfo::CHANNEL_CANARY: | |
91 return metrics::SystemProfileProto::CHANNEL_CANARY; | |
92 case chrome::VersionInfo::CHANNEL_DEV: | |
93 return metrics::SystemProfileProto::CHANNEL_DEV; | |
94 case chrome::VersionInfo::CHANNEL_BETA: | |
95 return metrics::SystemProfileProto::CHANNEL_BETA; | |
96 case chrome::VersionInfo::CHANNEL_STABLE: | |
97 return metrics::SystemProfileProto::CHANNEL_STABLE; | |
98 } | |
99 NOTREACHED(); | |
100 return metrics::SystemProfileProto::CHANNEL_UNKNOWN; | |
101 } | |
102 | |
103 // Standard interval between log uploads, in seconds. | 85 // Standard interval between log uploads, in seconds. |
104 #if defined(OS_ANDROID) || defined(OS_IOS) | 86 #if defined(OS_ANDROID) || defined(OS_IOS) |
105 const int kStandardUploadIntervalSeconds = 5 * 60; // Five minutes. | 87 const int kStandardUploadIntervalSeconds = 5 * 60; // Five minutes. |
106 const int kStandardUploadIntervalCellularSeconds = 15 * 60; // Fifteen minutes. | 88 const int kStandardUploadIntervalCellularSeconds = 15 * 60; // Fifteen minutes. |
107 #else | 89 #else |
108 const int kStandardUploadIntervalSeconds = 30 * 60; // Thirty minutes. | 90 const int kStandardUploadIntervalSeconds = 30 * 60; // Thirty minutes. |
109 #endif | 91 #endif |
110 | 92 |
111 #if defined(OS_ANDROID) || defined(OS_IOS) | 93 #if defined(OS_ANDROID) || defined(OS_IOS) |
112 // Returns true if the user is assigned to the experiment group for enabled | 94 // Returns true if the user is assigned to the experiment group for enabled |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 175 |
194 std::string ChromeMetricsServiceClient::GetApplicationLocale() { | 176 std::string ChromeMetricsServiceClient::GetApplicationLocale() { |
195 return g_browser_process->GetApplicationLocale(); | 177 return g_browser_process->GetApplicationLocale(); |
196 } | 178 } |
197 | 179 |
198 bool ChromeMetricsServiceClient::GetBrand(std::string* brand_code) { | 180 bool ChromeMetricsServiceClient::GetBrand(std::string* brand_code) { |
199 return google_brand::GetBrand(brand_code); | 181 return google_brand::GetBrand(brand_code); |
200 } | 182 } |
201 | 183 |
202 metrics::SystemProfileProto::Channel ChromeMetricsServiceClient::GetChannel() { | 184 metrics::SystemProfileProto::Channel ChromeMetricsServiceClient::GetChannel() { |
203 return AsProtobufChannel(chrome::VersionInfo::GetChannel()); | 185 return metrics::AsProtobufChannel(chrome::VersionInfo::GetChannel()); |
204 } | 186 } |
205 | 187 |
206 std::string ChromeMetricsServiceClient::GetVersionString() { | 188 std::string ChromeMetricsServiceClient::GetVersionString() { |
207 chrome::VersionInfo version_info; | 189 return metrics::GetVersionString(); |
208 std::string version = version_info.Version(); | |
209 #if defined(ARCH_CPU_64_BITS) | |
210 version += "-64"; | |
211 #endif // defined(ARCH_CPU_64_BITS) | |
212 if (!version_info.IsOfficialBuild()) | |
213 version.append("-devel"); | |
214 return version; | |
215 } | 190 } |
216 | 191 |
217 void ChromeMetricsServiceClient::OnLogUploadComplete() { | 192 void ChromeMetricsServiceClient::OnLogUploadComplete() { |
218 // Collect network stats after each UMA upload. | 193 // Collect network stats after each UMA upload. |
219 network_stats_uploader_.CollectAndReportNetworkStats(); | 194 network_stats_uploader_.CollectAndReportNetworkStats(); |
220 } | 195 } |
221 | 196 |
222 void ChromeMetricsServiceClient::StartGatheringMetrics( | 197 void ChromeMetricsServiceClient::StartGatheringMetrics( |
223 const base::Closure& done_callback) { | 198 const base::Closure& done_callback) { |
224 finished_gathering_initial_metrics_callback_ = done_callback; | 199 finished_gathering_initial_metrics_callback_ = done_callback; |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 // Capture the histogram samples. | 570 // Capture the histogram samples. |
596 if (dumps_with_crash != 0) | 571 if (dumps_with_crash != 0) |
597 UMA_HISTOGRAM_COUNTS("Chrome.BrowserDumpsWithCrash", dumps_with_crash); | 572 UMA_HISTOGRAM_COUNTS("Chrome.BrowserDumpsWithCrash", dumps_with_crash); |
598 if (dumps_with_no_crash != 0) | 573 if (dumps_with_no_crash != 0) |
599 UMA_HISTOGRAM_COUNTS("Chrome.BrowserDumpsWithNoCrash", dumps_with_no_crash); | 574 UMA_HISTOGRAM_COUNTS("Chrome.BrowserDumpsWithNoCrash", dumps_with_no_crash); |
600 int total_dumps = dumps_with_crash + dumps_with_no_crash; | 575 int total_dumps = dumps_with_crash + dumps_with_no_crash; |
601 if (total_dumps != 0) | 576 if (total_dumps != 0) |
602 UMA_HISTOGRAM_COUNTS("Chrome.BrowserCrashDumpAttempts", total_dumps); | 577 UMA_HISTOGRAM_COUNTS("Chrome.BrowserCrashDumpAttempts", total_dumps); |
603 } | 578 } |
604 #endif // defined(OS_WIN) | 579 #endif // defined(OS_WIN) |
OLD | NEW |