summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/chromeos/external_metrics.cc88
-rw-r--r--chrome/browser/chromeos/external_metrics_unittest.cc34
2 files changed, 111 insertions, 11 deletions
diff --git a/chrome/browser/chromeos/external_metrics.cc b/chrome/browser/chromeos/external_metrics.cc
index b97dbb1..3eb8936 100644
--- a/chrome/browser/chromeos/external_metrics.cc
+++ b/chrome/browser/chromeos/external_metrics.cc
@@ -21,6 +21,18 @@
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/profile.h"
+// Steps to add a stat:
+//
+// 1. Enter the stat in the function_table_ (specify histogram or action).
+// Note that the macros concatenate strings. Also note that stat names must be
+// in alphabetical order (there is an init-time test but only for debug
+// builds).
+//
+// 2. Enter a helper function that calls either one of the UMA_HISTOGRAM
+// macros, or UserMetrics::RecordAction.
+//
+// 3. Enjoy the recompilation.
+
namespace chromeos {
// The interval between external metrics collections, in milliseconds.
@@ -49,7 +61,7 @@ static void RecordBootTime(const char* info) {
base::TimeDelta::FromMilliseconds(time),
base::TimeDelta::FromSeconds(0),
base::TimeDelta::FromSeconds(60),
- 100);
+ 50);
}
static void RecordUpTime(const char* info) {
@@ -58,6 +70,66 @@ static void RecordUpTime(const char* info) {
base::TimeDelta::FromSeconds(time));
}
+static void RecordConnmanIdle(const char* info) {
+ int64 time = atol(info);
+ UMA_HISTOGRAM_LONG_TIMES("ChromeOS.Net.Connman.Idle",
+ base::TimeDelta::FromMilliseconds(time));
+}
+
+static void RecordConnmanOffline(const char* info) {
+ int64 time = atol(info);
+ UMA_HISTOGRAM_LONG_TIMES("ChromeOS.Net.Connman.Offline",
+ base::TimeDelta::FromMilliseconds(time));
+}
+
+static void RecordConnmanOnline(const char* info) {
+ int64 time = atol(info);
+ UMA_HISTOGRAM_LONG_TIMES("ChromeOS.Net.Connman.Online",
+ base::TimeDelta::FromMilliseconds(time));
+}
+
+static void RecordConnmanReady(const char* info) {
+ int64 time = atol(info);
+ UMA_HISTOGRAM_LONG_TIMES("ChromeOS.Net.Connman.Ready",
+ base::TimeDelta::FromMilliseconds(time));
+}
+
+static void RecordConnmanAssociation(const char* info) {
+ int64 time = atol(info);
+ UMA_HISTOGRAM_CUSTOM_TIMES("ChromeOS.Net.Connman.Association",
+ base::TimeDelta::FromMilliseconds(time),
+ base::TimeDelta::FromSeconds(0),
+ base::TimeDelta::FromSeconds(120),
+ 50);
+}
+
+static void RecordConnmanConfiguration(const char* info) {
+ int64 time = atol(info);
+ UMA_HISTOGRAM_CUSTOM_TIMES("ChromeOS.Net.Connman.Configuration",
+ base::TimeDelta::FromMilliseconds(time),
+ base::TimeDelta::FromSeconds(0),
+ base::TimeDelta::FromSeconds(120),
+ 50);
+}
+
+static void RecordConnmanDisconnect(const char* info) {
+ int64 time = atol(info);
+ UMA_HISTOGRAM_CUSTOM_TIMES("ChromeOS.Net.Connman.Disconnect",
+ base::TimeDelta::FromMilliseconds(time),
+ base::TimeDelta::FromSeconds(0),
+ base::TimeDelta::FromSeconds(30),
+ 50);
+}
+
+static void RecordConnmanFailure(const char* info) {
+ int64 time = atol(info);
+ UMA_HISTOGRAM_CUSTOM_TIMES("ChromeOS.Net.Connman.Failure",
+ base::TimeDelta::FromMilliseconds(time),
+ base::TimeDelta::FromSeconds(0),
+ base::TimeDelta::FromSeconds(30),
+ 50);
+}
+
void ExternalMetrics::Start(Profile* profile) {
DCHECK(external_metrics_profile == NULL);
external_metrics_profile = profile;
@@ -83,9 +155,17 @@ void ExternalMetrics::RecordActionWrapper(RecordFunctionType f) {
ExternalMetrics::RecordFunctionTableEntry ExternalMetrics::function_table_[] = {
// These entries MUST be in alphabetical order.
- RF_ENTRY(BootTime, EVENT_TYPE_HISTOGRAM),
- RF_ENTRY(TabOverviewExitMouse, EVENT_TYPE_ACTION),
- RF_ENTRY(TabOverviewKeystroke, EVENT_TYPE_ACTION),
+ RF_ENTRY(BootTime, EVENT_TYPE_HISTOGRAM),
+ RF_ENTRY(ConnmanAssociation, EVENT_TYPE_HISTOGRAM),
+ RF_ENTRY(ConnmanConfiguration, EVENT_TYPE_HISTOGRAM),
+ RF_ENTRY(ConnmanDisconnect, EVENT_TYPE_HISTOGRAM),
+ RF_ENTRY(ConnmanFailure, EVENT_TYPE_HISTOGRAM),
+ RF_ENTRY(ConnmanIdle, EVENT_TYPE_HISTOGRAM),
+ RF_ENTRY(ConnmanOffline, EVENT_TYPE_HISTOGRAM),
+ RF_ENTRY(ConnmanOnline, EVENT_TYPE_HISTOGRAM),
+ RF_ENTRY(ConnmanReady, EVENT_TYPE_HISTOGRAM),
+ RF_ENTRY(TabOverviewExitMouse, EVENT_TYPE_ACTION),
+ RF_ENTRY(TabOverviewKeystroke, EVENT_TYPE_ACTION),
RF_ENTRY(UpTime, EVENT_TYPE_HISTOGRAM),
};
diff --git a/chrome/browser/chromeos/external_metrics_unittest.cc b/chrome/browser/chromeos/external_metrics_unittest.cc
index a1853c9..297954d 100644
--- a/chrome/browser/chromeos/external_metrics_unittest.cc
+++ b/chrome/browser/chromeos/external_metrics_unittest.cc
@@ -53,6 +53,21 @@ TEST(ExternalMetricsTest, ParseExternalMetricsFile) {
{"BootTime", "9500"},
{"BootTime", "10000"},
{"BootTime", "9200"},
+ {"TabOverviewExitMouse", ""},
+ {"ConnmanIdle", "1000"},
+ {"ConnmanIdle", "1200"},
+ {"TabOverviewKeystroke", ""},
+ {"ConnmanDisconnect", "1000"},
+ {"ConnmanFailure", "1000"},
+ {"ConnmanFailure", "1300"},
+ {"ConnmanAssociation", "1000"},
+ {"ConnmanConfiguration", "1000"},
+ {"ConnmanOffline", "1000"},
+ {"ConnmanOnline", "1000"},
+ {"ConnmanOffline", "2000"},
+ {"ConnmanReady", "33000"},
+ {"ConnmanReady", "44000"},
+ {"ConnmanReady", "22000"},
};
int npairs = ARRAYSIZE_UNSAFE(pairs);
int32 i;
@@ -63,15 +78,20 @@ TEST(ExternalMetricsTest, ParseExternalMetricsFile) {
EXPECT_TRUE(unlink(path) == 0 || errno == ENOENT);
- // Send a few valid messages.
+ // Sends a few valid messages. Once in a while, collect them and check the
+ // last message. We don't want to check every single message because we also
+ // want to test the ability to deal with a file containing more than one
+ // message.
for (i = 0; i < npairs; i++) {
SendMessage(path, pairs[i].name, pairs[i].value);
+ if (i % 3 == 2) {
+ external_metrics->CollectEvents();
+ CheckMessage(pairs[i].name, pairs[i].value, i + 1);
+ }
}
- external_metrics->CollectEvents();
- CheckMessage(pairs[npairs-1].name, pairs[npairs-1].value, npairs);
- // Send a message that's too large.
+ // Sends a message that's too large.
char b[MAXLENGTH + 100];
for (i = 0; i < MAXLENGTH + 99; i++) {
b[i] = 'x';
@@ -81,7 +101,7 @@ TEST(ExternalMetricsTest, ParseExternalMetricsFile) {
external_metrics->CollectEvents();
EXPECT_EQ(received_count, npairs);
- // Send a malformed message (first string is not null-terminated).
+ // Sends a malformed message (first string is not null-terminated).
i = 100 + sizeof(i);
int fd = open(path, O_CREAT | O_WRONLY);
EXPECT_GT(fd, 0);
@@ -92,7 +112,7 @@ TEST(ExternalMetricsTest, ParseExternalMetricsFile) {
external_metrics->CollectEvents();
EXPECT_EQ(received_count, npairs);
- // Send a malformed message (second string is not null-terminated).
+ // Sends a malformed message (second string is not null-terminated).
b[50] = '\0';
fd = open(path, O_CREAT | O_WRONLY);
EXPECT_GT(fd, 0);
@@ -103,7 +123,7 @@ TEST(ExternalMetricsTest, ParseExternalMetricsFile) {
external_metrics->CollectEvents();
EXPECT_EQ(received_count, npairs);
- // Check that we survive when file doesn't exist.
+ // Checks that we survive when file doesn't exist.
EXPECT_EQ(unlink(path), 0);
external_metrics->CollectEvents();
EXPECT_EQ(received_count, npairs);