| 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_socket_pool.h" |    5 #include "net/dns/dns_socket_pool.h" | 
|    6  |    6  | 
|    7 #include "base/logging.h" |    7 #include "base/logging.h" | 
|    8 #include "base/rand_util.h" |    8 #include "base/rand_util.h" | 
|    9 #include "base/stl_util.h" |    9 #include "base/stl_util.h" | 
|   10 #include "net/base/address_list.h" |   10 #include "net/base/address_list.h" | 
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   90 } |   90 } | 
|   91  |   91  | 
|   92 class NullDnsSocketPool : public DnsSocketPool { |   92 class NullDnsSocketPool : public DnsSocketPool { | 
|   93  public: |   93  public: | 
|   94   NullDnsSocketPool(ClientSocketFactory* factory) |   94   NullDnsSocketPool(ClientSocketFactory* factory) | 
|   95      : DnsSocketPool(factory) { |   95      : DnsSocketPool(factory) { | 
|   96   } |   96   } | 
|   97  |   97  | 
|   98   virtual void Initialize( |   98   virtual void Initialize( | 
|   99       const std::vector<IPEndPoint>* nameservers, |   99       const std::vector<IPEndPoint>* nameservers, | 
|  100       NetLog* net_log) OVERRIDE { |  100       NetLog* net_log) override { | 
|  101     InitializeInternal(nameservers, net_log); |  101     InitializeInternal(nameservers, net_log); | 
|  102   } |  102   } | 
|  103  |  103  | 
|  104   virtual scoped_ptr<DatagramClientSocket> AllocateSocket( |  104   virtual scoped_ptr<DatagramClientSocket> AllocateSocket( | 
|  105       unsigned server_index) OVERRIDE { |  105       unsigned server_index) override { | 
|  106     return CreateConnectedSocket(server_index); |  106     return CreateConnectedSocket(server_index); | 
|  107   } |  107   } | 
|  108  |  108  | 
|  109   virtual void FreeSocket( |  109   virtual void FreeSocket( | 
|  110       unsigned server_index, |  110       unsigned server_index, | 
|  111       scoped_ptr<DatagramClientSocket> socket) OVERRIDE { |  111       scoped_ptr<DatagramClientSocket> socket) override { | 
|  112   } |  112   } | 
|  113  |  113  | 
|  114  private: |  114  private: | 
|  115   DISALLOW_COPY_AND_ASSIGN(NullDnsSocketPool); |  115   DISALLOW_COPY_AND_ASSIGN(NullDnsSocketPool); | 
|  116 }; |  116 }; | 
|  117  |  117  | 
|  118 // static |  118 // static | 
|  119 scoped_ptr<DnsSocketPool> DnsSocketPool::CreateNull( |  119 scoped_ptr<DnsSocketPool> DnsSocketPool::CreateNull( | 
|  120     ClientSocketFactory* factory) { |  120     ClientSocketFactory* factory) { | 
|  121   return scoped_ptr<DnsSocketPool>(new NullDnsSocketPool(factory)); |  121   return scoped_ptr<DnsSocketPool>(new NullDnsSocketPool(factory)); | 
|  122 } |  122 } | 
|  123  |  123  | 
|  124 class DefaultDnsSocketPool : public DnsSocketPool { |  124 class DefaultDnsSocketPool : public DnsSocketPool { | 
|  125  public: |  125  public: | 
|  126   DefaultDnsSocketPool(ClientSocketFactory* factory) |  126   DefaultDnsSocketPool(ClientSocketFactory* factory) | 
|  127      : DnsSocketPool(factory) { |  127      : DnsSocketPool(factory) { | 
|  128   }; |  128   }; | 
|  129  |  129  | 
|  130   virtual ~DefaultDnsSocketPool(); |  130   virtual ~DefaultDnsSocketPool(); | 
|  131  |  131  | 
|  132   virtual void Initialize( |  132   virtual void Initialize( | 
|  133       const std::vector<IPEndPoint>* nameservers, |  133       const std::vector<IPEndPoint>* nameservers, | 
|  134       NetLog* net_log) OVERRIDE; |  134       NetLog* net_log) override; | 
|  135  |  135  | 
|  136   virtual scoped_ptr<DatagramClientSocket> AllocateSocket( |  136   virtual scoped_ptr<DatagramClientSocket> AllocateSocket( | 
|  137       unsigned server_index) OVERRIDE; |  137       unsigned server_index) override; | 
|  138  |  138  | 
|  139   virtual void FreeSocket( |  139   virtual void FreeSocket( | 
|  140       unsigned server_index, |  140       unsigned server_index, | 
|  141       scoped_ptr<DatagramClientSocket> socket) OVERRIDE; |  141       scoped_ptr<DatagramClientSocket> socket) override; | 
|  142  |  142  | 
|  143  private: |  143  private: | 
|  144   void FillPool(unsigned server_index, unsigned size); |  144   void FillPool(unsigned server_index, unsigned size); | 
|  145  |  145  | 
|  146   typedef std::vector<DatagramClientSocket*> SocketVector; |  146   typedef std::vector<DatagramClientSocket*> SocketVector; | 
|  147  |  147  | 
|  148   std::vector<SocketVector> pools_; |  148   std::vector<SocketVector> pools_; | 
|  149  |  149  | 
|  150   DISALLOW_COPY_AND_ASSIGN(DefaultDnsSocketPool); |  150   DISALLOW_COPY_AND_ASSIGN(DefaultDnsSocketPool); | 
|  151 }; |  151 }; | 
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  213   for (unsigned pool_index = pool.size(); pool_index < size; ++pool_index) { |  213   for (unsigned pool_index = pool.size(); pool_index < size; ++pool_index) { | 
|  214     DatagramClientSocket* socket = |  214     DatagramClientSocket* socket = | 
|  215         CreateConnectedSocket(server_index).release(); |  215         CreateConnectedSocket(server_index).release(); | 
|  216     if (!socket) |  216     if (!socket) | 
|  217       break; |  217       break; | 
|  218     pool.push_back(socket); |  218     pool.push_back(socket); | 
|  219   } |  219   } | 
|  220 } |  220 } | 
|  221  |  221  | 
|  222 } // namespace net |  222 } // namespace net | 
| OLD | NEW |