Chromium Code Reviews| Index: net/dns/mock_host_resolver.h |
| diff --git a/net/dns/mock_host_resolver.h b/net/dns/mock_host_resolver.h |
| index cca300acbc69c90e93bfa0772f27646533f0670f..4cbe57c12c50d0e99930e1475544f48dad18f300 100644 |
| --- a/net/dns/mock_host_resolver.h |
| +++ b/net/dns/mock_host_resolver.h |
| @@ -9,6 +9,7 @@ |
| #include <list> |
| #include <map> |
| +#include <string> |
| #include "base/macros.h" |
| #include "base/memory/weak_ptr.h" |
| @@ -212,6 +213,11 @@ class RuleBasedHostResolverProc : public HostResolverProc { |
| // Deletes all the rules that have been added. |
| void ClearRules(); |
| + // Asserts if any changes are made to the rules after this call. |
| + // TODO: once this class isn't used by tests that use an out of process |
|
mmenke
2017/04/25 17:29:47
I believe TODO(name) is the preferred style here?
jam
2017/04/25 18:19:37
Done.
|
| + // network service, remove this method and make Rule private. |
| + void DisableModifications(); |
| + |
| // HostResolverProc methods: |
| int Resolve(const std::string& host, |
| AddressFamily address_family, |
| @@ -219,10 +225,36 @@ class RuleBasedHostResolverProc : public HostResolverProc { |
| AddressList* addrlist, |
| int* os_error) override; |
| - private: |
| - struct Rule; |
| + struct Rule { |
| + enum ResolverType { |
| + kResolverTypeFail, |
| + kResolverTypeSystem, |
| + kResolverTypeIPLiteral, |
| + }; |
| + |
| + Rule(ResolverType resolver_type, |
| + const std::string& host_pattern, |
| + AddressFamily address_family, |
| + HostResolverFlags host_resolver_flags, |
| + const std::string& replacement, |
| + const std::string& canonical_name, |
| + int latency_ms); |
| + Rule(const Rule& other); |
| + |
| + ResolverType resolver_type; |
| + std::string host_pattern; |
| + AddressFamily address_family; |
| + HostResolverFlags host_resolver_flags; |
| + std::string replacement; |
| + std::string canonical_name; |
| + int latency_ms; // In milliseconds. |
| + }; |
| + |
| typedef std::list<Rule> RuleList; |
| + RuleList GetRules(); |
| + |
| + private: |
| ~RuleBasedHostResolverProc() override; |
| void AddRuleInternal(const Rule& rule); |
| @@ -231,6 +263,9 @@ class RuleBasedHostResolverProc : public HostResolverProc { |
| // Must be obtained before writing to or reading from |rules_|. |
| base::Lock rule_lock_; |
| + |
| + // Whether changes are allowed. |
| + bool modifications_allowed_; |
| }; |
| // Create rules that map all requests to localhost. |