Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 5 | #include "metrics_library.h" |
| 6 | |
Luigi Semenzato | 41c5450 | 2014-05-13 15:16:24 -0700 | [diff] [blame] | 7 | #include <base/logging.h> |
| 8 | #include <base/strings/stringprintf.h> |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 9 | #include <errno.h> |
| 10 | #include <sys/file.h> |
Ken Mixter | 4c5daa4 | 2010-08-26 18:35:06 -0700 | [diff] [blame] | 11 | #include <sys/stat.h> |
Darin Petkov | 4fcb2ac | 2010-04-15 16:40:23 -0700 | [diff] [blame] | 12 | |
| 13 | #include <cstdarg> |
| 14 | #include <cstdio> |
| 15 | #include <cstring> |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 16 | |
Chris Masone | e10b548 | 2013-02-14 12:15:35 -0800 | [diff] [blame] | 17 | // HANDLE_EINTR macro, no libbase required. |
| 18 | #include <base/posix/eintr_wrapper.h> |
| 19 | |
Ken Mixter | b2f1709 | 2011-07-22 14:59:51 -0700 | [diff] [blame] | 20 | #include "policy/device_policy.h" |
Darin Petkov | 8842c8c | 2011-02-24 12:48:30 -0800 | [diff] [blame] | 21 | |
Chih-Chung Chang | 6844c06 | 2013-04-01 14:27:39 +0800 | [diff] [blame] | 22 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 23 | |
Ken Mixter | 4c5daa4 | 2010-08-26 18:35:06 -0700 | [diff] [blame] | 24 | static const char kAutotestPath[] = "/var/log/metrics/autotest-events"; |
Luigi Semenzato | 31cda98 | 2014-05-19 08:30:42 -0700 | [diff] [blame] | 25 | static const char kUMAEventsPath[] = "/var/run/metrics/uma-events"; |
Ken Mixter | 4c5daa4 | 2010-08-26 18:35:06 -0700 | [diff] [blame] | 26 | static const char kConsentFile[] = "/home/chronos/Consent To Send Stats"; |
Darin Petkov | 4fcb2ac | 2010-04-15 16:40:23 -0700 | [diff] [blame] | 27 | static const int32_t kBufferSize = 1024; |
Luigi Semenzato | 3268422 | 2013-03-13 10:53:55 -0700 | [diff] [blame] | 28 | static const char kCrosEventHistogramName[] = "Platform.CrOSEvent"; |
| 29 | static const int kCrosEventHistogramMax = 100; |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 30 | |
Chih-Chung Chang | 6844c06 | 2013-04-01 14:27:39 +0800 | [diff] [blame] | 31 | /* Add new cros events here. |
| 32 | * |
| 33 | * The index of the event is sent in the message, so please do not |
| 34 | * reorder the names. |
| 35 | */ |
| 36 | static const char *kCrosEventNames[] = { |
| 37 | "ModemManagerCommandSendFailure", // 0 |
| 38 | "HwWatchdogReboot", // 1 |
| 39 | "Cras.NoCodecsFoundAtBoot", // 2 |
Darren Krahn | 6e55c115 | 2013-07-19 14:09:50 -0700 | [diff] [blame] | 40 | "Chaps.DatabaseCorrupted", // 3 |
| 41 | "Chaps.DatabaseRepairFailure", // 4 |
| 42 | "Chaps.DatabaseCreateFailure", // 5 |
Darren Krahn | 86830ba | 2013-07-26 13:37:20 -0700 | [diff] [blame] | 43 | "Attestation.OriginSpecificExhausted", // 6 |
Luigi Semenzato | e57398a | 2013-11-11 14:24:44 -0800 | [diff] [blame] | 44 | "SpringPowerSupply.Original.High", // 7 |
| 45 | "SpringPowerSupply.Other.High", // 8 |
Luigi Semenzato | e8fd968 | 2013-11-13 16:28:43 -0800 | [diff] [blame] | 46 | "SpringPowerSupply.Original.Low", // 9 |
| 47 | "SpringPowerSupply.ChargerIdle", // 10 |
Darren Krahn | 09a15fa | 2014-02-07 16:51:15 -0800 | [diff] [blame] | 48 | "TPM.NonZeroDictionaryAttackCounter", // 11 |
Chih-Chung Chang | 6844c06 | 2013-04-01 14:27:39 +0800 | [diff] [blame] | 49 | }; |
| 50 | |
Ken Mixter | 4c5daa4 | 2010-08-26 18:35:06 -0700 | [diff] [blame] | 51 | time_t MetricsLibrary::cached_enabled_time_ = 0; |
| 52 | bool MetricsLibrary::cached_enabled_ = false; |
| 53 | |
Darin Petkov | 8d3305e | 2011-02-25 14:19:30 -0800 | [diff] [blame] | 54 | // Copied from libbase to avoid pulling in all of libbase just for libmetrics. |
| 55 | static int WriteFileDescriptor(const int fd, const char* data, int size) { |
| 56 | // Allow for partial writes. |
| 57 | ssize_t bytes_written_total = 0; |
| 58 | for (ssize_t bytes_written_partial = 0; bytes_written_total < size; |
| 59 | bytes_written_total += bytes_written_partial) { |
| 60 | bytes_written_partial = |
| 61 | HANDLE_EINTR(write(fd, data + bytes_written_total, |
| 62 | size - bytes_written_total)); |
| 63 | if (bytes_written_partial < 0) |
| 64 | return -1; |
| 65 | } |
| 66 | |
| 67 | return bytes_written_total; |
| 68 | } |
| 69 | |
Luigi Semenzato | 41c5450 | 2014-05-13 15:16:24 -0700 | [diff] [blame] | 70 | MetricsLibrary::MetricsLibrary() : consent_file_(kConsentFile) {} |
Daniel Erat | fd15829 | 2014-03-09 21:39:08 -0700 | [diff] [blame] | 71 | MetricsLibrary::~MetricsLibrary() {} |
| 72 | |
Ken Mixter | eafbbdf | 2010-10-01 15:38:42 -0700 | [diff] [blame] | 73 | // We take buffer and buffer_size as parameters in order to simplify testing |
| 74 | // of various alignments of the |device_name| with |buffer_size|. |
| 75 | bool MetricsLibrary::IsDeviceMounted(const char* device_name, |
| 76 | const char* mounts_file, |
| 77 | char* buffer, |
| 78 | int buffer_size, |
| 79 | bool* result) { |
| 80 | if (buffer == NULL || buffer_size < 1) |
| 81 | return false; |
| 82 | int mounts_fd = open(mounts_file, O_RDONLY); |
| 83 | if (mounts_fd < 0) |
| 84 | return false; |
| 85 | // match_offset describes: |
| 86 | // -1 -- not beginning of line |
| 87 | // 0..strlen(device_name)-1 -- this offset in device_name is next to match |
| 88 | // strlen(device_name) -- matched full name, just need a space. |
| 89 | int match_offset = 0; |
| 90 | bool match = false; |
| 91 | while (!match) { |
| 92 | int read_size = read(mounts_fd, buffer, buffer_size); |
| 93 | if (read_size <= 0) { |
| 94 | if (errno == -EINTR) |
| 95 | continue; |
| 96 | break; |
| 97 | } |
| 98 | for (int i = 0; i < read_size; ++i) { |
| 99 | if (buffer[i] == '\n') { |
| 100 | match_offset = 0; |
| 101 | continue; |
| 102 | } |
| 103 | if (match_offset < 0) { |
| 104 | continue; |
| 105 | } |
| 106 | if (device_name[match_offset] == '\0') { |
| 107 | if (buffer[i] == ' ') { |
| 108 | match = true; |
| 109 | break; |
| 110 | } |
| 111 | match_offset = -1; |
| 112 | continue; |
| 113 | } |
| 114 | |
| 115 | if (buffer[i] == device_name[match_offset]) { |
| 116 | ++match_offset; |
| 117 | } else { |
| 118 | match_offset = -1; |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | close(mounts_fd); |
| 123 | *result = match; |
| 124 | return true; |
| 125 | } |
| 126 | |
| 127 | bool MetricsLibrary::IsGuestMode() { |
| 128 | char buffer[256]; |
| 129 | bool result = false; |
| 130 | if (!IsDeviceMounted("guestfs", |
| 131 | "/proc/mounts", |
| 132 | buffer, |
| 133 | sizeof(buffer), |
| 134 | &result)) { |
| 135 | return false; |
| 136 | } |
Arkaitz Ruiz Alvarez | 9f1a774 | 2011-05-26 12:22:22 -0700 | [diff] [blame] | 137 | return result && (access("/var/run/state/logged-in", F_OK) == 0); |
Ken Mixter | eafbbdf | 2010-10-01 15:38:42 -0700 | [diff] [blame] | 138 | } |
| 139 | |
Ken Mixter | 4c5daa4 | 2010-08-26 18:35:06 -0700 | [diff] [blame] | 140 | bool MetricsLibrary::AreMetricsEnabled() { |
Julian Pastarmov | 70b7abd | 2011-08-02 16:10:49 +0200 | [diff] [blame] | 141 | static struct stat stat_buffer; |
Ken Mixter | 4c5daa4 | 2010-08-26 18:35:06 -0700 | [diff] [blame] | 142 | time_t this_check_time = time(NULL); |
Ken Mixter | 4c5daa4 | 2010-08-26 18:35:06 -0700 | [diff] [blame] | 143 | if (this_check_time != cached_enabled_time_) { |
| 144 | cached_enabled_time_ = this_check_time; |
Julian Pastarmov | 70b7abd | 2011-08-02 16:10:49 +0200 | [diff] [blame] | 145 | |
| 146 | if (!policy_provider_.get()) |
| 147 | policy_provider_.reset(new policy::PolicyProvider()); |
Julian Pastarmov | d605a00 | 2013-02-04 17:58:14 +0100 | [diff] [blame] | 148 | policy_provider_->Reload(); |
Julian Pastarmov | 70b7abd | 2011-08-02 16:10:49 +0200 | [diff] [blame] | 149 | // We initialize with the default value which is false and will be preserved |
| 150 | // if the policy is not set. |
| 151 | bool enabled = false; |
| 152 | bool has_policy = false; |
| 153 | if (policy_provider_->device_policy_is_loaded()) { |
| 154 | has_policy = |
| 155 | policy_provider_->GetDevicePolicy().GetMetricsEnabled(&enabled); |
| 156 | } |
| 157 | // If policy couldn't be loaded or the metrics policy is not set we should |
| 158 | // still respect the consent file if it is present for migration purposes. |
| 159 | // TODO(pastarmovj) |
| 160 | if (!has_policy) { |
Luigi Semenzato | 41c5450 | 2014-05-13 15:16:24 -0700 | [diff] [blame] | 161 | enabled = stat(consent_file_.c_str(), &stat_buffer) >= 0; |
Julian Pastarmov | 70b7abd | 2011-08-02 16:10:49 +0200 | [diff] [blame] | 162 | } |
| 163 | |
Ken Mixter | b2f1709 | 2011-07-22 14:59:51 -0700 | [diff] [blame] | 164 | if (enabled && !IsGuestMode()) |
Ken Mixter | eafbbdf | 2010-10-01 15:38:42 -0700 | [diff] [blame] | 165 | cached_enabled_ = true; |
| 166 | else |
| 167 | cached_enabled_ = false; |
Ken Mixter | 4c5daa4 | 2010-08-26 18:35:06 -0700 | [diff] [blame] | 168 | } |
| 169 | return cached_enabled_; |
| 170 | } |
Darin Petkov | 11b8eb3 | 2010-05-18 11:00:59 -0700 | [diff] [blame] | 171 | |
Luigi Semenzato | 31cda98 | 2014-05-19 08:30:42 -0700 | [diff] [blame] | 172 | bool MetricsLibrary::SendMessageToChrome(const std::string& message) { |
Luigi Semenzato | 41c5450 | 2014-05-13 15:16:24 -0700 | [diff] [blame] | 173 | int size = static_cast<int>(message.size()); |
| 174 | if (size > kBufferSize) { |
| 175 | LOG(ERROR) << "chrome message too big (" << size << " bytes)"; |
| 176 | return false; |
| 177 | } |
| 178 | // Use libc here instead of chromium base classes because we need a UNIX fd |
Luigi Semenzato | a5db220 | 2014-05-23 15:06:24 -0700 | [diff] [blame] | 179 | // for flock. |uma_events_file_| must exist already. |
Luigi Semenzato | 31cda98 | 2014-05-19 08:30:42 -0700 | [diff] [blame] | 180 | int chrome_fd = HANDLE_EINTR(open(uma_events_file_.c_str(), |
Luigi Semenzato | a5db220 | 2014-05-23 15:06:24 -0700 | [diff] [blame] | 181 | O_WRONLY | O_APPEND)); |
Darin Petkov | 4fcb2ac | 2010-04-15 16:40:23 -0700 | [diff] [blame] | 182 | // If we failed to open it, return. |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 183 | if (chrome_fd < 0) { |
Luigi Semenzato | 31cda98 | 2014-05-19 08:30:42 -0700 | [diff] [blame] | 184 | PLOG(ERROR) << uma_events_file_ << ": open"; |
Darin Petkov | 4fcb2ac | 2010-04-15 16:40:23 -0700 | [diff] [blame] | 185 | return false; |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 186 | } |
| 187 | |
Darin Petkov | 4fcb2ac | 2010-04-15 16:40:23 -0700 | [diff] [blame] | 188 | // Grab an exclusive lock to protect Chrome from truncating |
Luigi Semenzato | 41c5450 | 2014-05-13 15:16:24 -0700 | [diff] [blame] | 189 | // underneath us. |
Darin Petkov | 8842c8c | 2011-02-24 12:48:30 -0800 | [diff] [blame] | 190 | if (HANDLE_EINTR(flock(chrome_fd, LOCK_EX)) < 0) { |
Luigi Semenzato | 31cda98 | 2014-05-19 08:30:42 -0700 | [diff] [blame] | 191 | PLOG(ERROR) << uma_events_file_ << ": flock"; |
Mike Frysinger | 3e8a851 | 2014-05-14 16:14:37 -0400 | [diff] [blame] | 192 | IGNORE_EINTR(close(chrome_fd)); |
Darin Petkov | 4fcb2ac | 2010-04-15 16:40:23 -0700 | [diff] [blame] | 193 | return false; |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 194 | } |
| 195 | |
Darin Petkov | 4fcb2ac | 2010-04-15 16:40:23 -0700 | [diff] [blame] | 196 | bool success = true; |
Luigi Semenzato | 41c5450 | 2014-05-13 15:16:24 -0700 | [diff] [blame] | 197 | if (WriteFileDescriptor(chrome_fd, message.c_str(), size) != size) { |
Luigi Semenzato | 31cda98 | 2014-05-19 08:30:42 -0700 | [diff] [blame] | 198 | PLOG(ERROR) << uma_events_file_ << ": write"; |
Darin Petkov | 4fcb2ac | 2010-04-15 16:40:23 -0700 | [diff] [blame] | 199 | success = false; |
| 200 | } |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 201 | |
Darin Petkov | 8842c8c | 2011-02-24 12:48:30 -0800 | [diff] [blame] | 202 | // Close the file and release the lock. |
Mike Frysinger | 3e8a851 | 2014-05-14 16:14:37 -0400 | [diff] [blame] | 203 | IGNORE_EINTR(close(chrome_fd)); |
Darin Petkov | 4fcb2ac | 2010-04-15 16:40:23 -0700 | [diff] [blame] | 204 | return success; |
| 205 | } |
| 206 | |
Luigi Semenzato | 41c5450 | 2014-05-13 15:16:24 -0700 | [diff] [blame] | 207 | const std::string MetricsLibrary::FormatChromeMessage( |
| 208 | const std::string& name, |
| 209 | const std::string& value) { |
| 210 | uint32 message_length = |
| 211 | sizeof(message_length) + name.size() + 1 + value.size() + 1; |
| 212 | std::string result; |
| 213 | result.reserve(message_length); |
| 214 | // Marshal the total message length in the native byte order. |
| 215 | result.assign(reinterpret_cast<char*>(&message_length), |
| 216 | sizeof(message_length)); |
| 217 | result += name + '\0' + value + '\0'; |
| 218 | return result; |
Darin Petkov | 4fcb2ac | 2010-04-15 16:40:23 -0700 | [diff] [blame] | 219 | } |
| 220 | |
Darin Petkov | fc91b42 | 2010-05-12 13:05:45 -0700 | [diff] [blame] | 221 | void MetricsLibrary::Init() { |
Darin Petkov | 11b8eb3 | 2010-05-18 11:00:59 -0700 | [diff] [blame] | 222 | uma_events_file_ = kUMAEventsPath; |
Darin Petkov | fc91b42 | 2010-05-12 13:05:45 -0700 | [diff] [blame] | 223 | } |
| 224 | |
Luigi Semenzato | 41c5450 | 2014-05-13 15:16:24 -0700 | [diff] [blame] | 225 | bool MetricsLibrary::SendToAutotest(const std::string& name, int value) { |
David James | 3b3add5 | 2010-06-04 15:01:19 -0700 | [diff] [blame] | 226 | FILE* autotest_file = fopen(kAutotestPath, "a+"); |
Darin Petkov | 4fcb2ac | 2010-04-15 16:40:23 -0700 | [diff] [blame] | 227 | if (autotest_file == NULL) { |
Luigi Semenzato | 41c5450 | 2014-05-13 15:16:24 -0700 | [diff] [blame] | 228 | PLOG(ERROR) << kAutotestPath << ": fopen"; |
Darin Petkov | 4fcb2ac | 2010-04-15 16:40:23 -0700 | [diff] [blame] | 229 | return false; |
| 230 | } |
| 231 | |
| 232 | fprintf(autotest_file, "%s=%d\n", name.c_str(), value); |
| 233 | fclose(autotest_file); |
| 234 | return true; |
| 235 | } |
| 236 | |
Luigi Semenzato | 41c5450 | 2014-05-13 15:16:24 -0700 | [diff] [blame] | 237 | bool MetricsLibrary::SendToUMA(const std::string& name, |
| 238 | int sample, |
| 239 | int min, |
| 240 | int max, |
| 241 | int nbuckets) { |
Darin Petkov | 4fcb2ac | 2010-04-15 16:40:23 -0700 | [diff] [blame] | 242 | // Format the message. |
Luigi Semenzato | 41c5450 | 2014-05-13 15:16:24 -0700 | [diff] [blame] | 243 | std::string value = base::StringPrintf("%s %d %d %d %d", |
| 244 | name.c_str(), sample, min, max, nbuckets); |
| 245 | std::string message = FormatChromeMessage("histogram", value); |
Darin Petkov | 4fcb2ac | 2010-04-15 16:40:23 -0700 | [diff] [blame] | 246 | // Send the message. |
Luigi Semenzato | 41c5450 | 2014-05-13 15:16:24 -0700 | [diff] [blame] | 247 | return SendMessageToChrome(message); |
Darin Petkov | 65b0146 | 2010-04-14 13:32:20 -0700 | [diff] [blame] | 248 | } |
Darin Petkov | 5b7dce1 | 2010-04-21 15:45:10 -0700 | [diff] [blame] | 249 | |
Darin Petkov | 21cd2c5 | 2010-05-12 15:26:16 -0700 | [diff] [blame] | 250 | bool MetricsLibrary::SendEnumToUMA(const std::string& name, int sample, |
| 251 | int max) { |
Darin Petkov | 5b7dce1 | 2010-04-21 15:45:10 -0700 | [diff] [blame] | 252 | // Format the message. |
Luigi Semenzato | 41c5450 | 2014-05-13 15:16:24 -0700 | [diff] [blame] | 253 | std::string value = base::StringPrintf("%s %d %d", name.c_str(), sample, max); |
| 254 | std::string message = FormatChromeMessage("linearhistogram", value); |
Darin Petkov | ed82485 | 2011-01-06 10:51:47 -0800 | [diff] [blame] | 255 | // Send the message. |
Luigi Semenzato | 41c5450 | 2014-05-13 15:16:24 -0700 | [diff] [blame] | 256 | return SendMessageToChrome(message); |
Darin Petkov | ed82485 | 2011-01-06 10:51:47 -0800 | [diff] [blame] | 257 | } |
| 258 | |
Luigi Semenzato | a7ebeb3 | 2013-03-19 15:02:42 -0700 | [diff] [blame] | 259 | bool MetricsLibrary::SendSparseToUMA(const std::string& name, int sample) { |
| 260 | // Format the message. |
Luigi Semenzato | 41c5450 | 2014-05-13 15:16:24 -0700 | [diff] [blame] | 261 | std::string value = base::StringPrintf("%s %d", name.c_str(), sample); |
| 262 | std::string message = FormatChromeMessage("sparsehistogram", value); |
Luigi Semenzato | a7ebeb3 | 2013-03-19 15:02:42 -0700 | [diff] [blame] | 263 | // Send the message. |
Luigi Semenzato | 41c5450 | 2014-05-13 15:16:24 -0700 | [diff] [blame] | 264 | return SendMessageToChrome(message); |
Luigi Semenzato | a7ebeb3 | 2013-03-19 15:02:42 -0700 | [diff] [blame] | 265 | } |
| 266 | |
Darin Petkov | ed82485 | 2011-01-06 10:51:47 -0800 | [diff] [blame] | 267 | bool MetricsLibrary::SendUserActionToUMA(const std::string& action) { |
| 268 | // Format the message. |
Luigi Semenzato | 41c5450 | 2014-05-13 15:16:24 -0700 | [diff] [blame] | 269 | std::string message = FormatChromeMessage("useraction", action); |
Darin Petkov | 5b7dce1 | 2010-04-21 15:45:10 -0700 | [diff] [blame] | 270 | // Send the message. |
Luigi Semenzato | 41c5450 | 2014-05-13 15:16:24 -0700 | [diff] [blame] | 271 | return SendMessageToChrome(message); |
Darin Petkov | 5b7dce1 | 2010-04-21 15:45:10 -0700 | [diff] [blame] | 272 | } |
Ken Mixter | be2e13b | 2011-01-22 06:15:56 -0800 | [diff] [blame] | 273 | |
| 274 | bool MetricsLibrary::SendCrashToUMA(const char *crash_kind) { |
| 275 | // Format the message. |
Luigi Semenzato | 41c5450 | 2014-05-13 15:16:24 -0700 | [diff] [blame] | 276 | std::string message = FormatChromeMessage("crash", crash_kind); |
Ken Mixter | be2e13b | 2011-01-22 06:15:56 -0800 | [diff] [blame] | 277 | // Send the message. |
Luigi Semenzato | 41c5450 | 2014-05-13 15:16:24 -0700 | [diff] [blame] | 278 | return SendMessageToChrome(message); |
Ken Mixter | be2e13b | 2011-01-22 06:15:56 -0800 | [diff] [blame] | 279 | } |
Ken Mixter | b2f1709 | 2011-07-22 14:59:51 -0700 | [diff] [blame] | 280 | |
| 281 | void MetricsLibrary::SetPolicyProvider(policy::PolicyProvider* provider) { |
| 282 | policy_provider_.reset(provider); |
| 283 | } |
Luigi Semenzato | 3268422 | 2013-03-13 10:53:55 -0700 | [diff] [blame] | 284 | |
| 285 | bool MetricsLibrary::SendCrosEventToUMA(const std::string& event) { |
Chih-Chung Chang | 6844c06 | 2013-04-01 14:27:39 +0800 | [diff] [blame] | 286 | for (size_t i = 0; i < ARRAY_SIZE(kCrosEventNames); i++) { |
| 287 | if (strcmp(event.c_str(), kCrosEventNames[i]) == 0) { |
| 288 | return SendEnumToUMA(kCrosEventHistogramName, i, kCrosEventHistogramMax); |
| 289 | } |
Luigi Semenzato | 3268422 | 2013-03-13 10:53:55 -0700 | [diff] [blame] | 290 | } |
Chih-Chung Chang | 6844c06 | 2013-04-01 14:27:39 +0800 | [diff] [blame] | 291 | return false; |
Luigi Semenzato | 3268422 | 2013-03-13 10:53:55 -0700 | [diff] [blame] | 292 | } |