Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: net/base/mapped_host_resolver.cc

Issue 12518036: net: move host_resolver files from net/base to net/dns (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "net/base/mapped_host_resolver.h"
6
7 #include "base/string_util.h"
8 #include "net/base/host_port_pair.h"
9 #include "net/base/net_errors.h"
10 #include "net/base/net_util.h"
11
12 namespace net {
13
14 MappedHostResolver::MappedHostResolver(scoped_ptr<HostResolver> impl)
15 : impl_(impl.Pass()) {
16 }
17
18 MappedHostResolver::~MappedHostResolver() {
19 }
20
21 int MappedHostResolver::Resolve(const RequestInfo& original_info,
22 AddressList* addresses,
23 const CompletionCallback& callback,
24 RequestHandle* out_req,
25 const BoundNetLog& net_log) {
26 RequestInfo info = original_info;
27 int rv = ApplyRules(&info);
28 if (rv != OK)
29 return rv;
30
31 return impl_->Resolve(info, addresses, callback, out_req, net_log);
32 }
33
34 int MappedHostResolver::ResolveFromCache(const RequestInfo& original_info,
35 AddressList* addresses,
36 const BoundNetLog& net_log) {
37 RequestInfo info = original_info;
38 int rv = ApplyRules(&info);
39 if (rv != OK)
40 return rv;
41
42 return impl_->ResolveFromCache(info, addresses, net_log);
43 }
44
45 void MappedHostResolver::CancelRequest(RequestHandle req) {
46 impl_->CancelRequest(req);
47 }
48
49 void MappedHostResolver::ProbeIPv6Support() {
50 impl_->ProbeIPv6Support();
51 }
52
53 HostCache* MappedHostResolver::GetHostCache() {
54 return impl_->GetHostCache();
55 }
56
57 int MappedHostResolver::ApplyRules(RequestInfo* info) const {
58 HostPortPair host_port(info->host_port_pair());
59 if (rules_.RewriteHost(&host_port)) {
60 if (host_port.host() == "~NOTFOUND")
61 return ERR_NAME_NOT_RESOLVED;
62 info->set_host_port_pair(host_port);
63 }
64 return OK;
65 }
66
67 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698