Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(588)

Side by Side Diff: src/platform/metrics/metrics_library.cc

Issue 2037011: Remove the deprecated static metrics APIs. (Closed) Base URL: ssh://git@chromiumos-git/chromeos
Patch Set: Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 /*
6 * metrics_library.cc
7 *
8 * Created on: Dec 1, 2009
9 * Author: sosa
10 */
11
12 #include "metrics_library.h" 5 #include "metrics_library.h"
13 6
14 #include <errno.h> 7 #include <errno.h>
15 #include <sys/file.h> 8 #include <sys/file.h>
16 9
17 #include <cstdarg> 10 #include <cstdarg>
18 #include <cstdio> 11 #include <cstdio>
19 #include <cstring> 12 #include <cstring>
20 13
21 #define READ_WRITE_ALL_FILE_FLAGS \ 14 #define READ_WRITE_ALL_FILE_FLAGS \
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 if (autotest_file == NULL) { 123 if (autotest_file == NULL) {
131 PrintError("fopen", kAutotestPath, errno); 124 PrintError("fopen", kAutotestPath, errno);
132 return false; 125 return false;
133 } 126 }
134 127
135 fprintf(autotest_file, "%s=%d\n", name.c_str(), value); 128 fprintf(autotest_file, "%s=%d\n", name.c_str(), value);
136 fclose(autotest_file); 129 fclose(autotest_file);
137 return true; 130 return true;
138 } 131 }
139 132
140 // static 133 bool MetricsLibrary::SendToUMA(const string& name, int sample,
141 bool MetricsLibrary::SendToChrome(const string& name, int sample, 134 int min, int max, int nbuckets) {
142 int min, int max, int nbuckets) {
143 // Format the message. 135 // Format the message.
144 char message[kBufferSize]; 136 char message[kBufferSize];
145 int32_t message_length = 137 int32_t message_length =
146 FormatChromeMessage(kBufferSize, message, 138 FormatChromeMessage(kBufferSize, message,
147 "histogram%c%s %d %d %d %d", '\0', 139 "histogram%c%s %d %d %d %d", '\0',
148 name.c_str(), sample, min, max, nbuckets); 140 name.c_str(), sample, min, max, nbuckets);
149 141
150 if (message_length < 0) 142 if (message_length < 0)
151 return false; 143 return false;
152 144
153 // Send the message. 145 // Send the message.
154 return SendMessageToChrome(message_length, message); 146 return SendMessageToChrome(message_length, message);
155 } 147 }
156 148
157 bool MetricsLibrary::SendToUMA(const string& name, int sample, 149 bool MetricsLibrary::SendEnumToUMA(const std::string& name, int sample,
158 int min, int max, int nbuckets) { 150 int max) {
159 return SendToChrome(name, sample, min, max, nbuckets);
160 }
161
162 //static
163 bool MetricsLibrary::SendEnumToChrome(const std::string& name, int sample,
164 int max) {
165 // Format the message. 151 // Format the message.
166 char message[kBufferSize]; 152 char message[kBufferSize];
167 int32_t message_length = 153 int32_t message_length =
168 FormatChromeMessage(kBufferSize, message, 154 FormatChromeMessage(kBufferSize, message,
169 "linearhistogram%c%s %d %d", '\0', 155 "linearhistogram%c%s %d %d", '\0',
170 name.c_str(), sample, max); 156 name.c_str(), sample, max);
171 157
172 if (message_length < 0) 158 if (message_length < 0)
173 return false; 159 return false;
174 160
175 // Send the message. 161 // Send the message.
176 return SendMessageToChrome(message_length, message); 162 return SendMessageToChrome(message_length, message);
177 } 163 }
178
179 bool MetricsLibrary::SendEnumToUMA(const std::string& name, int sample,
180 int max) {
181 return SendEnumToChrome(name, sample, max);
182 }
OLDNEW
« src/platform/metrics/metrics_library.h ('K') | « src/platform/metrics/metrics_library.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698