| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_BASE_MAPPED_HOST_RESOLVER_H_ | 5 #ifndef NET_BASE_MAPPED_HOST_RESOLVER_H_ |
| 6 #define NET_BASE_MAPPED_HOST_RESOLVER_H_ | 6 #define NET_BASE_MAPPED_HOST_RESOLVER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "net/base/host_mapping_rules.h" | 11 #include "net/base/host_mapping_rules.h" |
| 12 #include "net/base/host_resolver.h" | 12 #include "net/base/host_resolver.h" |
| 13 #include "net/base/net_export.h" | 13 #include "net/base/net_export.h" |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 | 16 |
| 17 // This class wraps an existing HostResolver instance, but modifies the | 17 // This class wraps an existing HostResolver instance, but modifies the |
| 18 // request before passing it off to |impl|. This is different from | 18 // request before passing it off to |impl|. This is different from |
| 19 // MockHostResolver which does the remapping at the HostResolverProc | 19 // MockHostResolver which does the remapping at the HostResolverProc |
| 20 // layer, so it is able to preserve the effectiveness of the cache. | 20 // layer, so it is able to preserve the effectiveness of the cache. |
| 21 class NET_EXPORT MappedHostResolver : public HostResolver { | 21 class NET_EXPORT MappedHostResolver : public HostResolver { |
| 22 public: | 22 public: |
| 23 // Creates a MappedHostResolver that forwards all of its requests through | 23 // Creates a MappedHostResolver that forwards all of its requests through |
| 24 // |impl|. It takes ownership of |impl|. | 24 // |impl|. |
| 25 explicit MappedHostResolver(HostResolver* impl); | 25 explicit MappedHostResolver(scoped_ptr<HostResolver> impl); |
| 26 virtual ~MappedHostResolver(); | 26 virtual ~MappedHostResolver(); |
| 27 | 27 |
| 28 // Adds a rule to this mapper. The format of the rule can be one of: | 28 // Adds a rule to this mapper. The format of the rule can be one of: |
| 29 // | 29 // |
| 30 // "MAP" <hostname_pattern> <replacement_host> [":" <replacement_port>] | 30 // "MAP" <hostname_pattern> <replacement_host> [":" <replacement_port>] |
| 31 // "EXCLUDE" <hostname_pattern> | 31 // "EXCLUDE" <hostname_pattern> |
| 32 // | 32 // |
| 33 // The <replacement_host> can be either a hostname, or an IP address literal. | 33 // The <replacement_host> can be either a hostname, or an IP address literal. |
| 34 // | 34 // |
| 35 // Returns true if the rule was successfully parsed and added. | 35 // Returns true if the rule was successfully parsed and added. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 60 RequestInfo ApplyRules(const RequestInfo& info) const; | 60 RequestInfo ApplyRules(const RequestInfo& info) const; |
| 61 | 61 |
| 62 scoped_ptr<HostResolver> impl_; | 62 scoped_ptr<HostResolver> impl_; |
| 63 | 63 |
| 64 HostMappingRules rules_; | 64 HostMappingRules rules_; |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 } // namespace net | 67 } // namespace net |
| 68 | 68 |
| 69 #endif // NET_BASE_MAPPED_HOST_RESOLVER_H_ | 69 #endif // NET_BASE_MAPPED_HOST_RESOLVER_H_ |
| OLD | NEW |