Remove PlatformFile from profile_browsertest
[chromium-blink-merge.git] / net / quic / quic_address_mismatch.cc
blob36b53a1022c1a583282d62e7dc11eb45d358f668
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "net/quic/quic_address_mismatch.h"
7 #include "net/base/ip_endpoint.h"
9 namespace net {
11 int GetAddressMismatch(const IPEndPoint& first_address,
12 const IPEndPoint& second_address) {
13 if (first_address.address().empty() || second_address.address().empty()) {
14 return -1;
17 int sample;
18 if (first_address.address() != second_address.address()) {
19 sample = QUIC_ADDRESS_MISMATCH_BASE;
20 } else if (first_address.port() != second_address.port()) {
21 sample = QUIC_PORT_MISMATCH_BASE;
22 } else {
23 sample = QUIC_ADDRESS_AND_PORT_MATCH_BASE;
26 // Add an offset to |sample|:
27 // V4_V4: add 0
28 // V6_V6: add 1
29 // V4_V6: add 2
30 // V6_V4: add 3
31 bool first_ipv4 = (first_address.address().size() == kIPv4AddressSize);
32 bool second_ipv4 = (second_address.address().size() == kIPv4AddressSize);
33 if (first_ipv4 != second_ipv4) {
34 CHECK_EQ(sample, QUIC_ADDRESS_MISMATCH_BASE);
35 sample += 2;
37 if (!first_ipv4) {
38 sample += 1;
40 return sample;
43 } // namespace net