OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/metrics_log.h" | 5 #include "chrome/browser/metrics/metrics_log.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 | 102 |
103 { | 103 { |
104 OPEN_ELEMENT_FOR_SCOPE("stability"); // Minimal set of stability elements. | 104 OPEN_ELEMENT_FOR_SCOPE("stability"); // Minimal set of stability elements. |
105 WriteRequiredStabilityAttributes(pref); | 105 WriteRequiredStabilityAttributes(pref); |
106 WriteRealtimeStabilityAttributes(pref); | 106 WriteRealtimeStabilityAttributes(pref); |
107 | 107 |
108 WritePluginStabilityElements(pref); | 108 WritePluginStabilityElements(pref); |
109 } | 109 } |
110 } | 110 } |
111 | 111 |
112 void MetricsLog::WriteStabilityElement() { | 112 void MetricsLog::WriteStabilityElement(PrefService* pref) { |
jar (doing other things)
2011/01/14 02:31:47
Why did you decide to pass this in? Does this fac
kmixter1
2011/01/15 22:21:07
Exactly. So I can unit test what this function ou
| |
113 DCHECK(!locked_); | 113 DCHECK(!locked_); |
114 | 114 |
115 PrefService* pref = g_browser_process->local_state(); | |
116 DCHECK(pref); | 115 DCHECK(pref); |
117 | 116 |
118 // Get stability attributes out of Local State, zeroing out stored values. | 117 // Get stability attributes out of Local State, zeroing out stored values. |
119 // NOTE: This could lead to some data loss if this report isn't successfully | 118 // NOTE: This could lead to some data loss if this report isn't successfully |
120 // sent, but that's true for all the metrics. | 119 // sent, but that's true for all the metrics. |
121 | 120 |
122 OPEN_ELEMENT_FOR_SCOPE("stability"); | 121 OPEN_ELEMENT_FOR_SCOPE("stability"); |
123 WriteRequiredStabilityAttributes(pref); | 122 WriteRequiredStabilityAttributes(pref); |
124 WriteRealtimeStabilityAttributes(pref); | 123 WriteRealtimeStabilityAttributes(pref); |
125 | 124 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 WriteIntAttribute("rendererhangcount", count); | 224 WriteIntAttribute("rendererhangcount", count); |
226 pref->SetInteger(prefs::kStabilityRendererHangCount, 0); | 225 pref->SetInteger(prefs::kStabilityRendererHangCount, 0); |
227 } | 226 } |
228 | 227 |
229 count = pref->GetInteger(prefs::kStabilityChildProcessCrashCount); | 228 count = pref->GetInteger(prefs::kStabilityChildProcessCrashCount); |
230 if (count) { | 229 if (count) { |
231 WriteIntAttribute("childprocesscrashcount", count); | 230 WriteIntAttribute("childprocesscrashcount", count); |
232 pref->SetInteger(prefs::kStabilityChildProcessCrashCount, 0); | 231 pref->SetInteger(prefs::kStabilityChildProcessCrashCount, 0); |
233 } | 232 } |
234 | 233 |
234 #if defined(OS_CHROMEOS) | |
235 count = pref->GetInteger(prefs::kStabilityOtherUserCrashCount); | |
236 if (count) { | |
237 // TODO(kmixter): Write attribute once log server supports it | |
238 // and remove warning log. | |
239 // WriteIntAttribute("otherusercrashcount", count); | |
240 LOG(WARNING) << "Not yet able to send otherusercrashcount=" | |
241 << count; | |
242 pref->SetInteger(prefs::kStabilityOtherUserCrashCount, 0); | |
243 } | |
244 | |
245 count = pref->GetInteger(prefs::kStabilityKernelCrashCount); | |
246 if (count) { | |
247 // TODO(kmixter): Write attribute once log server supports it | |
248 // and remove warning log. | |
249 // WriteIntAttribute("kernelcrashcount", count); | |
250 LOG(WARNING) << "Not yet able to send kernelcrashcount=" | |
251 << count; | |
252 pref->SetInteger(prefs::kStabilityKernelCrashCount, 0); | |
253 } | |
254 | |
255 count = pref->GetInteger(prefs::kStabilitySystemUncleanShutdownCount); | |
256 if (count) { | |
257 // TODO(kmixter): Write attribute once log server supports it | |
258 // and remove warning log. | |
259 // WriteIntAttribute("systemuncleanshutdowns", count); | |
260 LOG(WARNING) << "Not yet able to send systemuncleanshutdowns=" | |
261 << count; | |
262 pref->SetInteger(prefs::kStabilitySystemUncleanShutdownCount, 0); | |
263 } | |
264 #endif // OS_CHROMEOS | |
265 | |
235 int64 recent_duration = GetIncrementalUptime(pref); | 266 int64 recent_duration = GetIncrementalUptime(pref); |
236 if (recent_duration) | 267 if (recent_duration) |
237 WriteInt64Attribute("uptimesec", recent_duration); | 268 WriteInt64Attribute("uptimesec", recent_duration); |
238 } | 269 } |
239 | 270 |
240 void MetricsLog::WritePluginList( | 271 void MetricsLog::WritePluginList( |
241 const std::vector<webkit::npapi::WebPluginInfo>& plugin_list) { | 272 const std::vector<webkit::npapi::WebPluginInfo>& plugin_list) { |
242 DCHECK(!locked_); | 273 DCHECK(!locked_); |
243 | 274 |
244 OPEN_ELEMENT_FOR_SCOPE("plugins"); | 275 OPEN_ELEMENT_FOR_SCOPE("plugins"); |
(...skipping 25 matching lines...) Expand all Loading... | |
270 | 301 |
271 PrefService* pref = g_browser_process->local_state(); | 302 PrefService* pref = g_browser_process->local_state(); |
272 | 303 |
273 OPEN_ELEMENT_FOR_SCOPE("profile"); | 304 OPEN_ELEMENT_FOR_SCOPE("profile"); |
274 WriteCommonEventAttributes(); | 305 WriteCommonEventAttributes(); |
275 | 306 |
276 WriteInstallElement(); | 307 WriteInstallElement(); |
277 | 308 |
278 WritePluginList(plugin_list); | 309 WritePluginList(plugin_list); |
279 | 310 |
280 WriteStabilityElement(); | 311 WriteStabilityElement(pref); |
281 | 312 |
282 { | 313 { |
283 OPEN_ELEMENT_FOR_SCOPE("cpu"); | 314 OPEN_ELEMENT_FOR_SCOPE("cpu"); |
284 WriteAttribute("arch", base::SysInfo::CPUArchitecture()); | 315 WriteAttribute("arch", base::SysInfo::CPUArchitecture()); |
285 } | 316 } |
286 | 317 |
287 { | 318 { |
288 OPEN_ELEMENT_FOR_SCOPE("memory"); | 319 OPEN_ELEMENT_FOR_SCOPE("memory"); |
289 WriteIntAttribute("mb", base::SysInfo::AmountOfPhysicalMemoryMB()); | 320 WriteIntAttribute("mb", base::SysInfo::AmountOfPhysicalMemoryMB()); |
290 #if defined(OS_WIN) | 321 #if defined(OS_WIN) |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
449 const std::string result_type(AutocompleteMatch::TypeToString(i->type)); | 480 const std::string result_type(AutocompleteMatch::TypeToString(i->type)); |
450 if (!result_type.empty()) | 481 if (!result_type.empty()) |
451 WriteAttribute("resulttype", result_type); | 482 WriteAttribute("resulttype", result_type); |
452 WriteIntAttribute("relevance", i->relevance); | 483 WriteIntAttribute("relevance", i->relevance); |
453 WriteIntAttribute("isstarred", i->starred ? 1 : 0); | 484 WriteIntAttribute("isstarred", i->starred ? 1 : 0); |
454 } | 485 } |
455 } | 486 } |
456 | 487 |
457 ++num_events_; | 488 ++num_events_; |
458 } | 489 } |
OLD | NEW |