Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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_BROWSER_NET_DNS_PROBE_RUNNER_H | |
| 6 | |
| 7 #define CHROME_BROWSER_NET_DNS_PROBE_RUNNER_H | |
| 8 | |
| 9 #include "base/bind.h" | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/memory/weak_ptr.h" | |
| 12 #include "net/base/net_log.h" | |
| 13 #include "net/base/network_change_notifier.h" | |
| 14 | |
| 15 namespace net { | |
| 16 class DnsClient; | |
| 17 struct DnsConfig; | |
| 18 class DnsResponse; | |
| 19 class DnsTransaction; | |
| 20 } | |
|
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.
| |
| 21 | |
| 22 class DnsProbeRunner : public net::NetworkChangeNotifier::DNSObserver { | |
|
szym
2013/06/07 19:31:28
Add a short class-level comment, e.g., "Runs DnsTr
| |
| 23 public: | |
| 24 enum Type { | |
| 25 SYSTEM, | |
| 26 PUBLIC | |
| 27 }; | |
| 28 | |
| 29 enum Result { | |
| 30 UNKNOWN, | |
| 31 CORRECT, | |
| 32 INCORRECT, | |
| 33 FAILING, | |
| 34 UNREACHABLE | |
| 35 }; | |
| 36 | |
| 37 typedef base::Callback<void(Type, Result)> ProbeCallback; | |
| 38 | |
| 39 DnsProbeRunner(); | |
| 40 virtual ~DnsProbeRunner(); | |
| 41 | |
| 42 // NetworkChangeNotifier::DNSObserver implementation: | |
| 43 virtual void OnDNSChanged() OVERRIDE; | |
| 44 | |
| 45 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.
| |
| 46 void SetClientsForTesting(scoped_ptr<net::DnsClient> system_client, | |
| 47 scoped_ptr<net::DnsClient> public_client); | |
| 48 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.
| |
| 49 | |
| 50 private: | |
| 51 friend class DnsProbeRunnerTest; | |
| 52 | |
| 53 struct ProbeInfo { | |
| 54 ProbeInfo(Type type, const ProbeCallback& callback); | |
| 55 ~ProbeInfo(); | |
| 56 | |
| 57 const Type type; | |
| 58 const ProbeCallback callback; | |
| 59 }; | |
| 60 | |
| 61 enum MockMode { | |
| 62 NO_MOCK, | |
| 63 MOCK_CLIENTS, | |
| 64 MOCK_RESULTS | |
| 65 }; | |
| 66 | |
| 67 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
| |
| 68 | |
| 69 void InitializeSystemClient(); | |
| 70 void InitializePublicClient(); | |
| 71 Result GetMockResult(Type type); | |
| 72 net::DnsClient* GetClient(Type type); | |
| 73 void OnTransactionComplete(bool async, | |
| 74 net::DnsTransaction* transaction, | |
| 75 int net_error, | |
| 76 const net::DnsResponse* response); | |
| 77 Result EvaluateResponse(bool async, | |
|
szym
2013/06/07 19:31:28
Needs comment.
Deprecated (see juliatuttle)
2013/06/11 01:07:34
Done.
| |
| 78 int net_error, | |
| 79 const net::DnsResponse* response); | |
| 80 | |
| 81 base::WeakPtrFactory<DnsProbeRunner> weak_factory_; | |
| 82 net::BoundNetLog bound_net_log_; | |
| 83 | |
| 84 scoped_ptr<net::DnsClient> system_client_; | |
| 85 scoped_ptr<net::DnsClient> public_client_; | |
| 86 TransactionMap pending_transactions_; | |
| 87 | |
| 88 MockMode mock_mode_; | |
| 89 scoped_ptr<net::DnsClient> mock_system_client_; | |
| 90 scoped_ptr<net::DnsClient> mock_public_client_; | |
| 91 Result mock_system_result_; | |
| 92 Result mock_public_result_; | |
| 93 }; | |
| 94 | |
| 95 #endif // CHROME_BROWSER_NET_DNS_PROBE_RUNNER_H | |
| OLD | NEW |