Chromium Code Reviews| Index: net/dns/mapped_ip_resolver.h |
| diff --git a/net/dns/mapped_host_resolver.h b/net/dns/mapped_ip_resolver.h |
| similarity index 56% |
| copy from net/dns/mapped_host_resolver.h |
| copy to net/dns/mapped_ip_resolver.h |
| index c03a2a66d46d7a2b99a6cd2606dcb56515af5e84..2773630e6240a6e3666ce0f968c3b629fbdb0c62 100644 |
| --- a/net/dns/mapped_host_resolver.h |
| +++ b/net/dns/mapped_ip_resolver.h |
| @@ -1,39 +1,32 @@ |
| -// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Copyright (c) 2014 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 NET_DNS_MAPPED_HOST_RESOLVER_H_ |
| -#define NET_DNS_MAPPED_HOST_RESOLVER_H_ |
| +#ifndef NET_DNS_MAPPED_IP_RESOLVER_H_ |
| +#define NET_DNS_MAPPED_IP_RESOLVER_H_ |
| #include <string> |
| #include "base/memory/scoped_ptr.h" |
| -#include "net/base/host_mapping_rules.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "net/base/ip_mapping_rules.h" |
| #include "net/base/net_export.h" |
| #include "net/dns/host_resolver.h" |
| namespace net { |
| // This class wraps an existing HostResolver instance, but modifies the |
| -// request before passing it off to |impl|. This is different from |
| -// MockHostResolver which does the remapping at the HostResolverProc |
| -// layer, so it is able to preserve the effectiveness of the cache. |
| -class NET_EXPORT MappedHostResolver : public HostResolver { |
| +// resolution response by inserting or replacing IP addresses before returning |
|
wtc
2014/02/11 23:52:30
You only implemented the "PREFACE" directive, righ
jar (doing other things)
2014/02/15 21:14:56
I added clarifying comments.
|
| +// it. |
| +class NET_EXPORT MappedIPResolver : public HostResolver { |
|
wtc
2014/02/11 23:52:30
Nit: "IPResolver" is a poor name because there is
jar (doing other things)
2014/02/15 21:14:56
As per offline discussion.... I parsed the names (
|
| public: |
| // Creates a MappedHostResolver that forwards all of its requests through |
|
wtc
2014/02/11 23:52:30
MappedHostResolver => MappedIPResolver
jar (doing other things)
2014/02/15 21:14:56
Done.
|
| // |impl|. |
| - explicit MappedHostResolver(scoped_ptr<HostResolver> impl); |
| - virtual ~MappedHostResolver(); |
| + explicit MappedIPResolver(scoped_ptr<HostResolver> impl); |
| + virtual ~MappedIPResolver(); |
| - // Adds a rule to this mapper. The format of the rule can be one of: |
| - // |
| - // "MAP" <hostname_pattern> <replacement_host> [":" <replacement_port>] |
| - // "EXCLUDE" <hostname_pattern> |
| - // |
| - // The <replacement_host> can be either a hostname, or an IP address literal, |
| - // or "~NOTFOUND". If it is "~NOTFOUND" then all matched hostnames will fail |
| - // to be resolved with ERR_NAME_NOT_RESOLVED. |
| - // |
| + // Adds a rule to our IP mapper rules_. |
| + // See ip_mapping_rules.h for syntax and semantics. |
| // Returns true if the rule was successfully parsed and added. |
| bool AddRuleFromString(const std::string& rule_string) { |
| return rules_.AddRuleFromString(rule_string); |
| @@ -60,15 +53,19 @@ class NET_EXPORT MappedHostResolver : public HostResolver { |
| virtual base::Value* GetDnsConfigAsValue() const OVERRIDE; |
| private: |
| - // Modify the request |info| according to |rules_|. Returns either OK or |
| - // the network error code that the hostname's resolution mapped to. |
| - int ApplyRules(RequestInfo* info) const; |
| + // Modify the list of resolution |addresses| according to |rules_|, and then |
| + // calls the |original_cb| with network error code |rv|. |
| + void ApplyRules(const CompletionCallback& original_cb, |
|
wtc
2014/02/11 23:52:30
Nit: it may be nice to be verbose and name this pa
jar (doing other things)
2014/02/15 21:14:56
Done.
|
| + AddressList* addresses, |
| + int rv) const; |
| scoped_ptr<HostResolver> impl_; |
| + IPMappingRules rules_; |
| - HostMappingRules rules_; |
| + base::WeakPtrFactory<MappedIPResolver> weak_factory_; |
| + DISALLOW_COPY_AND_ASSIGN(MappedIPResolver); |
| }; |
| } // namespace net |
| -#endif // NET_DNS_MAPPED_HOST_RESOLVER_H_ |
| +#endif // NET_DNS_MAPPED_IP_RESOLVER_H_ |