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

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

Issue 1649007: metrics cleanup and fixes. (Closed)
Patch Set: Expose the pass/fail status. Created 10 years, 8 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
« no previous file with comments | « src/platform/metrics/metrics_daemon.h ('k') | src/platform/metrics/metrics_library.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "metrics_daemon.h" 5 #include "metrics_daemon.h"
6 #include "metrics_library.h" 6 #include "metrics_library.h"
7 7
8 #include <glib-object.h> 8 #include <glib-object.h>
9 9
10 extern "C" { 10 extern "C" {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 106 }
107 if (old_id != kUnknownNetworkStateId) { 107 if (old_id != kUnknownNetworkStateId) {
108 struct timeval diff; 108 struct timeval diff;
109 timersub(&now, &network_state_start_, &diff); 109 timersub(&now, &network_state_start_, &diff);
110 int diff_ms = diff.tv_usec / 1000 + diff.tv_sec * 1000; 110 int diff_ms = diff.tv_usec / 1000 + diff.tv_sec * 1000;
111 // Saturates rather than overflowing. We expect this to be statistically 111 // Saturates rather than overflowing. We expect this to be statistically
112 // insignificant, since INT_MAX milliseconds is 24.8 days. 112 // insignificant, since INT_MAX milliseconds is 24.8 days.
113 if (diff.tv_sec >= INT_MAX / 1000) { 113 if (diff.tv_sec >= INT_MAX / 1000) {
114 diff_ms = INT_MAX; 114 diff_ms = INT_MAX;
115 } 115 }
116 char buffer[100];
117 snprintf(buffer, sizeof(buffer), "%d", diff_ms);
118 if (testing_) { 116 if (testing_) {
119 TestPublishMetric(network_states_[old_id].stat_name, buffer); 117 TestPublishMetric(network_states_[old_id].stat_name, diff_ms);
120 } else { 118 } else {
121 ChromePublishMetric(network_states_[old_id].stat_name, buffer); 119 ChromePublishMetric(network_states_[old_id].stat_name, diff_ms);
122 } 120 }
123 } 121 }
124 network_state_id_ = new_id; 122 network_state_id_ = new_id;
125 network_state_start_ = now; 123 network_state_start_ = now;
126 } 124 }
127 125
128 MetricsDaemon::NetworkStateId 126 MetricsDaemon::NetworkStateId
129 MetricsDaemon::GetNetworkStateId(const char* state_name) { 127 MetricsDaemon::GetNetworkStateId(const char* state_name) {
130 for (int i = 0; i < kNumberNetworkStates; i++) { 128 for (int i = 0; i < kNumberNetworkStates; i++) {
131 if (strcmp(state_name, network_states_[i].name) == 0) { 129 if (strcmp(state_name, network_states_[i].name) == 0) {
132 return static_cast<NetworkStateId>(i); 130 return static_cast<NetworkStateId>(i);
133 } 131 }
134 } 132 }
135 return static_cast<NetworkStateId>(-1); 133 return static_cast<NetworkStateId>(-1);
136 } 134 }
137 135
138 void MetricsDaemon::ChromePublishMetric(const char* name, const char* value) { 136 void MetricsDaemon::ChromePublishMetric(const char* name, int value) {
139 MetricsLibrary::SendToChrome(name, value); 137 MetricsLibrary::SendToChrome(name, value);
140 } 138 }
141 139
142 void MetricsDaemon::TestPublishMetric(const char* name, const char* value) { 140 void MetricsDaemon::TestPublishMetric(const char* name, int value) {
143 LOG(INFO) << "received metric: " << name << " " << value; 141 LOG(INFO) << "received metric: " << name << " " << value;
144 } 142 }
OLDNEW
« no previous file with comments | « src/platform/metrics/metrics_daemon.h ('k') | src/platform/metrics/metrics_library.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698