Chromium Code Reviews| Index: chrome/browser/net/dns_probe_runner.h |
| diff --git a/chrome/browser/net/dns_probe_runner.h b/chrome/browser/net/dns_probe_runner.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1bc18c9f8d924aaab2e5dfe99c6b6874f909e0fd |
| --- /dev/null |
| +++ b/chrome/browser/net/dns_probe_runner.h |
| @@ -0,0 +1,95 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_NET_DNS_PROBE_RUNNER_H |
| + |
| +#define CHROME_BROWSER_NET_DNS_PROBE_RUNNER_H |
| + |
| +#include "base/bind.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "net/base/net_log.h" |
| +#include "net/base/network_change_notifier.h" |
| + |
| +namespace net { |
| +class DnsClient; |
| +struct DnsConfig; |
| +class DnsResponse; |
| +class DnsTransaction; |
| +} |
|
cbentzel
2013/06/10 17:10:00
Should this be in chrome_browser_net namespace?
Deprecated (see juliatuttle)
2013/06/11 01:07:34
Done.
|
| + |
| +class DnsProbeRunner : public net::NetworkChangeNotifier::DNSObserver { |
|
szym
2013/06/07 19:31:28
Add a short class-level comment, e.g., "Runs DnsTr
|
| + public: |
| + enum Type { |
| + SYSTEM, |
| + PUBLIC |
| + }; |
| + |
| + enum Result { |
| + UNKNOWN, |
| + CORRECT, |
| + INCORRECT, |
| + FAILING, |
| + UNREACHABLE |
| + }; |
| + |
| + typedef base::Callback<void(Type, Result)> ProbeCallback; |
| + |
| + DnsProbeRunner(); |
| + virtual ~DnsProbeRunner(); |
| + |
| + // NetworkChangeNotifier::DNSObserver implementation: |
| + virtual void OnDNSChanged() OVERRIDE; |
| + |
| + void RunProbe(Type type, const ProbeCallback& callback); |
|
szym
2013/06/07 19:31:28
Why does it need |type|? Should it run both? If it
Deprecated (see juliatuttle)
2013/06/11 01:07:34
Done.
|
| + void SetClientsForTesting(scoped_ptr<net::DnsClient> system_client, |
| + scoped_ptr<net::DnsClient> public_client); |
| + void SetResultsForTesting(Result system_result, Result public_result); |
|
szym
2013/06/07 19:31:28
Could you avoid doing this by creating:
class Dns
Deprecated (see juliatuttle)
2013/06/11 01:07:34
Obsolete.
|
| + |
| + private: |
| + friend class DnsProbeRunnerTest; |
| + |
| + struct ProbeInfo { |
| + ProbeInfo(Type type, const ProbeCallback& callback); |
| + ~ProbeInfo(); |
| + |
| + const Type type; |
| + const ProbeCallback callback; |
| + }; |
| + |
| + enum MockMode { |
| + NO_MOCK, |
| + MOCK_CLIENTS, |
| + MOCK_RESULTS |
| + }; |
| + |
| + typedef std::map<net::DnsTransaction*,ProbeInfo> TransactionMap; |
|
szym
2013/06/07 19:31:28
This is strange. I think you could accomplish the
Deprecated (see juliatuttle)
2013/06/11 01:07:34
I could, but I needed the DnsTransactions anyway t
|
| + |
| + void InitializeSystemClient(); |
| + void InitializePublicClient(); |
| + Result GetMockResult(Type type); |
| + net::DnsClient* GetClient(Type type); |
| + void OnTransactionComplete(bool async, |
| + net::DnsTransaction* transaction, |
| + int net_error, |
| + const net::DnsResponse* response); |
| + Result EvaluateResponse(bool async, |
|
szym
2013/06/07 19:31:28
Needs comment.
Deprecated (see juliatuttle)
2013/06/11 01:07:34
Done.
|
| + int net_error, |
| + const net::DnsResponse* response); |
| + |
| + base::WeakPtrFactory<DnsProbeRunner> weak_factory_; |
| + net::BoundNetLog bound_net_log_; |
| + |
| + scoped_ptr<net::DnsClient> system_client_; |
| + scoped_ptr<net::DnsClient> public_client_; |
| + TransactionMap pending_transactions_; |
| + |
| + MockMode mock_mode_; |
| + scoped_ptr<net::DnsClient> mock_system_client_; |
| + scoped_ptr<net::DnsClient> mock_public_client_; |
| + Result mock_system_result_; |
| + Result mock_public_result_; |
| +}; |
| + |
| +#endif // CHROME_BROWSER_NET_DNS_PROBE_RUNNER_H |