Chromium Code Reviews| Index: chrome/browser/net/dns_probe_service.h |
| diff --git a/chrome/browser/net/dns_probe_service.h b/chrome/browser/net/dns_probe_service.h |
| index c40967acc10c64e35dc34b5739b580b9dcd4a150..a799ba727757e89facfc0cb58ccd3d87323b12f1 100644 |
| --- a/chrome/browser/net/dns_probe_service.h |
| +++ b/chrome/browser/net/dns_probe_service.h |
| @@ -8,34 +8,39 @@ |
| #include <vector> |
| #include "base/basictypes.h" |
| +#include "base/bind.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/time.h" |
| -#include "chrome/browser/net/dns_probe_job.h" |
| +#include "chrome/browser/net/dns_probe_runner.h" |
| #include "chrome/common/net/net_error_info.h" |
| #include "net/base/network_change_notifier.h" |
| namespace net { |
| +class DnsClient; |
| struct DnsConfig; |
| } |
| namespace chrome_browser_net { |
| -class DnsProbeService : public net::NetworkChangeNotifier::IPAddressObserver { |
| +// Probes the system and public DNS servers to determine the (probable) cause |
| +// of a recent DNS-related page load error. Coalesces multiple probe requests |
| +// (perhaps from multiple tabs) and caches the results. |
| +class DnsProbeService : public net::NetworkChangeNotifier::DNSObserver { |
| public: |
| - typedef base::Callback<void(chrome_common_net::DnsProbeResult result)> |
| - CallbackType; |
| + typedef base::Callback<void(chrome_common_net::DnsProbeStatus result)> |
| + ProbeCallback; |
| DnsProbeService(); |
| virtual ~DnsProbeService(); |
| - void ProbeDns(const CallbackType& callback); |
| + void ProbeDns(const ProbeCallback& callback); |
| - // NetworkChangeNotifier::IPAddressObserver implementation: |
| - virtual void OnIPAddressChanged() OVERRIDE; |
| + // NetworkChangeNotifier::DNSObserver implementation: |
| + virtual void OnDNSChanged() OVERRIDE; |
| - protected: |
| - // This can be called by tests to pretend the cached reuslt has expired. |
| - void ExpireResults(); |
| + void SetSystemClientForTesting(scoped_ptr<net::DnsClient> system_client); |
| + void SetPublicClientForTesting(scoped_ptr<net::DnsClient> public_client); |
| + void ExpireResultForTesting(); |
| private: |
| enum State { |
| @@ -44,42 +49,35 @@ class DnsProbeService : public net::NetworkChangeNotifier::IPAddressObserver { |
| STATE_RESULTS_CACHED, |
| }; |
| - void StartProbes(); |
| - void OnProbesComplete(); |
| - void CallCallbacks(); |
| + enum ProbeType { |
| + SYSTEM, |
| + PUBLIC |
| + }; |
| + |
| + void SetSystemClientToCurrentConfig(); |
| + void SetPublicClientToGooglePublicDns(); |
| - void OnProbeJobComplete(DnsProbeJob* job, DnsProbeJob::Result result); |
| - chrome_common_net::DnsProbeResult EvaluateResults() const; |
| + void SetSystemClient(scoped_ptr<net::DnsClient> system_client); |
| + void SetPublicClient(scoped_ptr<net::DnsClient> public_client); |
| + |
| + void StartProbes(); |
| + void OnProbeComplete(ProbeType type, DnsProbeRunner::Result result); |
| + chrome_common_net::DnsProbeStatus EvaluateResults() const; |
|
mmenke
2013/06/11 16:15:35
Think a couple of these may be woth comments.
Deprecated (see juliatuttle)
2013/06/13 14:37:04
Done.
|
| void HistogramProbes() const; |
| + void CallCallbacks(); |
| + void ExpireResult(); |
| - // These are expected to be overridden by tests to return mock jobs. |
| - virtual scoped_ptr<DnsProbeJob> CreateSystemProbeJob( |
| - const DnsProbeJob::CallbackType& job_callback); |
| - virtual scoped_ptr<DnsProbeJob> CreatePublicProbeJob( |
| - const DnsProbeJob::CallbackType& job_callback); |
| - |
| - scoped_ptr<DnsProbeJob> CreateProbeJob( |
| - const net::DnsConfig& dns_config, |
| - const DnsProbeJob::CallbackType& job_callback); |
| - void GetSystemDnsConfig(net::DnsConfig* config); |
| - void GetPublicDnsConfig(net::DnsConfig* config); |
| bool ResultsExpired(); |
|
mmenke
2013/06/12 19:17:12
nit: const.
Deprecated (see juliatuttle)
2013/06/13 14:37:04
Done.
|
| - scoped_ptr<DnsProbeJob> system_job_; |
| - scoped_ptr<DnsProbeJob> public_job_; |
| - DnsProbeJob::Result system_result_; |
| - DnsProbeJob::Result public_result_; |
| - std::vector<CallbackType> callbacks_; |
| State state_; |
| - chrome_common_net::DnsProbeResult result_; |
| + std::vector<ProbeCallback> pending_callbacks_; |
| base::Time probe_start_time_; |
| - // How many DNS request attempts the probe jobs will make before giving up |
| - // (Overrides the attempts field in the system DnsConfig.) |
| - const int dns_attempts_; |
| - // How many nameservers the system config has. |
| - int system_nameserver_count_; |
| - // Whether the only system nameserver is 127.0.0.1. |
| - bool system_is_localhost_; |
| + chrome_common_net::DnsProbeStatus result_; |
|
mmenke
2013/06/11 16:15:35
cached_result_, maybe?
Deprecated (see juliatuttle)
2013/06/13 14:37:04
Done.
|
| + |
| + DnsProbeRunner system_runner_; |
| + DnsProbeRunner public_runner_; |
| + DnsProbeRunner::Result system_result_; |
| + DnsProbeRunner::Result public_result_; |
|
mmenke
2013/06/11 16:15:35
Think these are worth comments.
Deprecated (see juliatuttle)
2013/06/13 14:37:04
Done.
|
| DISALLOW_COPY_AND_ASSIGN(DnsProbeService); |
| }; |