1 // Copyright (c) 2010 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_tokenizer.h"
8 #include "base/string_util.h"
9 #include "net/base/host_port_pair.h"
10 #include "net/base/net_util.h"
11
12 namespace net {
13
MappedHostResolver(HostResolver * impl)14 MappedHostResolver::MappedHostResolver(HostResolver* impl)
15 : impl_(impl) {
16 }
17
~MappedHostResolver()18 MappedHostResolver::~MappedHostResolver() {
19 }
20
Resolve(const RequestInfo & info,AddressList * addresses,CompletionCallback * callback,RequestHandle * out_req,const BoundNetLog & net_log)21 int MappedHostResolver::Resolve(const RequestInfo& info,
22 AddressList* addresses,
23 CompletionCallback* callback,
24 RequestHandle* out_req,
25 const BoundNetLog& net_log) {
26 // Modify the request before forwarding it to |impl_|.
27 RequestInfo modified_info = info;
28 HostPortPair host_port(info.host_port_pair());
29 if (rules_.RewriteHost(&host_port))
30 modified_info.set_host_port_pair(host_port);
31 return impl_->Resolve(modified_info, addresses, callback, out_req, net_log);
32 }
33
CancelRequest(RequestHandle req)34 void MappedHostResolver::CancelRequest(RequestHandle req) {
35 impl_->CancelRequest(req);
36 }
37
AddObserver(Observer * observer)38 void MappedHostResolver::AddObserver(Observer* observer) {
39 impl_->AddObserver(observer);
40 }
41
RemoveObserver(Observer * observer)42 void MappedHostResolver::RemoveObserver(Observer* observer) {
43 impl_->RemoveObserver(observer);
44 }
45
GetAsHostResolverImpl()46 HostResolverImpl* MappedHostResolver::GetAsHostResolverImpl() {
47 return impl_->GetAsHostResolverImpl();
48 }
49
50 } // namespace net
51