Chromium Code Reviews| 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" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
| 13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
| 14 #include "base/threading/platform_thread.h" | 14 #include "base/threading/platform_thread.h" |
| 15 #include "base/time.h" | 15 #include "base/time.h" |
| 16 #include "base/tuple.h" | 16 #include "base/tuple.h" |
| 17 #include "chrome/common/chrome_version_info.h" | 17 #include "chrome/common/chrome_version_info.h" |
| 18 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 19 #include "googleurl/src/gurl.h" | |
| 19 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
| 20 #include "net/base/net_util.h" | 21 #include "net/base/net_util.h" |
| 21 #include "net/base/network_change_notifier.h" | 22 #include "net/base/network_change_notifier.h" |
| 22 #include "net/base/sys_addrinfo.h" | 23 #include "net/base/sys_addrinfo.h" |
| 23 #include "net/base/test_completion_callback.h" | 24 #include "net/base/test_completion_callback.h" |
| 25 #include "net/proxy/proxy_service.h" | |
| 24 #include "net/socket/tcp_client_socket.h" | 26 #include "net/socket/tcp_client_socket.h" |
| 25 #include "net/udp/udp_client_socket.h" | 27 #include "net/udp/udp_client_socket.h" |
| 26 #include "net/udp/udp_server_socket.h" | 28 #include "net/udp/udp_server_socket.h" |
| 27 | 29 |
| 28 using content::BrowserThread; | 30 using content::BrowserThread; |
| 29 | 31 |
| 30 namespace chrome_browser_net { | 32 namespace chrome_browser_net { |
| 31 | 33 |
| 32 // This specifies the number of bytes to be sent to the TCP/UDP servers as part | 34 // This specifies the number of bytes to be sent to the TCP/UDP servers as part |
| 33 // of small packet size test. | 35 // of small packet size test. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 | 89 |
| 88 // Maximum number of packets that can be sent to the server for packet loss | 90 // Maximum number of packets that can be sent to the server for packet loss |
| 89 // testing. | 91 // testing. |
| 90 static const uint32 kMaximumPackets = 4; | 92 static const uint32 kMaximumPackets = 4; |
| 91 | 93 |
| 92 // NetworkStats methods and members. | 94 // NetworkStats methods and members. |
| 93 NetworkStats::NetworkStats() | 95 NetworkStats::NetworkStats() |
| 94 : load_size_(0), | 96 : load_size_(0), |
| 95 bytes_to_read_(0), | 97 bytes_to_read_(0), |
| 96 bytes_to_send_(0), | 98 bytes_to_send_(0), |
| 99 has_proxy_server_(false), | |
| 97 packets_to_send_(0), | 100 packets_to_send_(0), |
| 98 packets_sent_(0), | 101 packets_sent_(0), |
| 99 base_packet_number_(0), | 102 base_packet_number_(0), |
| 100 packets_received_mask_(0), | 103 packets_received_mask_(0), |
| 101 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 104 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
| 102 } | 105 } |
| 103 | 106 |
| 104 NetworkStats::~NetworkStats() { | 107 NetworkStats::~NetworkStats() { |
| 105 socket_.reset(); | 108 socket_.reset(); |
| 106 } | 109 } |
| 107 | 110 |
| 108 bool NetworkStats::Start(net::HostResolver* host_resolver, | 111 bool NetworkStats::Start(net::HostResolver* host_resolver, |
| 109 const net::HostPortPair& server_host_port_pair, | 112 const net::HostPortPair& server_host_port_pair, |
| 110 HistogramPortSelector histogram_port, | 113 HistogramPortSelector histogram_port, |
| 114 bool has_proxy_server, | |
| 111 uint32 bytes_to_send, | 115 uint32 bytes_to_send, |
| 112 uint32 packets_to_send, | 116 uint32 packets_to_send, |
| 113 const net::CompletionCallback& finished_callback) { | 117 const net::CompletionCallback& finished_callback) { |
| 114 DCHECK(bytes_to_send); // We should have data to send. | 118 DCHECK(bytes_to_send); // We should have data to send. |
| 115 DCHECK_LE(packets_to_send, kMaximumPackets); | 119 DCHECK_LE(packets_to_send, kMaximumPackets); |
| 116 | 120 |
| 117 Initialize(bytes_to_send, histogram_port, packets_to_send, finished_callback); | 121 Initialize(bytes_to_send, |
| 122 histogram_port, | |
| 123 has_proxy_server, | |
| 124 packets_to_send, | |
| 125 finished_callback); | |
| 118 | 126 |
| 119 net::HostResolver::RequestInfo request(server_host_port_pair); | 127 net::HostResolver::RequestInfo request(server_host_port_pair); |
| 120 int rv = host_resolver->Resolve( | 128 int rv = host_resolver->Resolve( |
| 121 request, &addresses_, | 129 request, &addresses_, |
| 122 base::Bind(&NetworkStats::OnResolveComplete, | 130 base::Bind(&NetworkStats::OnResolveComplete, |
| 123 base::Unretained(this)), | 131 base::Unretained(this)), |
| 124 NULL, net::BoundNetLog()); | 132 NULL, net::BoundNetLog()); |
| 125 if (rv == net::ERR_IO_PENDING) | 133 if (rv == net::ERR_IO_PENDING) |
| 126 return true; | 134 return true; |
| 127 return DoConnect(rv); | 135 return DoConnect(rv); |
| 128 } | 136 } |
| 129 | 137 |
| 130 void NetworkStats::Initialize( | 138 void NetworkStats::Initialize( |
| 131 uint32 bytes_to_send, | 139 uint32 bytes_to_send, |
| 132 HistogramPortSelector histogram_port, | 140 HistogramPortSelector histogram_port, |
| 141 bool has_proxy_server, | |
| 133 uint32 packets_to_send, | 142 uint32 packets_to_send, |
| 134 const net::CompletionCallback& finished_callback) { | 143 const net::CompletionCallback& finished_callback) { |
| 135 DCHECK(bytes_to_send); // We should have data to send. | 144 DCHECK(bytes_to_send); // We should have data to send. |
| 136 DCHECK(packets_to_send); // We should send at least 1 packet. | 145 DCHECK(packets_to_send); // We should send at least 1 packet. |
| 137 DCHECK_LE(bytes_to_send, kLargeTestBytesToSend); | 146 DCHECK_LE(bytes_to_send, kLargeTestBytesToSend); |
| 138 | 147 |
| 139 load_size_ = bytes_to_send; | 148 load_size_ = bytes_to_send; |
| 140 packets_to_send_ = packets_to_send; | 149 packets_to_send_ = packets_to_send; |
| 141 | 150 |
| 142 histogram_port_ = histogram_port; | 151 histogram_port_ = histogram_port; |
| 152 has_proxy_server_ = has_proxy_server; | |
| 143 finished_callback_ = finished_callback; | 153 finished_callback_ = finished_callback; |
| 144 } | 154 } |
| 145 | 155 |
| 146 uint32 SendingPacketSize(uint32 load_size) { | 156 uint32 SendingPacketSize(uint32 load_size) { |
| 147 return kVersionLength + kChecksumLength + kPayloadSizeLength + load_size; | 157 return kVersionLength + kChecksumLength + kPayloadSizeLength + load_size; |
| 148 } | 158 } |
| 149 | 159 |
| 150 uint32 ReceivingPacketSize(uint32 load_size) { | 160 uint32 ReceivingPacketSize(uint32 load_size) { |
| 151 return kVersionLength + kChecksumLength + kPayloadSizeLength + kKeyLength + | 161 return kVersionLength + kChecksumLength + kPayloadSizeLength + kKeyLength + |
| 152 load_size; | 162 load_size; |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 531 if (result == net::OK) { | 541 if (result == net::OK) { |
| 532 *rtt_histogram_name = base::StringPrintf( | 542 *rtt_histogram_name = base::StringPrintf( |
| 533 "NetConnectivity.%s.Success.%d.%s.RTT", | 543 "NetConnectivity.%s.Success.%d.%s.RTT", |
| 534 protocol_string, | 544 protocol_string, |
| 535 kPorts[port], | 545 kPorts[port], |
| 536 load_size_string); | 546 load_size_string); |
| 537 } | 547 } |
| 538 | 548 |
| 539 // Build "NetConnectivity.<protocol>.Status.<port>.<load_size>" histogram | 549 // Build "NetConnectivity.<protocol>.Status.<port>.<load_size>" histogram |
| 540 // name. Total number of histograms are 2*5*2. | 550 // name. Total number of histograms are 2*5*2. |
| 541 *status_histogram_name = base::StringPrintf( | 551 *status_histogram_name = base::StringPrintf( |
| 542 "NetConnectivity.%s.Status.%d.%s", | 552 "NetConnectivity.%s.Status.%d.%s", |
| 543 protocol_string, | 553 protocol_string, |
| 544 kPorts[port], | 554 kPorts[port], |
| 545 load_size_string); | 555 load_size_string); |
| 546 | 556 |
| 547 // Build "NetConnectivity.<protocol>.PacketLoss.<port>.<load_size>" histogram | 557 // Build "NetConnectivity.<protocol>.PacketLoss.<port>.<load_size>" histogram |
| 548 // name. Total number of histograms are 5 (because we do this test for UDP | 558 // name. Total number of histograms are 5 (because we do this test for UDP |
| 549 // only). | 559 // only). |
| 550 *packet_loss_histogram_name = base::StringPrintf( | 560 *packet_loss_histogram_name = base::StringPrintf( |
| 551 "NetConnectivity.%s.PacketLoss.%d.%s", | 561 "NetConnectivity.%s.PacketLoss.%d.%s", |
| 552 protocol_string, | 562 protocol_string, |
| 553 kPorts[port], | 563 kPorts[port], |
| 554 load_size_string); | 564 load_size_string); |
| 555 } | 565 } |
| 556 | 566 |
| 557 void NetworkStats::RecordHistograms(const ProtocolValue& protocol, | 567 void NetworkStats::RecordHistograms(const ProtocolValue& protocol, |
| 558 const Status& status, | 568 const Status& status, |
| 559 int result) { | 569 int result) { |
| 560 base::TimeDelta duration = base::TimeTicks::Now() - start_time(); | 570 base::TimeDelta duration = base::TimeTicks::Now() - start_time(); |
| 561 | 571 |
| 562 std::string rtt_histogram_name; | 572 std::string rtt_histogram_name; |
| 563 std::string status_histogram_name; | 573 std::string status_histogram_name; |
| 564 std::string packet_loss_histogram_name; | 574 std::string packet_loss_histogram_name; |
| 565 GetHistogramNames(protocol, | 575 GetHistogramNames(protocol, |
| 566 histogram_port_, | 576 histogram_port_, |
| 567 load_size_, | 577 load_size_, |
| 568 result, | 578 result, |
| 569 &rtt_histogram_name, | 579 &rtt_histogram_name, |
| 570 &status_histogram_name, | 580 &status_histogram_name, |
| 571 &packet_loss_histogram_name); | 581 &packet_loss_histogram_name); |
| 572 | 582 |
| 573 // For packet loss test, just record packet loss data. | 583 size_t histogram_count = has_proxy_server_ ? 1 : 2; |
| 574 if (packets_to_send_ > 1) { | 584 for (size_t i = 0; i < histogram_count; i++) { |
| 575 base::Histogram* packet_loss_histogram = base::LinearHistogram::FactoryGet( | 585 // For packet loss test, just record packet loss data. |
| 576 packet_loss_histogram_name, | 586 if (packets_to_send_ > 1) { |
| 577 1, | 587 base::Histogram* histogram = base::LinearHistogram::FactoryGet( |
| 578 2 << kMaximumPackets, | 588 packet_loss_histogram_name, |
| 579 (2 << kMaximumPackets) + 1, | 589 1, |
| 590 2 << kMaximumPackets, | |
| 591 (2 << kMaximumPackets) + 1, | |
| 592 base::Histogram::kUmaTargetedHistogramFlag); | |
| 593 histogram->Add(packets_received_mask_); | |
| 594 packet_loss_histogram_name.append(".NoProxy"); | |
| 595 continue; | |
| 596 } | |
| 597 | |
| 598 if (result == net::OK) { | |
| 599 base::Histogram* rtt_histogram = base::Histogram::FactoryTimeGet( | |
| 600 rtt_histogram_name, | |
| 601 base::TimeDelta::FromMilliseconds(10), | |
| 602 base::TimeDelta::FromSeconds(60), 50, | |
| 603 base::Histogram::kUmaTargetedHistogramFlag); | |
| 604 rtt_histogram->AddTime(duration); | |
| 605 rtt_histogram_name.append(".NoProxy"); | |
| 606 } | |
| 607 | |
| 608 base::Histogram* status_histogram = base::LinearHistogram::FactoryGet( | |
| 609 status_histogram_name, 1, STATUS_MAX, STATUS_MAX+1, | |
| 580 base::Histogram::kUmaTargetedHistogramFlag); | 610 base::Histogram::kUmaTargetedHistogramFlag); |
| 581 packet_loss_histogram->Add(packets_received_mask_); | 611 status_histogram->Add(status); |
| 582 return; | 612 status_histogram_name.append(".NoProxy"); |
| 583 } | 613 } |
| 584 | |
| 585 if (result == net::OK) { | |
| 586 base::Histogram* rtt_histogram = base::Histogram::FactoryTimeGet( | |
| 587 rtt_histogram_name, | |
| 588 base::TimeDelta::FromMilliseconds(10), | |
| 589 base::TimeDelta::FromSeconds(60), 50, | |
| 590 base::Histogram::kUmaTargetedHistogramFlag); | |
| 591 rtt_histogram->AddTime(duration); | |
| 592 } | |
| 593 | |
| 594 base::Histogram* status_histogram = base::LinearHistogram::FactoryGet( | |
| 595 status_histogram_name, 1, STATUS_MAX, STATUS_MAX+1, | |
| 596 base::Histogram::kUmaTargetedHistogramFlag); | |
| 597 status_histogram->Add(status); | |
| 598 } | 614 } |
| 599 | 615 |
| 600 // UDPStatsClient methods and members. | 616 // UDPStatsClient methods and members. |
| 601 UDPStatsClient::UDPStatsClient() | 617 UDPStatsClient::UDPStatsClient() |
| 602 : NetworkStats() { | 618 : NetworkStats() { |
| 603 } | 619 } |
| 604 | 620 |
| 605 UDPStatsClient::~UDPStatsClient() { | 621 UDPStatsClient::~UDPStatsClient() { |
| 606 } | 622 } |
| 607 | 623 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 710 | 726 |
| 711 // Disconnect the socket so that there are no more IO operations. | 727 // Disconnect the socket so that there are no more IO operations. |
| 712 net::TCPClientSocket* tcp_socket = | 728 net::TCPClientSocket* tcp_socket = |
| 713 static_cast<net::TCPClientSocket*>(socket()); | 729 static_cast<net::TCPClientSocket*>(socket()); |
| 714 if (tcp_socket) | 730 if (tcp_socket) |
| 715 tcp_socket->Disconnect(); | 731 tcp_socket->Disconnect(); |
| 716 | 732 |
| 717 delete this; | 733 delete this; |
| 718 } | 734 } |
| 719 | 735 |
| 736 // ProxyDetector methods and members. | |
| 737 ProxyDetector::ProxyDetector(const std::string& network_stats_server, | |
| 738 NetworkStats::HistogramPortSelector histogram_port, | |
| 739 IOThread* io_thread) | |
| 740 : network_stats_server_(network_stats_server), | |
| 741 histogram_port_(histogram_port), | |
| 742 io_thread_(io_thread) { | |
| 743 } | |
| 744 | |
| 745 ProxyDetector::~ProxyDetector() { | |
|
eroman
2012/05/04 23:08:48
When is ProxyDetector deleted? Note that if it is
ramant (doing other things)
2012/05/07 23:35:47
Implemented option a). Thanks for the above commen
| |
| 746 } | |
| 747 | |
| 748 void ProxyDetector::ResolveProxy() { | |
| 749 std::string url = base::StringPrintf( | |
| 750 "https://%s:%d", network_stats_server_.c_str(), kPorts[histogram_port_]); | |
|
eroman
2012/05/04 23:08:48
Assembling URLs in this fashion is generally not s
ramant (doing other things)
2012/05/07 23:35:47
Implemented option a). Thanks much for the suggest
| |
| 751 GURL gurl(url); | |
| 752 net::ProxyService* service = | |
| 753 io_thread_->globals()->system_proxy_service.get(); | |
| 754 | |
| 755 int rv = service->ResolveProxy( | |
| 756 gurl, | |
| 757 &proxy_info_, | |
| 758 base::Bind(&ProxyDetector::OnResolveProxyComplete, | |
| 759 base::Unretained(this)), | |
| 760 NULL, | |
| 761 net::BoundNetLog()); | |
| 762 if (rv == net::OK) | |
| 763 OnResolveProxyComplete(rv); | |
| 764 } | |
| 765 | |
| 766 void ProxyDetector::OnResolveProxyComplete(int result) { | |
| 767 bool has_proxy_server = (proxy_info_.proxy_server().is_valid() && | |
|
eroman
2012/05/04 23:08:48
One extra check to add is into that list is:
re
ramant (doing other things)
2012/05/07 23:35:47
Done.
| |
| 768 !proxy_info_.proxy_server().is_direct()); | |
| 769 StartNetworkStatsTest( | |
|
eroman
2012/05/04 23:08:48
[optional] I suggest de-coupling this from ProxyDe
ramant (doing other things)
2012/05/07 23:35:47
Done.
| |
| 770 network_stats_server_, histogram_port_, has_proxy_server, io_thread_); | |
| 771 } | |
| 772 | |
| 720 // static | 773 // static |
| 721 void CollectNetworkStats(const std::string& network_stats_server, | 774 void CollectNetworkStats(const std::string& network_stats_server, |
| 722 IOThread* io_thread) { | 775 IOThread* io_thread) { |
| 723 if (network_stats_server.empty()) | 776 if (network_stats_server.empty()) |
| 724 return; | 777 return; |
| 725 | 778 |
| 726 // If we are not on IO Thread, then post a task to call CollectNetworkStats on | 779 // If we are not on IO Thread, then post a task to call CollectNetworkStats on |
| 727 // IO Thread. | 780 // IO Thread. |
| 728 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 781 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 729 BrowserThread::PostTask( | 782 BrowserThread::PostTask( |
| 730 BrowserThread::IO, | 783 BrowserThread::IO, |
| 731 FROM_HERE, | 784 FROM_HERE, |
| 732 base::Bind( | 785 base::Bind( |
| 733 &CollectNetworkStats, network_stats_server, io_thread)); | 786 &CollectNetworkStats, network_stats_server, io_thread)); |
| 734 return; | 787 return; |
| 735 } | 788 } |
| 736 | 789 |
| 737 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 790 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 738 | 791 |
| 739 // Check that there is a network connection. We get called only if UMA upload | 792 // Check that there is a network connection. We get called only if UMA upload |
| 740 // to the server has succeeded. | 793 // to the server has succeeded. |
| 741 DCHECK(!net::NetworkChangeNotifier::IsOffline()); | 794 DCHECK(!net::NetworkChangeNotifier::IsOffline()); |
| 742 | 795 |
| 743 CR_DEFINE_STATIC_LOCAL(scoped_refptr<base::FieldTrial>, trial, ()); | 796 CR_DEFINE_STATIC_LOCAL(scoped_refptr<base::FieldTrial>, trial, ()); |
| 744 static bool collect_stats = false; | 797 static bool collect_stats = false; |
| 745 | |
| 746 static uint32 port; | |
| 747 static NetworkStats::HistogramPortSelector histogram_port; | 798 static NetworkStats::HistogramPortSelector histogram_port; |
| 748 | 799 |
| 749 if (!trial.get()) { | 800 if (!trial.get()) { |
| 750 // Set up a field trial to collect network stats for UDP and TCP. | 801 // Set up a field trial to collect network stats for UDP and TCP. |
| 751 const base::FieldTrial::Probability kDivisor = 1000; | 802 const base::FieldTrial::Probability kDivisor = 1000; |
| 752 | 803 |
| 753 // Enable the connectivity testing for 0.5% of the users in stable channel. | 804 // Enable the connectivity testing for 0.5% of the users in stable channel. |
| 754 base::FieldTrial::Probability probability_per_group = 5; | 805 base::FieldTrial::Probability probability_per_group = 5; |
| 755 | 806 |
| 756 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | 807 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 775 if (trial->group() == collect_stats_group) | 826 if (trial->group() == collect_stats_group) |
| 776 collect_stats = true; | 827 collect_stats = true; |
| 777 | 828 |
| 778 if (collect_stats) { | 829 if (collect_stats) { |
| 779 // Pick a port randomly from the set of TCP/UDP echo server ports | 830 // Pick a port randomly from the set of TCP/UDP echo server ports |
| 780 // specified in |kPorts|. | 831 // specified in |kPorts|. |
| 781 histogram_port = static_cast<NetworkStats::HistogramPortSelector>( | 832 histogram_port = static_cast<NetworkStats::HistogramPortSelector>( |
| 782 base::RandInt(NetworkStats::PORT_53, NetworkStats::PORT_8080)); | 833 base::RandInt(NetworkStats::PORT_53, NetworkStats::PORT_8080)); |
| 783 DCHECK_GE(histogram_port, NetworkStats::PORT_53); | 834 DCHECK_GE(histogram_port, NetworkStats::PORT_53); |
| 784 DCHECK_LE(histogram_port, NetworkStats::PORT_8080); | 835 DCHECK_LE(histogram_port, NetworkStats::PORT_8080); |
| 785 port = kPorts[histogram_port]; | |
| 786 } | 836 } |
| 787 } | 837 } |
| 788 | 838 |
| 789 if (!collect_stats) | 839 if (!collect_stats) |
| 790 return; | 840 return; |
| 791 | 841 |
| 792 // Run test kMaxNumberOfTests times. | 842 // Run test kMaxNumberOfTests times. |
| 793 const size_t kMaxNumberOfTests = INT_MAX; | 843 const size_t kMaxNumberOfTests = INT_MAX; |
| 794 static size_t number_of_tests_done = 0; | 844 static size_t number_of_tests_done = 0; |
| 795 if (number_of_tests_done > kMaxNumberOfTests) | 845 if (number_of_tests_done > kMaxNumberOfTests) |
| 796 return; | 846 return; |
| 797 | 847 |
| 798 ++number_of_tests_done; | 848 ++number_of_tests_done; |
| 799 | 849 |
| 850 ProxyDetector* proxy_client = new ProxyDetector( | |
| 851 network_stats_server, histogram_port, io_thread); | |
| 852 proxy_client->ResolveProxy(); | |
| 853 } | |
| 854 | |
| 855 // static | |
| 856 void StartNetworkStatsTest(const std::string& network_stats_server, | |
| 857 NetworkStats::HistogramPortSelector histogram_port, | |
| 858 bool has_proxy_server, | |
| 859 IOThread* io_thread) { | |
| 800 net::HostResolver* host_resolver = io_thread->globals()->host_resolver.get(); | 860 net::HostResolver* host_resolver = io_thread->globals()->host_resolver.get(); |
| 801 DCHECK(host_resolver); | 861 DCHECK(host_resolver); |
| 802 | 862 |
| 803 net::HostPortPair server_address(network_stats_server, port); | 863 DCHECK_GE(histogram_port, NetworkStats::PORT_53); |
| 864 DCHECK_LE(histogram_port, NetworkStats::PORT_8080); | |
| 865 net::HostPortPair server_address(network_stats_server, | |
| 866 kPorts[histogram_port]); | |
| 804 | 867 |
| 805 int experiment_to_run = base::RandInt(1, 5); | 868 int experiment_to_run = base::RandInt(1, 5); |
| 806 switch (experiment_to_run) { | 869 switch (experiment_to_run) { |
| 807 case 1: | 870 case 1: |
| 808 { | 871 { |
| 809 UDPStatsClient* small_udp_stats = new UDPStatsClient(); | 872 UDPStatsClient* small_udp_stats = new UDPStatsClient(); |
| 810 small_udp_stats->Start( | 873 small_udp_stats->Start( |
| 811 host_resolver, server_address, histogram_port, | 874 host_resolver, server_address, histogram_port, has_proxy_server, |
| 812 kSmallTestBytesToSend, 1, net::CompletionCallback()); | 875 kSmallTestBytesToSend, 1, net::CompletionCallback()); |
| 813 } | 876 } |
| 814 break; | 877 break; |
| 815 | 878 |
| 816 case 2: | 879 case 2: |
| 817 { | 880 { |
| 818 UDPStatsClient* large_udp_stats = new UDPStatsClient(); | 881 UDPStatsClient* large_udp_stats = new UDPStatsClient(); |
| 819 large_udp_stats->Start( | 882 large_udp_stats->Start( |
| 820 host_resolver, server_address, histogram_port, | 883 host_resolver, server_address, histogram_port, has_proxy_server, |
| 821 kLargeTestBytesToSend, 1, net::CompletionCallback()); | 884 kLargeTestBytesToSend, 1, net::CompletionCallback()); |
| 822 } | 885 } |
| 823 break; | 886 break; |
| 824 | 887 |
| 825 case 3: | 888 case 3: |
| 826 { | 889 { |
| 827 TCPStatsClient* small_tcp_client = new TCPStatsClient(); | 890 TCPStatsClient* small_tcp_client = new TCPStatsClient(); |
| 828 small_tcp_client->Start( | 891 small_tcp_client->Start( |
| 829 host_resolver, server_address, histogram_port, | 892 host_resolver, server_address, histogram_port, has_proxy_server, |
| 830 kSmallTestBytesToSend, 1, net::CompletionCallback()); | 893 kSmallTestBytesToSend, 1, net::CompletionCallback()); |
| 831 } | 894 } |
| 832 break; | 895 break; |
| 833 | 896 |
| 834 case 4: | 897 case 4: |
| 835 { | 898 { |
| 836 TCPStatsClient* large_tcp_client = new TCPStatsClient(); | 899 TCPStatsClient* large_tcp_client = new TCPStatsClient(); |
| 837 large_tcp_client->Start( | 900 large_tcp_client->Start( |
| 838 host_resolver, server_address, histogram_port, | 901 host_resolver, server_address, histogram_port, has_proxy_server, |
| 839 kLargeTestBytesToSend, 1, net::CompletionCallback()); | 902 kLargeTestBytesToSend, 1, net::CompletionCallback()); |
| 840 } | 903 } |
| 841 break; | 904 break; |
| 842 | 905 |
| 843 case 5: | 906 case 5: |
| 844 { | 907 { |
| 845 UDPStatsClient* packet_loss_udp_stats = new UDPStatsClient(); | 908 UDPStatsClient* packet_loss_udp_stats = new UDPStatsClient(); |
| 846 packet_loss_udp_stats->Start( | 909 packet_loss_udp_stats->Start( |
| 847 host_resolver, server_address, histogram_port, | 910 host_resolver, server_address, histogram_port, has_proxy_server, |
| 848 kLargeTestBytesToSend, kMaximumPackets, net::CompletionCallback()); | 911 kLargeTestBytesToSend, kMaximumPackets, net::CompletionCallback()); |
| 849 } | 912 } |
| 850 break; | 913 break; |
| 851 } | 914 } |
| 852 } | 915 } |
| 853 | 916 |
| 854 } // namespace chrome_browser_net | 917 } // namespace chrome_browser_net |
| OLD | NEW |