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

Side by Side Diff: net/dns/address_sorter_posix.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/address_sorter_posix.h" 5 #include "net/dns/address_sorter_posix.h"
6 6
7 #include <netinet/in.h> 7 #include <netinet/in.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
11 11
12 #if defined(OS_MACOSX) || defined(OS_BSD) 12 #if defined(OS_MACOSX) || defined(OS_BSD)
13 #include <sys/socket.h> // Must be included before ifaddrs.h. 13 #include <sys/socket.h> // Must be included before ifaddrs.h.
14 #include <ifaddrs.h> 14 #include <ifaddrs.h>
15 #include <net/if.h> 15 #include <net/if.h>
16 #include <netinet/in_var.h> 16 #include <netinet/in_var.h>
17 #include <string.h> 17 #include <string.h>
18 #include <sys/ioctl.h> 18 #include <sys/ioctl.h>
19 #endif 19 #endif
20 20
21 #include <algorithm> 21 #include <algorithm>
22 #include <vector> 22 #include <vector>
23 23
24 #include "base/logging.h" 24 #include "base/logging.h"
25 #include "net/base/net_errors.h" 25 #include "net/base/net_errors.h"
26 #include "net/log/net_log_source.h"
26 #include "net/socket/client_socket_factory.h" 27 #include "net/socket/client_socket_factory.h"
27 #include "net/udp/datagram_client_socket.h" 28 #include "net/udp/datagram_client_socket.h"
28 29
29 #if defined(OS_LINUX) 30 #if defined(OS_LINUX)
30 #include "net/base/address_tracker_linux.h" 31 #include "net/base/address_tracker_linux.h"
31 #endif 32 #endif
32 33
33 namespace net { 34 namespace net {
34 35
35 namespace { 36 namespace {
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 std::unique_ptr<DestinationInfo> info(new DestinationInfo()); 263 std::unique_ptr<DestinationInfo> info(new DestinationInfo());
263 info->address = list[i].address(); 264 info->address = list[i].address();
264 info->scope = GetScope(ipv4_scope_table_, info->address); 265 info->scope = GetScope(ipv4_scope_table_, info->address);
265 info->precedence = GetPolicyValue(precedence_table_, info->address); 266 info->precedence = GetPolicyValue(precedence_table_, info->address);
266 info->label = GetPolicyValue(label_table_, info->address); 267 info->label = GetPolicyValue(label_table_, info->address);
267 268
268 // Each socket can only be bound once. 269 // Each socket can only be bound once.
269 std::unique_ptr<DatagramClientSocket> socket( 270 std::unique_ptr<DatagramClientSocket> socket(
270 socket_factory_->CreateDatagramClientSocket( 271 socket_factory_->CreateDatagramClientSocket(
271 DatagramSocket::DEFAULT_BIND, RandIntCallback(), NULL /* NetLog */, 272 DatagramSocket::DEFAULT_BIND, RandIntCallback(), NULL /* NetLog */,
272 NetLog::Source())); 273 NetLogSource()));
273 274
274 // Even though no packets are sent, cannot use port 0 in Connect. 275 // Even though no packets are sent, cannot use port 0 in Connect.
275 IPEndPoint dest(info->address, 80 /* port */); 276 IPEndPoint dest(info->address, 80 /* port */);
276 int rv = socket->Connect(dest); 277 int rv = socket->Connect(dest);
277 if (rv != OK) { 278 if (rv != OK) {
278 VLOG(1) << "Could not connect to " << dest.ToStringWithoutPort() 279 VLOG(1) << "Could not connect to " << dest.ToStringWithoutPort()
279 << " reason " << rv; 280 << " reason " << rv;
280 continue; 281 continue;
281 } 282 }
282 // Filter out unusable destinations. 283 // Filter out unusable destinations.
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 } 391 }
391 392
392 // static 393 // static
393 std::unique_ptr<AddressSorter> AddressSorter::CreateAddressSorter() { 394 std::unique_ptr<AddressSorter> AddressSorter::CreateAddressSorter() {
394 return std::unique_ptr<AddressSorter>( 395 return std::unique_ptr<AddressSorter>(
395 new AddressSorterPosix(ClientSocketFactory::GetDefaultFactory())); 396 new AddressSorterPosix(ClientSocketFactory::GetDefaultFactory()));
396 } 397 }
397 398
398 } // namespace net 399 } // namespace net
399 400
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698