OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 static bool IsFeedbackAllowed() { | 47 static bool IsFeedbackAllowed() { |
48 return s_metrics_lib.AreMetricsEnabled(); | 48 return s_metrics_lib.AreMetricsEnabled(); |
49 } | 49 } |
50 | 50 |
51 static bool TouchFile(const FilePath &file_path) { | 51 static bool TouchFile(const FilePath &file_path) { |
52 return file_util::WriteFile(file_path, "", 0) == 0; | 52 return file_util::WriteFile(file_path, "", 0) == 0; |
53 } | 53 } |
54 | 54 |
55 static void CountKernelCrash() { | 55 static void CountKernelCrash() { |
| 56 // TODO(kmixter): We can remove this histogram as part of |
| 57 // crosbug.com/11163. |
56 s_metrics_lib.SendEnumToUMA(std::string(kCrashCounterHistogram), | 58 s_metrics_lib.SendEnumToUMA(std::string(kCrashCounterHistogram), |
57 kCrashKindKernel, | 59 kCrashKindKernel, |
58 kCrashKindMax); | 60 kCrashKindMax); |
| 61 s_metrics_lib.SendCrashToUMA("kernel"); |
59 } | 62 } |
60 | 63 |
61 static void CountUncleanShutdown() { | 64 static void CountUncleanShutdown() { |
| 65 // TODO(kmixter): We can remove this histogram as part of |
| 66 // crosbug.com/11163. |
62 s_metrics_lib.SendEnumToUMA(std::string(kCrashCounterHistogram), | 67 s_metrics_lib.SendEnumToUMA(std::string(kCrashCounterHistogram), |
63 kCrashKindUncleanShutdown, | 68 kCrashKindUncleanShutdown, |
64 kCrashKindMax); | 69 kCrashKindMax); |
| 70 s_metrics_lib.SendCrashToUMA("uncleanshutdown"); |
65 } | 71 } |
66 | 72 |
67 static void CountUserCrash() { | 73 static void CountUserCrash() { |
| 74 // TODO(kmixter): We can remove this histogram as part of |
| 75 // crosbug.com/11163. |
68 s_metrics_lib.SendEnumToUMA(std::string(kCrashCounterHistogram), | 76 s_metrics_lib.SendEnumToUMA(std::string(kCrashCounterHistogram), |
69 kCrashKindUser, | 77 kCrashKindUser, |
70 kCrashKindMax); | 78 kCrashKindMax); |
| 79 s_metrics_lib.SendCrashToUMA("user"); |
71 std::string command = StringPrintf( | 80 std::string command = StringPrintf( |
72 "/usr/bin/dbus-send --type=signal --system / \"%s\" &", | 81 "/usr/bin/dbus-send --type=signal --system / \"%s\" &", |
73 kUserCrashSignal); | 82 kUserCrashSignal); |
74 // Announce through D-Bus whenever a user crash happens. This is | 83 // Announce through D-Bus whenever a user crash happens. This is |
75 // used by the metrics daemon to log active use time between | 84 // used by the metrics daemon to log active use time between |
76 // crashes. | 85 // crashes. |
77 // | 86 // |
78 // This could be done more efficiently by explicit fork/exec or | 87 // This could be done more efficiently by explicit fork/exec or |
79 // using a dbus library directly. However, this should run | 88 // using a dbus library directly. However, this should run |
80 // relatively rarely and longer term we may need to implement a | 89 // relatively rarely and longer term we may need to implement a |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 user_collector.Disable(); | 214 user_collector.Disable(); |
206 return 0; | 215 return 0; |
207 } | 216 } |
208 | 217 |
209 if (!FLAGS_generate_kernel_signature.empty()) { | 218 if (!FLAGS_generate_kernel_signature.empty()) { |
210 return GenerateKernelSignature(&kernel_collector); | 219 return GenerateKernelSignature(&kernel_collector); |
211 } | 220 } |
212 | 221 |
213 return HandleUserCrash(&user_collector); | 222 return HandleUserCrash(&user_collector); |
214 } | 223 } |
OLD | NEW |