OLD | NEW |
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 "chrome/browser/net/network_stats.h" | 5 #include "chrome/browser/net/network_stats.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 // This specifies the length of the packet_number in the payload. | 76 // This specifies the length of the packet_number in the payload. |
77 static const uint32 kPacketNumberLength = 10; | 77 static const uint32 kPacketNumberLength = 10; |
78 | 78 |
79 // This specifies the starting position of the <encoded_payload> in | 79 // This specifies the starting position of the <encoded_payload> in |
80 // "echo response". | 80 // "echo response". |
81 static const uint32 kEncodedPayloadStart = kKeyEnd; | 81 static const uint32 kEncodedPayloadStart = kKeyEnd; |
82 | 82 |
83 // HistogramPortSelector and kPorts should be kept in sync. Port 999999 is | 83 // HistogramPortSelector and kPorts should be kept in sync. Port 999999 is |
84 // used by the unit tests. | 84 // used by the unit tests. |
85 static const int32 kPorts[] = {6121, 999999}; | 85 static const int32 kPorts[] = {443, 999999}; |
86 | 86 |
87 // Number of packets that are recorded in a packet-correlation histogram, which | 87 // Number of packets that are recorded in a packet-correlation histogram, which |
88 // shows exactly what sequence of packets were responded to. We use this to | 88 // shows exactly what sequence of packets were responded to. We use this to |
89 // deduce specific packet loss correlation. | 89 // deduce specific packet loss correlation. |
90 static const uint32 kCorrelatedLossPacketCount = 6; | 90 static const uint32 kCorrelatedLossPacketCount = 6; |
91 | 91 |
92 // Maximum number of packets that can be sent to the server. | 92 // Maximum number of packets that can be sent to the server. |
93 static const uint32 kMaximumSequentialPackets = 21; | 93 static const uint32 kMaximumSequentialPackets = 21; |
94 | 94 |
95 // This specifies the maximum message (payload) size. | 95 // This specifies the maximum message (payload) size. |
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 | 917 |
918 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 918 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
919 | 919 |
920 // Check that there is a network connection. We get called only if UMA upload | 920 // Check that there is a network connection. We get called only if UMA upload |
921 // to the server has succeeded. | 921 // to the server has succeeded. |
922 DCHECK(!net::NetworkChangeNotifier::IsOffline()); | 922 DCHECK(!net::NetworkChangeNotifier::IsOffline()); |
923 | 923 |
924 CR_DEFINE_STATIC_LOCAL(scoped_refptr<base::FieldTrial>, trial, ()); | 924 CR_DEFINE_STATIC_LOCAL(scoped_refptr<base::FieldTrial>, trial, ()); |
925 static bool collect_stats = false; | 925 static bool collect_stats = false; |
926 static NetworkStats::HistogramPortSelector histogram_port = | 926 static NetworkStats::HistogramPortSelector histogram_port = |
927 NetworkStats::PORT_6121; | 927 NetworkStats::PORT_443; |
928 | 928 |
929 if (!trial.get()) { | 929 if (!trial.get()) { |
930 // Set up a field trial to collect network stats for UDP. | 930 // Set up a field trial to collect network stats for UDP. |
931 const base::FieldTrial::Probability kDivisor = 1000; | 931 const base::FieldTrial::Probability kDivisor = 1000; |
932 | 932 |
933 // Enable the connectivity testing for 0.5% of the users in stable channel. | 933 // Enable the connectivity testing for 0.5% of the users in stable channel. |
934 base::FieldTrial::Probability probability_per_group = 5; | 934 base::FieldTrial::Probability probability_per_group = 5; |
935 | 935 |
936 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | 936 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
937 if (channel == chrome::VersionInfo::CHANNEL_CANARY) | 937 if (channel == chrome::VersionInfo::CHANNEL_CANARY) |
938 probability_per_group = kDivisor; | 938 probability_per_group = kDivisor; |
939 else if (channel == chrome::VersionInfo::CHANNEL_DEV) | 939 else if (channel == chrome::VersionInfo::CHANNEL_DEV) |
940 // Enable the connectivity testing for 10% of the users in dev channel. | 940 // Enable the connectivity testing for 50% of the users in dev channel. |
941 probability_per_group = 500; | 941 probability_per_group = 500; |
942 else if (channel == chrome::VersionInfo::CHANNEL_BETA) | 942 else if (channel == chrome::VersionInfo::CHANNEL_BETA) |
943 // Enable the connectivity testing for 5% of the users in beta channel. | 943 // Enable the connectivity testing for 5% of the users in beta channel. |
944 probability_per_group = 50; | 944 probability_per_group = 50; |
945 | 945 |
946 // After October 30, 2012 builds, it will always be in default group | 946 // After October 30, 2013 builds, it will always be in default group |
947 // (disable_network_stats). | 947 // (disable_network_stats). |
948 trial = base::FieldTrialList::FactoryGetFieldTrial( | 948 trial = base::FieldTrialList::FactoryGetFieldTrial( |
949 "NetworkConnectivity", kDivisor, "disable_network_stats", | 949 "NetworkConnectivity", kDivisor, "disable_network_stats", |
950 2012, 10, 30, NULL); | 950 2013, 10, 30, NULL); |
951 | 951 |
952 // Add option to collect_stats for NetworkConnectivity. | 952 // Add option to collect_stats for NetworkConnectivity. |
953 int collect_stats_group = trial->AppendGroup("collect_stats", | 953 int collect_stats_group = trial->AppendGroup("collect_stats", |
954 probability_per_group); | 954 probability_per_group); |
955 if (trial->group() == collect_stats_group) | 955 if (trial->group() == collect_stats_group) |
956 collect_stats = true; | 956 collect_stats = true; |
957 } | 957 } |
958 | 958 |
959 if (!collect_stats) | 959 if (!collect_stats) |
960 return; | 960 return; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 udp_stats_client->Start( | 1017 udp_stats_client->Start( |
1018 host_resolver, server_address, histogram_port, has_proxy_server, | 1018 host_resolver, server_address, histogram_port, has_proxy_server, |
1019 kLargeTestBytesToSend, kMaximumSequentialPackets, | 1019 kLargeTestBytesToSend, kMaximumSequentialPackets, |
1020 net::CompletionCallback()); | 1020 net::CompletionCallback()); |
1021 } | 1021 } |
1022 break; | 1022 break; |
1023 } | 1023 } |
1024 } | 1024 } |
1025 | 1025 |
1026 } // namespace chrome_browser_net | 1026 } // namespace chrome_browser_net |
OLD | NEW |