| 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_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/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| 11 #include "base/time.h" | 11 #include "base/time.h" |
| 12 #include "net/base/ip_endpoint.h" | 12 #include "net/base/ip_endpoint.h" |
| 13 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 14 #include "net/dns/dns_config_service.h" | 14 #include "net/dns/dns_config_service.h" |
| 15 #include "net/dns/dns_socket_pool.h" | 15 #include "net/dns/dns_socket_pool.h" |
| 16 #include "net/socket/stream_socket.h" |
| 17 #include "net/udp/datagram_client_socket.h" |
| 16 | 18 |
| 17 namespace net { | 19 namespace net { |
| 18 | 20 |
| 19 DnsSession::SocketLease::SocketLease(scoped_refptr<DnsSession> session, | 21 DnsSession::SocketLease::SocketLease(scoped_refptr<DnsSession> session, |
| 20 unsigned server_index, | 22 unsigned server_index, |
| 21 scoped_ptr<DatagramClientSocket> socket) | 23 scoped_ptr<DatagramClientSocket> socket) |
| 22 : session_(session), server_index_(server_index), socket_(socket.Pass()) {} | 24 : session_(session), server_index_(server_index), socket_(socket.Pass()) {} |
| 23 | 25 |
| 24 DnsSession::SocketLease::~SocketLease() { | 26 DnsSession::SocketLease::~SocketLease() { |
| 25 session_->FreeSocket(server_index_, socket_.Pass()); | 27 session_->FreeSocket(server_index_, socket_.Pass()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 return scoped_ptr<SocketLease>(NULL); | 70 return scoped_ptr<SocketLease>(NULL); |
| 69 | 71 |
| 70 socket->NetLog().BeginEvent( | 72 socket->NetLog().BeginEvent( |
| 71 NetLog::TYPE_SOCKET_IN_USE, | 73 NetLog::TYPE_SOCKET_IN_USE, |
| 72 source.ToEventParametersCallback()); | 74 source.ToEventParametersCallback()); |
| 73 | 75 |
| 74 SocketLease* lease = new SocketLease(this, server_index, socket.Pass()); | 76 SocketLease* lease = new SocketLease(this, server_index, socket.Pass()); |
| 75 return scoped_ptr<SocketLease>(lease); | 77 return scoped_ptr<SocketLease>(lease); |
| 76 } | 78 } |
| 77 | 79 |
| 80 scoped_ptr<StreamSocket> DnsSession::CreateTCPSocket( |
| 81 unsigned server_index, |
| 82 const NetLog::Source& source) { |
| 83 return socket_pool_->CreateTCPSocket(server_index, source); |
| 84 } |
| 85 |
| 78 // Release a socket. | 86 // Release a socket. |
| 79 void DnsSession::FreeSocket( | 87 void DnsSession::FreeSocket( |
| 80 unsigned server_index, | 88 unsigned server_index, |
| 81 scoped_ptr<DatagramClientSocket> socket) { | 89 scoped_ptr<DatagramClientSocket> socket) { |
| 82 DCHECK(socket.get()); | 90 DCHECK(socket.get()); |
| 83 | 91 |
| 84 socket->NetLog().EndEvent(NetLog::TYPE_SOCKET_IN_USE); | 92 socket->NetLog().EndEvent(NetLog::TYPE_SOCKET_IN_USE); |
| 85 | 93 |
| 86 socket_pool_->FreeSocket(server_index, socket.Pass()); | 94 socket_pool_->FreeSocket(server_index, socket.Pass()); |
| 87 } | 95 } |
| 88 | 96 |
| 89 } // namespace net | 97 } // namespace net |
| OLD | NEW |