| OLD | NEW |
| 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/local_discovery/privet_traffic_detector.h" | 5 #include "chrome/browser/local_discovery/privet_traffic_detector.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/sys_byteorder.h" | 8 #include "base/sys_byteorder.h" |
| 9 #include "net/base/dns_util.h" | 9 #include "net/base/dns_util.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 | 39 |
| 40 net::IPAddressNumber localhost_prefix(4, 0); | 40 net::IPAddressNumber localhost_prefix(4, 0); |
| 41 localhost_prefix[0] = 127; | 41 localhost_prefix[0] = 127; |
| 42 ip4_networks.push_back(net::NetworkInterface("lo", localhost_prefix, 8)); | 42 ip4_networks.push_back(net::NetworkInterface("lo", localhost_prefix, 8)); |
| 43 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, | 43 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, |
| 44 base::Bind(callback, ip4_networks)); | 44 base::Bind(callback, ip4_networks)); |
| 45 } | 45 } |
| 46 | 46 |
| 47 bool IsIpPrefixEqual(const net::IPAddressNumber& ip1, | |
| 48 const net::IPAddressNumber& ip2) { | |
| 49 return !ip1.empty() && ip1.size() == ip2.size() && | |
| 50 std::equal(ip1.begin(), ip1.end() - 1, ip2.begin()); | |
| 51 } | |
| 52 | |
| 53 } // namespace | 47 } // namespace |
| 54 | 48 |
| 55 namespace local_discovery { | 49 namespace local_discovery { |
| 56 | 50 |
| 57 PrivetTrafficDetector::PrivetTrafficDetector( | 51 PrivetTrafficDetector::PrivetTrafficDetector( |
| 58 net::AddressFamily address_family, | 52 net::AddressFamily address_family, |
| 59 const base::Closure& on_traffic_detected) | 53 const base::Closure& on_traffic_detected) |
| 60 : on_traffic_detected_(on_traffic_detected), | 54 : on_traffic_detected_(on_traffic_detected), |
| 61 callback_runner_(base::MessageLoop::current()->message_loop_proxy()), | 55 callback_runner_(base::MessageLoop::current()->message_loop_proxy()), |
| 62 address_family_(address_family), | 56 address_family_(address_family), |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 base::Unretained(this))); | 182 base::Unretained(this))); |
| 189 } while (rv > 0); | 183 } while (rv > 0); |
| 190 | 184 |
| 191 if (rv != net::ERR_IO_PENDING) | 185 if (rv != net::ERR_IO_PENDING) |
| 192 return rv; | 186 return rv; |
| 193 | 187 |
| 194 return net::OK; | 188 return net::OK; |
| 195 } | 189 } |
| 196 | 190 |
| 197 } // namespace local_discovery | 191 } // namespace local_discovery |
| OLD | NEW |