| Index: chrome/browser/net/dns_probe_service.h
|
| ===================================================================
|
| --- chrome/browser/net/dns_probe_service.h (revision 212348)
|
| +++ chrome/browser/net/dns_probe_service.h (working copy)
|
| @@ -8,71 +8,79 @@
|
| #include <vector>
|
|
|
| #include "base/basictypes.h"
|
| -#include "base/bind.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/time/time.h"
|
| -#include "chrome/browser/net/dns_probe_runner.h"
|
| +#include "chrome/browser/net/dns_probe_job.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 {
|
|
|
| -// 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.
|
| -//
|
| -// Uses a single DNS attempt per config, and doesn't randomize source ports.
|
| -class DnsProbeService : public net::NetworkChangeNotifier::DNSObserver {
|
| +class DnsProbeService : public net::NetworkChangeNotifier::IPAddressObserver {
|
| public:
|
| - typedef base::Callback<void(chrome_common_net::DnsProbeStatus result)>
|
| - ProbeCallback;
|
| + typedef base::Callback<void(chrome_common_net::DnsProbeResult result)>
|
| + CallbackType;
|
|
|
| DnsProbeService();
|
| virtual ~DnsProbeService();
|
|
|
| - virtual void ProbeDns(const ProbeCallback& callback);
|
| + void ProbeDns(const CallbackType& callback);
|
|
|
| - // NetworkChangeNotifier::DNSObserver implementation:
|
| - virtual void OnDNSChanged() OVERRIDE;
|
| + // NetworkChangeNotifier::IPAddressObserver implementation:
|
| + virtual void OnIPAddressChanged() OVERRIDE;
|
|
|
| - void SetSystemClientForTesting(scoped_ptr<net::DnsClient> system_client);
|
| - void SetPublicClientForTesting(scoped_ptr<net::DnsClient> public_client);
|
| - void ClearCachedResultForTesting();
|
| + protected:
|
| + // This can be called by tests to pretend the cached reuslt has expired.
|
| + void ExpireResults();
|
|
|
| private:
|
| enum State {
|
| - STATE_NO_RESULT,
|
| + STATE_NO_RESULTS,
|
| STATE_PROBE_RUNNING,
|
| - STATE_RESULT_CACHED,
|
| + STATE_RESULTS_CACHED,
|
| };
|
|
|
| - void SetSystemClientToCurrentConfig();
|
| - void SetPublicClientToGooglePublicDns();
|
| -
|
| - // Starts a probe (runs system and public probes).
|
| void StartProbes();
|
| - void OnProbeComplete();
|
| - // Calls all |pending_callbacks_| with the |cached_result_|.
|
| + void OnProbesComplete();
|
| void CallCallbacks();
|
| - // Clears a cached probe result.
|
| - void ClearCachedResult();
|
|
|
| - bool CachedResultIsExpired() const;
|
| + void OnProbeJobComplete(DnsProbeJob* job, DnsProbeJob::Result result);
|
| + chrome_common_net::DnsProbeResult EvaluateResults() const;
|
| + void HistogramProbes() const;
|
|
|
| + // 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();
|
| +
|
| + scoped_ptr<DnsProbeJob> system_job_;
|
| + scoped_ptr<DnsProbeJob> public_job_;
|
| + DnsProbeJob::Result system_result_;
|
| + DnsProbeJob::Result public_result_;
|
| + std::vector<CallbackType> callbacks_;
|
| State state_;
|
| - std::vector<ProbeCallback> pending_callbacks_;
|
| + chrome_common_net::DnsProbeResult result_;
|
| base::Time probe_start_time_;
|
| - chrome_common_net::DnsProbeStatus cached_result_;
|
| + // 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_;
|
|
|
| - // DnsProbeRunners for the system DNS configuration and a public DNS server.
|
| - DnsProbeRunner system_runner_;
|
| - DnsProbeRunner public_runner_;
|
| -
|
| DISALLOW_COPY_AND_ASSIGN(DnsProbeService);
|
| };
|
|
|
|
|