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

Unified Diff: chrome/browser/net/dns_probe_service.h

Issue 13270005: Display DNS probe results. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix FilePath initalization on Windows Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
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..2f89ec7985a1da055dc7604bc89a6204919bea8b 100644
--- a/chrome/browser/net/dns_probe_service.h
+++ b/chrome/browser/net/dns_probe_service.h
@@ -8,11 +8,11 @@
#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/common/net/net_error_info.h"
-#include "net/base/network_change_notifier.h"
namespace net {
struct DnsConfig;
@@ -20,66 +20,33 @@ struct DnsConfig;
namespace chrome_browser_net {
-class DnsProbeService : public net::NetworkChangeNotifier::IPAddressObserver {
+class DnsProbeService {
public:
- typedef base::Callback<void(chrome_common_net::DnsProbeResult result)>
- CallbackType;
-
- DnsProbeService();
- virtual ~DnsProbeService();
-
- void ProbeDns(const CallbackType& callback);
-
- // NetworkChangeNotifier::IPAddressObserver implementation:
- virtual void OnIPAddressChanged() OVERRIDE;
-
- protected:
- // This can be called by tests to pretend the cached reuslt has expired.
- void ExpireResults();
-
- private:
- enum State {
- STATE_NO_RESULTS,
- STATE_PROBE_RUNNING,
- STATE_RESULTS_CACHED,
+ class JobFactory {
+ public:
+ JobFactory() { }
+ virtual ~JobFactory() { }
mmenke 2013/05/28 18:20:13 nit: Google C++ style guide says not to use a spa
Deprecated (see juliatuttle) 2013/06/05 21:01:47 Done.
+ virtual scoped_ptr<DnsProbeJob> CreateSystemJob(
+ const DnsProbeJob::CallbackType& job_callback) = 0;
+ virtual scoped_ptr<DnsProbeJob> CreatePublicJob(
+ const DnsProbeJob::CallbackType& job_callback) = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(JobFactory);
};
- void StartProbes();
- void OnProbesComplete();
- void CallCallbacks();
-
- void OnProbeJobComplete(DnsProbeJob* job, DnsProbeJob::Result result);
- chrome_common_net::DnsProbeResult EvaluateResults() const;
- void HistogramProbes() const;
+ typedef base::Callback<void(chrome_common_net::DnsProbeStatus result)>
+ CallbackType;
- // 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);
+ DnsProbeService() { }
+ virtual ~DnsProbeService() { }
mmenke 2013/05/28 18:20:13 nit: Google C++ style guide says not to use a spa
Deprecated (see juliatuttle) 2013/06/05 21:01:47 Done.
- 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();
+ static DnsProbeService* CreateDefault();
+ static DnsProbeService* CreateDefaultWithJobFactory(
+ scoped_ptr<JobFactory> job_factory);
- 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_;
- 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_;
+ virtual void ProbeDns(const CallbackType& callback) = 0;
+ virtual void ExpireResultForTesting() { }
mmenke 2013/05/28 18:20:13 nit: Google C++ style guide says not to use a spa
Deprecated (see juliatuttle) 2013/06/05 21:01:47 Done.
DISALLOW_COPY_AND_ASSIGN(DnsProbeService);
};

Powered by Google App Engine
This is Rietveld 408576698