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 #include "net/dns/dns_client.h" | 5 #include "net/dns/dns_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
9 #include "net/base/net_log.h" | 9 #include "net/base/net_log.h" |
10 #include "net/dns/address_sorter.h" | 10 #include "net/dns/address_sorter.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 net_log_(net_log) {} | 25 net_log_(net_log) {} |
26 | 26 |
27 virtual void SetConfig(const DnsConfig& config) OVERRIDE { | 27 virtual void SetConfig(const DnsConfig& config) OVERRIDE { |
28 factory_.reset(); | 28 factory_.reset(); |
29 session_ = NULL; | 29 session_ = NULL; |
30 if (config.IsValid() && !config.unhandled_options) { | 30 if (config.IsValid() && !config.unhandled_options) { |
31 ClientSocketFactory* factory = ClientSocketFactory::GetDefaultFactory(); | 31 ClientSocketFactory* factory = ClientSocketFactory::GetDefaultFactory(); |
32 scoped_ptr<DnsSocketPool> socket_pool( | 32 scoped_ptr<DnsSocketPool> socket_pool( |
33 config.randomize_ports ? DnsSocketPool::CreateDefault(factory) | 33 config.randomize_ports ? DnsSocketPool::CreateDefault(factory) |
34 : DnsSocketPool::CreateNull(factory)); | 34 : DnsSocketPool::CreateNull(factory)); |
35 session_ = new DnsSession(config, | 35 session_ = new DnsSession( |
36 socket_pool.Pass(), | 36 config, socket_pool.Pass(), base::Bind(&base::RandInt), net_log_); |
37 base::Bind(&base::RandInt), | |
38 net_log_); | |
39 factory_ = DnsTransactionFactory::CreateFactory(session_.get()); | 37 factory_ = DnsTransactionFactory::CreateFactory(session_.get()); |
40 } | 38 } |
41 } | 39 } |
42 | 40 |
43 virtual const DnsConfig* GetConfig() const OVERRIDE { | 41 virtual const DnsConfig* GetConfig() const OVERRIDE { |
44 return session_.get() ? &session_->config() : NULL; | 42 return session_.get() ? &session_->config() : NULL; |
45 } | 43 } |
46 | 44 |
47 virtual DnsTransactionFactory* GetTransactionFactory() OVERRIDE { | 45 virtual DnsTransactionFactory* GetTransactionFactory() OVERRIDE { |
48 return session_.get() ? factory_.get() : NULL; | 46 return session_.get() ? factory_.get() : NULL; |
(...skipping 12 matching lines...) Expand all Loading... |
61 }; | 59 }; |
62 | 60 |
63 } // namespace | 61 } // namespace |
64 | 62 |
65 // static | 63 // static |
66 scoped_ptr<DnsClient> DnsClient::CreateClient(NetLog* net_log) { | 64 scoped_ptr<DnsClient> DnsClient::CreateClient(NetLog* net_log) { |
67 return scoped_ptr<DnsClient>(new DnsClientImpl(net_log)); | 65 return scoped_ptr<DnsClient>(new DnsClientImpl(net_log)); |
68 } | 66 } |
69 | 67 |
70 } // namespace net | 68 } // namespace net |
71 | |
OLD | NEW |