1// Copyright (c) 2013 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef CHROME_COMMON_NET_NET_ERROR_INFO_H_ 6#define CHROME_COMMON_NET_NET_ERROR_INFO_H_ 7 8namespace chrome_common_net { 9 10// The status of a DNS probe that the NetErrorTabHelper may or may not have 11// started. 12// 13// The DNS_PROBE_FINISHED_* values are used in histograms, so: 14// 1. FINISHED_UNKNOWN must remain the first FINISHED_* value. 15// 2. FINISHED_* values must not be rearranged relative to FINISHED_UNKNOWN. 16// 3. New FINISHED_* values must be inserted at the end. 17// 4. New non-FINISHED_* values cannot be inserted. 18enum DnsProbeStatus { 19 // A DNS probe may be run for this error page. (This status is only used on 20 // the renderer side before it's received a status update from the browser.) 21 DNS_PROBE_POSSIBLE, 22 23 // A DNS probe will not be run for this error page. (This happens if the 24 // user has the "Use web service to resolve navigation errors" preference 25 // turned off, or if probes are disabled by the field trial.) 26 DNS_PROBE_NOT_RUN, 27 28 // A DNS probe has been started for this error page. The renderer should 29 // expect to receive another IPC with one of the FINISHED statuses once the 30 // probe has finished (as long as the error page is still loaded). 31 DNS_PROBE_STARTED, 32 33 // A DNS probe has finished with one of the following results: 34 35 // The probe was inconclusive. 36 DNS_PROBE_FINISHED_INCONCLUSIVE, 37 38 // There's no internet connection. 39 DNS_PROBE_FINISHED_NO_INTERNET, 40 41 // The DNS configuration is wrong, or the servers are down or broken. 42 DNS_PROBE_FINISHED_BAD_CONFIG, 43 44 // The DNS servers are working fine, so the domain must not exist. 45 DNS_PROBE_FINISHED_NXDOMAIN, 46 47 DNS_PROBE_MAX 48}; 49 50// Returns a string representing |status|. It should be simply the name of 51// the value as a string, but don't rely on that. This is presented to the 52// user as part of the DNS error page (as the error code, at the bottom), 53// and is also used in some verbose log messages. 54// 55// |status| is an int because error codes are ints by the time they get to the 56// localized error system, and we don't want to require the caller to cast back 57// to a probe status. The function will NOTREACHED() and return an empty 58// string if given an int that does not match a value in DnsProbeStatus (or if 59// it is DNS_PROBE_MAX, which is not a real status). 60const char* DnsProbeStatusToString(int status); 61 62// Returns true if |status| is one of the DNS_PROBE_FINISHED_* statuses. 63bool DnsProbeStatusIsFinished(DnsProbeStatus status); 64 65// Checks the --force-dns-probes command line option and the DnsProbe-Enable 66// field trial. If the command-line option is found, return what it says, 67// otherwise return true if and only if the field trial has group "enabled". 68bool DnsProbesEnabled(); 69 70// The error domain used to pass DNS probe statuses to the localized error 71// code. 72extern const char kDnsProbeErrorDomain[]; 73 74} // namespace chrome_common_net 75 76#endif // CHROME_COMMON_NET_NET_ERROR_INFO_H_ 77