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

Side by Side Diff: chrome/browser/printing/cloud_print/privet_traffic_detector.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/printing/cloud_print/privet_traffic_detector.h" 5 #include "chrome/browser/printing/cloud_print/privet_traffic_detector.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/metrics/histogram_macros.h" 11 #include "base/metrics/histogram_macros.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "base/sys_byteorder.h" 13 #include "base/sys_byteorder.h"
14 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
15 #include "net/base/ip_address.h" 15 #include "net/base/ip_address.h"
16 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
17 #include "net/base/network_interfaces.h" 17 #include "net/base/network_interfaces.h"
18 #include "net/dns/dns_protocol.h" 18 #include "net/dns/dns_protocol.h"
19 #include "net/dns/dns_response.h" 19 #include "net/dns/dns_response.h"
20 #include "net/dns/mdns_client.h" 20 #include "net/dns/mdns_client.h"
21 #include "net/log/net_log.h" 21 #include "net/log/net_log_source.h"
22 #include "net/udp/datagram_server_socket.h" 22 #include "net/udp/datagram_server_socket.h"
23 #include "net/udp/udp_server_socket.h" 23 #include "net/udp/udp_server_socket.h"
24 24
25 namespace { 25 namespace {
26 26
27 const int kMaxRestartAttempts = 10; 27 const int kMaxRestartAttempts = 10;
28 const char kPrivetDeviceTypeDnsString[] = "\x07_privet"; 28 const char kPrivetDeviceTypeDnsString[] = "\x07_privet";
29 29
30 void GetNetworkListOnFileThread( 30 void GetNetworkListOnFileThread(
31 const base::Callback<void(const net::NetworkInterfaceList&)> callback) { 31 const base::Callback<void(const net::NetworkInterfaceList&)> callback) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 } 124 }
125 } 125 }
126 126
127 int PrivetTrafficDetector::Bind() { 127 int PrivetTrafficDetector::Bind() {
128 if (!start_time_.is_null()) { 128 if (!start_time_.is_null()) {
129 base::TimeDelta time_delta = base::Time::Now() - start_time_; 129 base::TimeDelta time_delta = base::Time::Now() - start_time_;
130 UMA_HISTOGRAM_LONG_TIMES("LocalDiscovery.DetectorRestartTime", time_delta); 130 UMA_HISTOGRAM_LONG_TIMES("LocalDiscovery.DetectorRestartTime", time_delta);
131 } 131 }
132 start_time_ = base::Time::Now(); 132 start_time_ = base::Time::Now();
133 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 133 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
134 socket_.reset(new net::UDPServerSocket(NULL, net::NetLog::Source())); 134 socket_.reset(new net::UDPServerSocket(NULL, net::NetLogSource()));
135 net::IPEndPoint multicast_addr = net::GetMDnsIPEndPoint(address_family_); 135 net::IPEndPoint multicast_addr = net::GetMDnsIPEndPoint(address_family_);
136 net::IPEndPoint bind_endpoint( 136 net::IPEndPoint bind_endpoint(
137 net::IPAddress::AllZeros(multicast_addr.address().size()), 137 net::IPAddress::AllZeros(multicast_addr.address().size()),
138 multicast_addr.port()); 138 multicast_addr.port());
139 socket_->AllowAddressReuse(); 139 socket_->AllowAddressReuse();
140 int rv = socket_->Listen(bind_endpoint); 140 int rv = socket_->Listen(bind_endpoint);
141 if (rv < net::OK) 141 if (rv < net::OK)
142 return rv; 142 return rv;
143 socket_->SetMulticastLoopbackMode(false); 143 socket_->SetMulticastLoopbackMode(false);
144 return socket_->JoinGroup(multicast_addr.address()); 144 return socket_->JoinGroup(multicast_addr.address());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 base::Unretained(this))); 195 base::Unretained(this)));
196 } while (rv > 0); 196 } while (rv > 0);
197 197
198 if (rv != net::ERR_IO_PENDING) 198 if (rv != net::ERR_IO_PENDING)
199 return rv; 199 return rv;
200 200
201 return net::OK; 201 return net::OK;
202 } 202 }
203 203
204 } // namespace cloud_print 204 } // namespace cloud_print
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698