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

Side by Side Diff: net/dns/dns_session.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/disk_cache/simple/simple_index_file.cc ('k') | net/dns/dns_socket_pool.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_session.h" 5 #include "net/dns/dns_session.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 return std::min(timeout * (1 << num_backoffs), 222 return std::min(timeout * (1 << num_backoffs),
223 base::TimeDelta::FromMilliseconds(kMaxTimeoutMs)); 223 base::TimeDelta::FromMilliseconds(kMaxTimeoutMs));
224 } 224 }
225 225
226 // Allocate a socket, already connected to the server address. 226 // Allocate a socket, already connected to the server address.
227 scoped_ptr<DnsSession::SocketLease> DnsSession::AllocateSocket( 227 scoped_ptr<DnsSession::SocketLease> DnsSession::AllocateSocket(
228 unsigned server_index, const NetLog::Source& source) { 228 unsigned server_index, const NetLog::Source& source) {
229 scoped_ptr<DatagramClientSocket> socket; 229 scoped_ptr<DatagramClientSocket> socket;
230 230
231 socket = socket_pool_->AllocateSocket(server_index); 231 socket = socket_pool_->AllocateSocket(server_index);
232 if (!socket.get()) return scoped_ptr<SocketLease>(NULL); 232 if (!socket.get())
233 return scoped_ptr<SocketLease>();
233 234
234 socket->NetLog().BeginEvent(NetLog::TYPE_SOCKET_IN_USE, 235 socket->NetLog().BeginEvent(NetLog::TYPE_SOCKET_IN_USE,
235 source.ToEventParametersCallback()); 236 source.ToEventParametersCallback());
236 237
237 SocketLease* lease = new SocketLease(this, server_index, socket.Pass()); 238 SocketLease* lease = new SocketLease(this, server_index, socket.Pass());
238 return scoped_ptr<SocketLease>(lease); 239 return scoped_ptr<SocketLease>(lease);
239 } 240 }
240 241
241 scoped_ptr<StreamSocket> DnsSession::CreateTCPSocket( 242 scoped_ptr<StreamSocket> DnsSession::CreateTCPSocket(
242 unsigned server_index, const NetLog::Source& source) { 243 unsigned server_index, const NetLog::Source& source) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 timeout = std::max(timeout, base::TimeDelta::FromMilliseconds(kMinTimeoutMs)); 295 timeout = std::max(timeout, base::TimeDelta::FromMilliseconds(kMinTimeoutMs));
295 296
296 // The timeout still doubles every full round. 297 // The timeout still doubles every full round.
297 unsigned num_backoffs = attempt / config_.nameservers.size(); 298 unsigned num_backoffs = attempt / config_.nameservers.size();
298 299
299 return std::min(timeout * (1 << num_backoffs), 300 return std::min(timeout * (1 << num_backoffs),
300 base::TimeDelta::FromMilliseconds(kMaxTimeoutMs)); 301 base::TimeDelta::FromMilliseconds(kMaxTimeoutMs));
301 } 302 }
302 303
303 } // namespace net 304 } // namespace net
OLDNEW
« no previous file with comments | « net/disk_cache/simple/simple_index_file.cc ('k') | net/dns/dns_socket_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698