Chromium Code Reviews| Index: chrome/browser/net/network_stats.h |
| =================================================================== |
| --- chrome/browser/net/network_stats.h (revision 135678) |
| +++ chrome/browser/net/network_stats.h (working copy) |
| @@ -21,6 +21,7 @@ |
| #include "net/base/io_buffer.h" |
| #include "net/base/ip_endpoint.h" |
| #include "net/base/test_data_stream.h" |
| +#include "net/proxy/proxy_info.h" |
| #include "net/socket/socket.h" |
| namespace chrome_browser_net { |
| @@ -101,6 +102,7 @@ |
| bool Start(net::HostResolver* host_resolver, |
| const net::HostPortPair& server, |
| HistogramPortSelector histogram_port, |
| + bool has_proxy_server, |
| uint32 bytes_to_send, |
| uint32 packets_to_send, |
| const net::CompletionCallback& callback); |
| @@ -109,6 +111,7 @@ |
| // Constructs an NetworkStats object that collects metrics for network |
| // connectivity (either TCP or UDP). |
| NetworkStats(); |
| + // NetworkStats is deleted when Finish() is called. |
| virtual ~NetworkStats(); |
| // Initializes |finished_callback_| and the number of bytes to send to the |
| @@ -116,6 +119,7 @@ |
| // |finished_callback| is mainly useful for unittests. |
| void Initialize(uint32 bytes_to_send, |
| HistogramPortSelector histogram_port, |
| + bool has_proxy_server, |
| uint32 packets_to_send, |
| const net::CompletionCallback& finished_callback); |
| @@ -271,6 +275,9 @@ |
| // connectivity. |
| HistogramPortSelector histogram_port_; |
| + // |has_proxy_server_| specifies if there is a proxy server or not. |
| + bool has_proxy_server_; |
| + |
| // HostResolver fills out the |addresses_| after host resolution is completed. |
| net::AddressList addresses_; |
| @@ -298,6 +305,7 @@ |
| // Constructs an UDPStatsClient object that collects metrics for UDP |
| // connectivity. |
| UDPStatsClient(); |
| + // UDPStatsClient is deleted when Finish() is called. |
| virtual ~UDPStatsClient(); |
| protected: |
| @@ -315,7 +323,8 @@ |
| virtual bool ReadComplete(int result) OVERRIDE; |
| // Collects stats for UDP connectivity. This is called when all the data from |
| - // server is read or when there is a failure during connect/read/write. |
| + // server is read or when there is a failure during connect/read/write. This |
| + // object is deleted at the end of this method. |
| virtual void Finish(Status status, int result) OVERRIDE; |
| }; |
| @@ -324,6 +333,7 @@ |
| // Constructs a TCPStatsClient object that collects metrics for TCP |
| // connectivity. |
| TCPStatsClient(); |
| + // TCPStatsClient is deleted when Finish() is called. |
| virtual ~TCPStatsClient(); |
| protected: |
| @@ -339,7 +349,8 @@ |
| virtual bool ReadComplete(int result) OVERRIDE; |
| // Collects stats for TCP connectivity. This is called when all the data from |
| - // server is read or when there is a failure during connect/read/write. |
| + // server is read or when there is a failure during connect/read/write. This |
| + // object is deleted at the end of this method. |
| virtual void Finish(Status status, int result) OVERRIDE; |
| private: |
| @@ -348,6 +359,49 @@ |
| void OnConnectComplete(int result); |
| }; |
| +class ProxyDetector { |
| + public: |
| + // Used for the callback that is called from |OnResolveProxyComplete|. |
| + typedef base::Callback<void(bool)> ProxyDetectorCallback; |
|
eroman
2012/05/08 01:02:27
[optional] nit: since this is already enclosed in
ramant (doing other things)
2012/05/08 05:28:19
Done.
|
| + |
| + // Constructs a ProxyDetector object that finds out if access to |
| + // |server_address| goes through a proxy server or not. Calls the |callback| |
| + // after proxy resolution is completed by currying the proxy resolution |
| + // status. |
| + ProxyDetector(net::ProxyService* proxy_service, |
| + const net::HostPortPair& server_address, |
| + ProxyDetectorCallback callback); |
| + |
| + // This method uses |proxy_service_| to resolve the proxy for |
| + // |server_address_|. |
| + void ResolveProxy(); |
| + |
| + private: |
| + // This object is deleted from |OnResolveProxyComplete|. |
| + ~ProxyDetector(); |
| + |
| + // Calls the |callback_| by currying the proxy resolution status. |
| + void OnResolveProxyComplete(int result); |
| + |
| + // |proxy_service_| specifies the proxy service that is to be used to find |
| + // if access to |server_address_| goes through proxy server or not. |
| + net::ProxyService* proxy_service_; |
| + |
| + // |server_address_| specifies the server host and port pair for which we are |
| + // trying to see if access to it, goes through proxy or not. |
| + net::HostPortPair server_address_; |
| + |
| + // |callback_| will be called after proxy resolution is completed. |
| + ProxyDetectorCallback callback_; |
| + |
| + // |proxy_info_| holds proxy information returned by ResolveProxy. |
| + net::ProxyInfo proxy_info_; |
| + |
| + // Indicates if there is a pending a proxy resolution. We use this to assert |
| + // that there is no in-progress proxy resolution request. |
| + bool has_pending_proxy_resolution_; |
| +}; |
| + |
| // This collects the network connectivity stats for UDP and TCP for small |
| // percentage of users who are participating in the experiment. All users must |
| // have enabled "UMA upload". This method gets called only if UMA upload to the |
| @@ -355,6 +409,15 @@ |
| void CollectNetworkStats(const std::string& network_stats_server_url, |
| IOThread* io_thread); |
| +// This starts a test randomly selected among "TCP test with small packet size", |
| +// "TCP test with large packet size", "UDP test with small packet size", "UDP |
| +// test with large packet size" and "UDP multi packet loss" tests to collect the |
| +// network connectivity stats. |
| +void StartNetworkStatsTest(net::HostResolver* host_resolver, |
| + const net::HostPortPair& server_address, |
| + NetworkStats::HistogramPortSelector histogram_port, |
| + bool has_proxy_server); |
| + |
| } // namespace chrome_browser_net |
| #endif // CHROME_BROWSER_NET_NETWORK_STATS_H_ |