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

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

Issue 2421143002: Fix broken clockstate.network2 histogram and add unit test (Closed)
Patch Set: meacer suggestion: move field trial into test util 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 20 matching lines...) Expand all
31 #include "base/win/windows_version.h" 31 #include "base/win/windows_version.h"
32 #endif 32 #endif
33 33
34 using base::Time; 34 using base::Time;
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
42 // unavailable, why it was unavailable. This enum is being histogrammed
43 // so do not reorder or remove values.
44 enum NetworkClockState {
45 // Value 0 was NETWORK_CLOCK_STATE_UNKNOWN_NO_SYNC, which is obsolete
46 // in favor of the finer-grained values below.
47
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
50 // from the network (due to e.g. suspend/resume).
51 NETWORK_CLOCK_STATE_UNKNOWN_SYNC_LOST = 1,
52 // The clock is "close enough" to the network time.
53 NETWORK_CLOCK_STATE_OK,
54 // The clock is in the past relative to network time.
55 NETWORK_CLOCK_STATE_CLOCK_IN_PAST,
56 // The clock is in the future relative to network time.
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,
71 NETWORK_CLOCK_STATE_MAX
72 };
73
74 // Events for UMA. Do not reorder or change! 41 // Events for UMA. Do not reorder or change!
75 enum SSLInterstitialCause { 42 enum SSLInterstitialCause {
76 CLOCK_PAST, 43 CLOCK_PAST,
77 CLOCK_FUTURE, 44 CLOCK_FUTURE,
78 WWW_SUBDOMAIN_MATCH, 45 WWW_SUBDOMAIN_MATCH,
79 SUBDOMAIN_MATCH, 46 SUBDOMAIN_MATCH,
80 SUBDOMAIN_INVERSE_MATCH, 47 SUBDOMAIN_INVERSE_MATCH,
81 SUBDOMAIN_OUTSIDE_WILDCARD, 48 SUBDOMAIN_OUTSIDE_WILDCARD,
82 HOST_NAME_NOT_KNOWN_TLD, 49 HOST_NAME_NOT_KNOWN_TLD,
83 LIKELY_MULTI_TENANT_HOSTING, 50 LIKELY_MULTI_TENANT_HOSTING,
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 ClockState build_time_state = CLOCK_STATE_UNKNOWN; 240 ClockState build_time_state = CLOCK_STATE_UNKNOWN;
274 base::Time build_time = g_testing_build_time.Get().is_null() 241 base::Time build_time = g_testing_build_time.Get().is_null()
275 ? base::GetBuildTime() 242 ? base::GetBuildTime()
276 : g_testing_build_time.Get(); 243 : g_testing_build_time.Get();
277 if (now_system < build_time - base::TimeDelta::FromDays(2)) { 244 if (now_system < build_time - base::TimeDelta::FromDays(2)) {
278 build_time_state = CLOCK_STATE_PAST; 245 build_time_state = CLOCK_STATE_PAST;
279 } else if (now_system > build_time + base::TimeDelta::FromDays(365)) { 246 } else if (now_system > build_time + base::TimeDelta::FromDays(365)) {
280 build_time_state = CLOCK_STATE_FUTURE; 247 build_time_state = CLOCK_STATE_FUTURE;
281 } 248 }
282 249
283 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.clockstate.network2", 250 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.clockstate.network3",
284 network_time_result, NETWORK_CLOCK_STATE_MAX); 251 network_state, NETWORK_CLOCK_STATE_MAX);
285 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.clockstate.build_time", 252 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.clockstate.build_time",
286 build_time_state, CLOCK_STATE_MAX); 253 build_time_state, CLOCK_STATE_MAX);
287 254
288 switch (network_state) { 255 switch (network_state) {
289 case NETWORK_CLOCK_STATE_UNKNOWN_SYNC_LOST: 256 case NETWORK_CLOCK_STATE_UNKNOWN_SYNC_LOST:
290 case NETWORK_CLOCK_STATE_UNKNOWN_NO_SYNC_ATTEMPT: 257 case NETWORK_CLOCK_STATE_UNKNOWN_NO_SYNC_ATTEMPT:
291 case NETWORK_CLOCK_STATE_UNKNOWN_NO_SUCCESSFUL_SYNC: 258 case NETWORK_CLOCK_STATE_UNKNOWN_NO_SUCCESSFUL_SYNC:
292 case NETWORK_CLOCK_STATE_UNKNOWN_FIRST_SYNC_PENDING: 259 case NETWORK_CLOCK_STATE_UNKNOWN_FIRST_SYNC_PENDING:
293 case NETWORK_CLOCK_STATE_UNKNOWN_SUBSEQUENT_SYNC_PENDING: 260 case NETWORK_CLOCK_STATE_UNKNOWN_SUBSEQUENT_SYNC_PENDING:
294 return build_time_state; 261 return build_time_state;
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 return std::find(dns_names_domain.begin(), dns_names_domain.end() - 1, 479 return std::find(dns_names_domain.begin(), dns_names_domain.end() - 1,
513 host_name_domain) != dns_names_domain.end() - 1; 480 host_name_domain) != dns_names_domain.end() - 1;
514 } 481 }
515 482
516 bool IsHostnameNonUniqueOrDotless(const std::string& hostname) { 483 bool IsHostnameNonUniqueOrDotless(const std::string& hostname) {
517 return net::IsHostnameNonUnique(hostname) || 484 return net::IsHostnameNonUnique(hostname) ||
518 hostname.find('.') == std::string::npos; 485 hostname.find('.') == std::string::npos;
519 } 486 }
520 487
521 } // namespace ssl_errors 488 } // namespace ssl_errors
OLDNEW
« no previous file with comments | « components/ssl_errors/error_classification.h ('k') | components/ssl_errors/error_classification_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698