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..37eab83301cf56e9ab26f90ff09bffea8ce9affa 100644 |
| --- a/net/dns/mock_host_resolver.h |
| +++ b/net/dns/mock_host_resolver.h |
| @@ -212,6 +212,9 @@ 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. |
|
mmenke
2017/04/25 16:37:53
Could you clarify that this makes calls that add/r
jam
2017/04/25 17:04:40
"after this call" isn't clear enough?
mmenke
2017/04/25 17:44:44
Oops, forgot to respond to this. My feeling is th
mmenke
2017/04/25 18:10:08
A better explanation: This method does not "Asser
jam
2017/04/25 18:19:37
Done.
|
| + void Lock(); |
|
mmenke
2017/04/25 16:37:55
Add a TODO to remove this, once it's no longer use
mmenke
2017/04/25 16:37:55
Can we not call this lock? Commit() or Initialize
jam
2017/04/25 17:04:40
Done.
jam
2017/04/25 17:04:40
Done.
|
| + |
| // HostResolverProc methods: |
| int Resolve(const std::string& host, |
| AddressFamily address_family, |
| @@ -219,10 +222,36 @@ class RuleBasedHostResolverProc : public HostResolverProc { |
| AddressList* addrlist, |
| int* os_error) override; |
| - private: |
| - struct Rule; |
| + struct Rule { |
| + enum ResolverType { |
| + kResolverTypeFail, |
| + kResolverTypeSystem, |
| + kResolverTypeIPLiteral, |
| + }; |
| + |
| + ResolverType resolver_type; |
| + std::string host_pattern; |
| + AddressFamily address_family; |
| + HostResolverFlags host_resolver_flags; |
| + std::string replacement; |
| + std::string canonical_name; |
|
mmenke
2017/04/25 16:37:54
include <string> (Should have been included alread
jam
2017/04/25 17:04:41
Done.
|
| + int latency_ms; // In milliseconds. |
| + |
| + 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); |
|
mmenke
2017/04/25 16:37:56
Per style guide, constructor/destructor should go
jam
2017/04/25 17:04:40
Done.
|
| + }; |
| + |
| typedef std::list<Rule> RuleList; |
| + RuleList GetRules(); |
| + |
| + private: |
| ~RuleBasedHostResolverProc() override; |
| void AddRuleInternal(const Rule& rule); |
| @@ -231,6 +260,9 @@ class RuleBasedHostResolverProc : public HostResolverProc { |
| // Must be obtained before writing to or reading from |rules_|. |
| base::Lock rule_lock_; |
| + |
| + // Whether changes are allowed. |
| + bool locked_; |
|
mmenke
2017/04/25 16:37:55
Hrm...Should this be protected by the lock as well
jam
2017/04/25 17:04:40
this will be modified before any threading happens
mmenke
2017/04/25 17:29:46
SGTM (Particularly with the above TODO)
|
| }; |
| // Create rules that map all requests to localhost. |