| 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" | 
|  11 #include "net/dns/dns_config_service.h" |  11 #include "net/dns/dns_config_service.h" | 
|  12 #include "net/dns/dns_session.h" |  12 #include "net/dns/dns_session.h" | 
 |  13 #include "net/dns/dns_socket_pool.h" | 
|  13 #include "net/dns/dns_transaction.h" |  14 #include "net/dns/dns_transaction.h" | 
|  14 #include "net/socket/client_socket_factory.h" |  15 #include "net/socket/client_socket_factory.h" | 
|  15  |  16  | 
|  16 namespace net { |  17 namespace net { | 
|  17  |  18  | 
|  18 namespace { |  19 namespace { | 
|  19  |  20  | 
|  20 class DnsClientImpl : public DnsClient { |  21 class DnsClientImpl : public DnsClient { | 
|  21  public: |  22  public: | 
|  22   explicit DnsClientImpl(NetLog* net_log) |  23   explicit DnsClientImpl(NetLog* net_log) | 
|  23       : address_sorter_(AddressSorter::CreateAddressSorter()), |  24       : address_sorter_(AddressSorter::CreateAddressSorter()), | 
|  24         net_log_(net_log) {} |  25         net_log_(net_log) {} | 
|  25  |  26  | 
|  26   virtual void SetConfig(const DnsConfig& config) OVERRIDE { |  27   virtual void SetConfig(const DnsConfig& config) OVERRIDE { | 
|  27     factory_.reset(); |  28     factory_.reset(); | 
|  28     session_ = NULL; |  29     session_ = NULL; | 
|  29     if (config.IsValid()) { |  30     if (config.IsValid()) { | 
|  30       session_ = new DnsSession(config, |  31       session_ = new DnsSession(config, | 
|  31                                 ClientSocketFactory::GetDefaultFactory(), |  32                                 ClientSocketFactory::GetDefaultFactory(), | 
 |  33                                 DnsSocketPool::MakeDefault().Pass(), | 
|  32                                 base::Bind(&base::RandInt), |  34                                 base::Bind(&base::RandInt), | 
|  33                                 net_log_); |  35                                 net_log_); | 
|  34       factory_ = DnsTransactionFactory::CreateFactory(session_); |  36       factory_ = DnsTransactionFactory::CreateFactory(session_); | 
|  35     } |  37     } | 
|  36   } |  38   } | 
|  37  |  39  | 
|  38   virtual const DnsConfig* GetConfig() const OVERRIDE { |  40   virtual const DnsConfig* GetConfig() const OVERRIDE { | 
|  39     return session_.get() ? &session_->config() : NULL; |  41     return session_.get() ? &session_->config() : NULL; | 
|  40   } |  42   } | 
|  41  |  43  | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
|  57  |  59  | 
|  58 }  // namespace |  60 }  // namespace | 
|  59  |  61  | 
|  60 // static |  62 // static | 
|  61 scoped_ptr<DnsClient> DnsClient::CreateClient(NetLog* net_log) { |  63 scoped_ptr<DnsClient> DnsClient::CreateClient(NetLog* net_log) { | 
|  62   return scoped_ptr<DnsClient>(new DnsClientImpl(net_log)); |  64   return scoped_ptr<DnsClient>(new DnsClientImpl(net_log)); | 
|  63 } |  65 } | 
|  64  |  66  | 
|  65 }  // namespace net |  67 }  // namespace net | 
|  66  |  68  | 
| OLD | NEW |