| 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/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 private: | 146 private: |
| 147 void FillPool(unsigned server_index, unsigned size); | 147 void FillPool(unsigned server_index, unsigned size); |
| 148 | 148 |
| 149 typedef std::vector<DatagramClientSocket*> SocketVector; | 149 typedef std::vector<DatagramClientSocket*> SocketVector; |
| 150 | 150 |
| 151 std::vector<SocketVector> pools_; | 151 std::vector<SocketVector> pools_; |
| 152 | 152 |
| 153 DISALLOW_COPY_AND_ASSIGN(DefaultDnsSocketPool); | 153 DISALLOW_COPY_AND_ASSIGN(DefaultDnsSocketPool); |
| 154 }; | 154 }; |
| 155 | 155 |
| 156 DnsSocketPool::~DnsSocketPool() {} |
| 157 |
| 156 // static | 158 // static |
| 157 std::unique_ptr<DnsSocketPool> DnsSocketPool::CreateDefault( | 159 std::unique_ptr<DnsSocketPool> DnsSocketPool::CreateDefault( |
| 158 ClientSocketFactory* factory, | 160 ClientSocketFactory* factory, |
| 159 const RandIntCallback& rand_int_callback) { | 161 const RandIntCallback& rand_int_callback) { |
| 160 return std::unique_ptr<DnsSocketPool>( | 162 return std::unique_ptr<DnsSocketPool>( |
| 161 new DefaultDnsSocketPool(factory, rand_int_callback)); | 163 new DefaultDnsSocketPool(factory, rand_int_callback)); |
| 162 } | 164 } |
| 163 | 165 |
| 164 void DefaultDnsSocketPool::Initialize( | 166 void DefaultDnsSocketPool::Initialize( |
| 165 const std::vector<IPEndPoint>* nameservers, | 167 const std::vector<IPEndPoint>* nameservers, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 for (unsigned pool_index = pool.size(); pool_index < size; ++pool_index) { | 220 for (unsigned pool_index = pool.size(); pool_index < size; ++pool_index) { |
| 219 DatagramClientSocket* socket = | 221 DatagramClientSocket* socket = |
| 220 CreateConnectedSocket(server_index).release(); | 222 CreateConnectedSocket(server_index).release(); |
| 221 if (!socket) | 223 if (!socket) |
| 222 break; | 224 break; |
| 223 pool.push_back(socket); | 225 pool.push_back(socket); |
| 224 } | 226 } |
| 225 } | 227 } |
| 226 | 228 |
| 227 } // namespace net | 229 } // namespace net |
| OLD | NEW |