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

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

Issue 2333923004: Extracting NetLog inner classes into their own classes. (Closed)
Patch Set: Some nit fixes and better, impl-agnostic naming of net_log_parameters_callback_typedef.h -> net/log… Created 4 years, 2 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
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/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"
11 #include "net/base/address_list.h" 11 #include "net/base/address_list.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/log/net_log_source.h"
14 #include "net/socket/client_socket_factory.h" 15 #include "net/socket/client_socket_factory.h"
15 #include "net/socket/stream_socket.h" 16 #include "net/socket/stream_socket.h"
16 #include "net/udp/datagram_client_socket.h" 17 #include "net/udp/datagram_client_socket.h"
17 18
18 namespace net { 19 namespace net {
19 20
20 namespace { 21 namespace {
21 22
22 // When we initialize the SocketPool, we allocate kInitialPoolSize sockets. 23 // When we initialize the SocketPool, we allocate kInitialPoolSize sockets.
23 // When we allocate a socket, we ensure we have at least kAllocateMinSize 24 // When we allocate a socket, we ensure we have at least kAllocateMinSize
(...skipping 28 matching lines...) Expand all
52 DCHECK(nameservers); 53 DCHECK(nameservers);
53 DCHECK(!initialized_); 54 DCHECK(!initialized_);
54 55
55 net_log_ = net_log; 56 net_log_ = net_log;
56 nameservers_ = nameservers; 57 nameservers_ = nameservers;
57 initialized_ = true; 58 initialized_ = true;
58 } 59 }
59 60
60 std::unique_ptr<StreamSocket> DnsSocketPool::CreateTCPSocket( 61 std::unique_ptr<StreamSocket> DnsSocketPool::CreateTCPSocket(
61 unsigned server_index, 62 unsigned server_index,
62 const NetLog::Source& source) { 63 const NetLogSource& source) {
63 DCHECK_LT(server_index, nameservers_->size()); 64 DCHECK_LT(server_index, nameservers_->size());
64 65
65 return std::unique_ptr<StreamSocket>( 66 return std::unique_ptr<StreamSocket>(
66 socket_factory_->CreateTransportClientSocket( 67 socket_factory_->CreateTransportClientSocket(
67 AddressList((*nameservers_)[server_index]), NULL, net_log_, source)); 68 AddressList((*nameservers_)[server_index]), NULL, net_log_, source));
68 } 69 }
69 70
70 std::unique_ptr<DatagramClientSocket> DnsSocketPool::CreateConnectedSocket( 71 std::unique_ptr<DatagramClientSocket> DnsSocketPool::CreateConnectedSocket(
71 unsigned server_index) { 72 unsigned server_index) {
72 DCHECK_LT(server_index, nameservers_->size()); 73 DCHECK_LT(server_index, nameservers_->size());
73 74
74 std::unique_ptr<DatagramClientSocket> socket; 75 std::unique_ptr<DatagramClientSocket> socket;
75 76
76 NetLog::Source no_source; 77 NetLogSource no_source;
77 socket = socket_factory_->CreateDatagramClientSocket( 78 socket = socket_factory_->CreateDatagramClientSocket(
78 kBindType, rand_int_callback_, net_log_, no_source); 79 kBindType, rand_int_callback_, net_log_, no_source);
79 80
80 if (socket.get()) { 81 if (socket.get()) {
81 int rv = socket->Connect((*nameservers_)[server_index]); 82 int rv = socket->Connect((*nameservers_)[server_index]);
82 if (rv != OK) { 83 if (rv != OK) {
83 DVLOG(1) << "Failed to connect socket: " << rv; 84 DVLOG(1) << "Failed to connect socket: " << rv;
84 socket.reset(); 85 socket.reset();
85 } 86 }
86 } else { 87 } else {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 for (unsigned pool_index = pool.size(); pool_index < size; ++pool_index) { 218 for (unsigned pool_index = pool.size(); pool_index < size; ++pool_index) {
218 DatagramClientSocket* socket = 219 DatagramClientSocket* socket =
219 CreateConnectedSocket(server_index).release(); 220 CreateConnectedSocket(server_index).release();
220 if (!socket) 221 if (!socket)
221 break; 222 break;
222 pool.push_back(socket); 223 pool.push_back(socket);
223 } 224 }
224 } 225 }
225 226
226 } // namespace net 227 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698