Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(786)

Side by Side Diff: net/dns/dns_socket_pool.cc

Issue 16434016: Rewrite scoped_ptr<T>(NULL) to use the default ctor in net/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/dns/dns_session.cc ('k') | net/dns/dns_transaction_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 } 180 }
181 181
182 scoped_ptr<DatagramClientSocket> DefaultDnsSocketPool::AllocateSocket( 182 scoped_ptr<DatagramClientSocket> DefaultDnsSocketPool::AllocateSocket(
183 unsigned server_index) { 183 unsigned server_index) {
184 DCHECK_LT(server_index, pools_.size()); 184 DCHECK_LT(server_index, pools_.size());
185 SocketVector& pool = pools_[server_index]; 185 SocketVector& pool = pools_[server_index];
186 186
187 FillPool(server_index, kAllocateMinSize); 187 FillPool(server_index, kAllocateMinSize);
188 if (pool.size() == 0) { 188 if (pool.size() == 0) {
189 LOG(WARNING) << "No DNS sockets available in pool " << server_index << "!"; 189 LOG(WARNING) << "No DNS sockets available in pool " << server_index << "!";
190 return scoped_ptr<DatagramClientSocket>(NULL); 190 return scoped_ptr<DatagramClientSocket>();
191 } 191 }
192 192
193 if (pool.size() < kAllocateMinSize) { 193 if (pool.size() < kAllocateMinSize) {
194 LOG(WARNING) << "Low DNS port entropy: wanted " << kAllocateMinSize 194 LOG(WARNING) << "Low DNS port entropy: wanted " << kAllocateMinSize
195 << " sockets to choose from, but only have " << pool.size() 195 << " sockets to choose from, but only have " << pool.size()
196 << " in pool " << server_index << "."; 196 << " in pool " << server_index << ".";
197 } 197 }
198 198
199 unsigned socket_index = base::RandInt(0, pool.size() - 1); 199 unsigned socket_index = base::RandInt(0, pool.size() - 1);
200 DatagramClientSocket* socket = pool[socket_index]; 200 DatagramClientSocket* socket = pool[socket_index];
(...skipping 24 matching lines...) Expand all
225 for (unsigned pool_index = pool.size(); pool_index < size; ++pool_index) { 225 for (unsigned pool_index = pool.size(); pool_index < size; ++pool_index) {
226 DatagramClientSocket* socket = 226 DatagramClientSocket* socket =
227 CreateConnectedSocket(server_index).release(); 227 CreateConnectedSocket(server_index).release();
228 if (!socket) 228 if (!socket)
229 break; 229 break;
230 pool.push_back(socket); 230 pool.push_back(socket);
231 } 231 }
232 } 232 }
233 233
234 } // namespace net 234 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/dns_session.cc ('k') | net/dns/dns_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698