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

Side by Side Diff: components/ssl_errors/error_classification.cc

Issue 2415703005: Refine NetworkTimeTracker histograms (Closed)
Patch Set: mab comments Created 4 years, 2 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium 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 "components/ssl_errors/error_classification.h" 5 #include "components/ssl_errors/error_classification.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 24 matching lines...) Expand all
35 using base::TimeTicks; 35 using base::TimeTicks;
36 using base::TimeDelta; 36 using base::TimeDelta;
37 37
38 namespace ssl_errors { 38 namespace ssl_errors {
39 namespace { 39 namespace {
40 40
41 // Describes the result of getting network time and if it was 41 // Describes the result of getting network time and if it was
42 // unavailable, why it was unavailable. This enum is being histogrammed 42 // unavailable, why it was unavailable. This enum is being histogrammed
43 // so do not reorder or remove values. 43 // so do not reorder or remove values.
44 enum NetworkClockState { 44 enum NetworkClockState {
45 // The clock state relative to network time is unknown because the 45 // Value 0 was NETWORK_CLOCK_STATE_UNKNOWN_NO_SYNC, which is obsolete
46 // NetworkTimeTracker has no information from the network. 46 // in favor of the finer-grained values below.
47 NETWORK_CLOCK_STATE_UNKNOWN_NO_SYNC = 0, 47
48 // The clock state relative to network time is unknown because the 48 // The clock state relative to network time is unknown because the
49 // user's clock has fallen out of sync with the latest information 49 // user's clock has fallen out of sync with the latest information
50 // from the network (due to e.g. suspend/resume). 50 // from the network (due to e.g. suspend/resume).
51 NETWORK_CLOCK_STATE_UNKNOWN_SYNC_LOST, 51 NETWORK_CLOCK_STATE_UNKNOWN_SYNC_LOST = 1,
52 // The clock is "close enough" to the network time. 52 // The clock is "close enough" to the network time.
53 NETWORK_CLOCK_STATE_OK, 53 NETWORK_CLOCK_STATE_OK,
54 // The clock is in the past relative to network time. 54 // The clock is in the past relative to network time.
55 NETWORK_CLOCK_STATE_CLOCK_IN_PAST, 55 NETWORK_CLOCK_STATE_CLOCK_IN_PAST,
56 // The clock is in the future relative to network time. 56 // The clock is in the future relative to network time.
57 NETWORK_CLOCK_STATE_CLOCK_IN_FUTURE, 57 NETWORK_CLOCK_STATE_CLOCK_IN_FUTURE,
58 // The clock state relative to network time is unknown because no sync
59 // attempt has been made yet.
60 NETWORK_CLOCK_STATE_UNKNOWN_NO_SYNC_ATTEMPT,
61 // The clock state relative to network time is unknown because one or
62 // more sync attempts has failed.
63 NETWORK_CLOCK_STATE_UNKNOWN_NO_SUCCESSFUL_SYNC,
64 // The clock state relative to network time is unknown because the
65 // first sync attempt is still pending.
66 NETWORK_CLOCK_STATE_UNKNOWN_FIRST_SYNC_PENDING,
67 // The clock state relative to network time is unknown because one or
68 // more time query attempts have failed, and a subsequent sync attempt
69 // is still pending.
70 NETWORK_CLOCK_STATE_UNKNOWN_SUBSEQUENT_SYNC_PENDING,
58 NETWORK_CLOCK_STATE_MAX 71 NETWORK_CLOCK_STATE_MAX
59 }; 72 };
60 73
61 // Events for UMA. Do not reorder or change! 74 // Events for UMA. Do not reorder or change!
62 enum SSLInterstitialCause { 75 enum SSLInterstitialCause {
63 CLOCK_PAST, 76 CLOCK_PAST,
64 CLOCK_FUTURE, 77 CLOCK_FUTURE,
65 WWW_SUBDOMAIN_MATCH, 78 WWW_SUBDOMAIN_MATCH,
66 SUBDOMAIN_MATCH, 79 SUBDOMAIN_MATCH,
67 SUBDOMAIN_INVERSE_MATCH, 80 SUBDOMAIN_INVERSE_MATCH,
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 network_state = NETWORK_CLOCK_STATE_CLOCK_IN_PAST; 249 network_state = NETWORK_CLOCK_STATE_CLOCK_IN_PAST;
237 } else if (now_system > now_network + uncertainty + kNetworkTimeFudge) { 250 } else if (now_system > now_network + uncertainty + kNetworkTimeFudge) {
238 network_state = NETWORK_CLOCK_STATE_CLOCK_IN_FUTURE; 251 network_state = NETWORK_CLOCK_STATE_CLOCK_IN_FUTURE;
239 } else { 252 } else {
240 network_state = NETWORK_CLOCK_STATE_OK; 253 network_state = NETWORK_CLOCK_STATE_OK;
241 } 254 }
242 break; 255 break;
243 case network_time::NetworkTimeTracker::NETWORK_TIME_SYNC_LOST: 256 case network_time::NetworkTimeTracker::NETWORK_TIME_SYNC_LOST:
244 network_state = NETWORK_CLOCK_STATE_UNKNOWN_SYNC_LOST; 257 network_state = NETWORK_CLOCK_STATE_UNKNOWN_SYNC_LOST;
245 break; 258 break;
246 case network_time::NetworkTimeTracker::NETWORK_TIME_NO_SYNC: 259 case network_time::NetworkTimeTracker::NETWORK_TIME_NO_SYNC_ATTEMPT:
247 network_state = NETWORK_CLOCK_STATE_UNKNOWN_NO_SYNC; 260 network_state = NETWORK_CLOCK_STATE_UNKNOWN_NO_SYNC_ATTEMPT;
261 break;
262 case network_time::NetworkTimeTracker::NETWORK_TIME_NO_SUCCESSFUL_SYNC:
263 network_state = NETWORK_CLOCK_STATE_UNKNOWN_NO_SUCCESSFUL_SYNC;
264 break;
265 case network_time::NetworkTimeTracker::NETWORK_TIME_FIRST_SYNC_PENDING:
266 network_state = NETWORK_CLOCK_STATE_UNKNOWN_FIRST_SYNC_PENDING;
267 break;
268 case network_time::NetworkTimeTracker::NETWORK_TIME_SUBSEQUENT_SYNC_PENDING:
269 network_state = NETWORK_CLOCK_STATE_UNKNOWN_SUBSEQUENT_SYNC_PENDING;
248 break; 270 break;
249 } 271 }
250 272
251 ClockState build_time_state = CLOCK_STATE_UNKNOWN; 273 ClockState build_time_state = CLOCK_STATE_UNKNOWN;
252 base::Time build_time = g_testing_build_time.Get().is_null() 274 base::Time build_time = g_testing_build_time.Get().is_null()
253 ? base::GetBuildTime() 275 ? base::GetBuildTime()
254 : g_testing_build_time.Get(); 276 : g_testing_build_time.Get();
255 if (now_system < build_time - base::TimeDelta::FromDays(2)) { 277 if (now_system < build_time - base::TimeDelta::FromDays(2)) {
256 build_time_state = CLOCK_STATE_PAST; 278 build_time_state = CLOCK_STATE_PAST;
257 } else if (now_system > build_time + base::TimeDelta::FromDays(365)) { 279 } else if (now_system > build_time + base::TimeDelta::FromDays(365)) {
258 build_time_state = CLOCK_STATE_FUTURE; 280 build_time_state = CLOCK_STATE_FUTURE;
259 } 281 }
260 282
261 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.clockstate.network2", 283 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.clockstate.network2",
262 network_time_result, NETWORK_CLOCK_STATE_MAX); 284 network_time_result, NETWORK_CLOCK_STATE_MAX);
263 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.clockstate.build_time", 285 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.clockstate.build_time",
264 build_time_state, CLOCK_STATE_MAX); 286 build_time_state, CLOCK_STATE_MAX);
265 287
266 switch (network_state) { 288 switch (network_state) {
267 case NETWORK_CLOCK_STATE_UNKNOWN_NO_SYNC:
268 case NETWORK_CLOCK_STATE_UNKNOWN_SYNC_LOST: 289 case NETWORK_CLOCK_STATE_UNKNOWN_SYNC_LOST:
290 case NETWORK_CLOCK_STATE_UNKNOWN_NO_SYNC_ATTEMPT:
291 case NETWORK_CLOCK_STATE_UNKNOWN_NO_SUCCESSFUL_SYNC:
292 case NETWORK_CLOCK_STATE_UNKNOWN_FIRST_SYNC_PENDING:
293 case NETWORK_CLOCK_STATE_UNKNOWN_SUBSEQUENT_SYNC_PENDING:
269 return build_time_state; 294 return build_time_state;
270 case NETWORK_CLOCK_STATE_OK: 295 case NETWORK_CLOCK_STATE_OK:
271 return CLOCK_STATE_OK; 296 return CLOCK_STATE_OK;
272 case NETWORK_CLOCK_STATE_CLOCK_IN_PAST: 297 case NETWORK_CLOCK_STATE_CLOCK_IN_PAST:
273 return CLOCK_STATE_PAST; 298 return CLOCK_STATE_PAST;
274 case NETWORK_CLOCK_STATE_CLOCK_IN_FUTURE: 299 case NETWORK_CLOCK_STATE_CLOCK_IN_FUTURE:
275 return CLOCK_STATE_FUTURE; 300 return CLOCK_STATE_FUTURE;
276 case NETWORK_CLOCK_STATE_MAX: 301 case NETWORK_CLOCK_STATE_MAX:
277 NOTREACHED(); 302 NOTREACHED();
278 return CLOCK_STATE_UNKNOWN; 303 return CLOCK_STATE_UNKNOWN;
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 return std::find(dns_names_domain.begin(), dns_names_domain.end() - 1, 512 return std::find(dns_names_domain.begin(), dns_names_domain.end() - 1,
488 host_name_domain) != dns_names_domain.end() - 1; 513 host_name_domain) != dns_names_domain.end() - 1;
489 } 514 }
490 515
491 bool IsHostnameNonUniqueOrDotless(const std::string& hostname) { 516 bool IsHostnameNonUniqueOrDotless(const std::string& hostname) {
492 return net::IsHostnameNonUnique(hostname) || 517 return net::IsHostnameNonUnique(hostname) ||
493 hostname.find('.') == std::string::npos; 518 hostname.find('.') == std::string::npos;
494 } 519 }
495 520
496 } // namespace ssl_errors 521 } // namespace ssl_errors
OLDNEW
« no previous file with comments | « components/network_time/network_time_tracker_unittest.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698