summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreroman <eroman@chromium.org>2015-04-09 18:58:58 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-10 01:59:29 +0000
commit3016ebc175612431204477c29f11c1348108cb0a (patch)
tree229790a74c495a8a1e7ba9a02b2cedfd30405c59
parent48f2d919f8ecea7da75cdfa237bf1f6b06ae8d2f (diff)
downloadchromium_src-3016ebc175612431204477c29f11c1348108cb0a.zip
chromium_src-3016ebc175612431204477c29f11c1348108cb0a.tar.gz
chromium_src-3016ebc175612431204477c29f11c1348108cb0a.tar.bz2
Remove the connection tester (chrome://net-internals#tests)
BUG=472313 Review URL: https://codereview.chromium.org/1071603003 Cr-Commit-Position: refs/heads/master@{#324572}
-rw-r--r--chrome/browser/net/connection_tester.cc542
-rw-r--r--chrome/browser/net/connection_tester.h186
-rw-r--r--chrome/browser/net/connection_tester_unittest.cc176
-rw-r--r--chrome/browser/resources/net_internals/index.html1
-rw-r--r--chrome/browser/resources/net_internals/index.js1
-rw-r--r--chrome/browser/resources/net_internals/main.js1
-rw-r--r--chrome/browser/resources/net_internals/test_view.html13
-rw-r--r--chrome/browser/resources/net_internals/test_view.js163
-rw-r--r--chrome/browser/ui/webui/net_internals/net_internals_ui.cc122
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--chrome/chrome_tests.gypi1
-rw-r--r--chrome/chrome_tests_unit.gypi1
-rw-r--r--chrome/test/data/webui/net_internals/log_util.js2
-rw-r--r--chrome/test/data/webui/net_internals/main.js1
-rw-r--r--chrome/test/data/webui/net_internals/net_internals_test.js1
-rw-r--r--chrome/test/data/webui/net_internals/test_view.js183
-rw-r--r--tools/metrics/histograms/histograms.xml3
17 files changed, 4 insertions, 1395 deletions
diff --git a/chrome/browser/net/connection_tester.cc b/chrome/browser/net/connection_tester.cc
deleted file mode 100644
index 57b4362..0000000
--- a/chrome/browser/net/connection_tester.cc
+++ /dev/null
@@ -1,542 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/net/connection_tester.h"
-
-#include "base/bind.h"
-#include "base/command_line.h"
-#include "base/compiler_specific.h"
-#include "base/logging.h"
-#include "base/memory/weak_ptr.h"
-#include "base/message_loop/message_loop.h"
-#include "base/strings/utf_string_conversions.h"
-#include "base/thread_task_runner_handle.h"
-#include "base/threading/thread_restrictions.h"
-#include "chrome/common/chrome_switches.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/cookie_store_factory.h"
-#include "net/base/io_buffer.h"
-#include "net/base/net_errors.h"
-#include "net/base/net_util.h"
-#include "net/base/request_priority.h"
-#include "net/cert/cert_verifier.h"
-#include "net/dns/host_resolver.h"
-#include "net/http/http_auth_handler_factory.h"
-#include "net/http/http_cache.h"
-#include "net/http/http_network_session.h"
-#include "net/http/http_server_properties_impl.h"
-#include "net/http/transport_security_state.h"
-#include "net/proxy/dhcp_proxy_script_fetcher_factory.h"
-#include "net/proxy/proxy_config_service_fixed.h"
-#include "net/proxy/proxy_script_fetcher_impl.h"
-#include "net/proxy/proxy_service.h"
-#include "net/proxy/proxy_service_v8.h"
-#include "net/ssl/ssl_config_service_defaults.h"
-#include "net/url_request/url_request.h"
-#include "net/url_request/url_request_context.h"
-#include "net/url_request/url_request_context_storage.h"
-#include "net/url_request/url_request_job_factory_impl.h"
-
-#if !defined(OS_ANDROID) && !defined(OS_IOS)
-#include "chrome/browser/net/firefox_proxy_settings.h"
-#endif
-
-namespace {
-
-// ExperimentURLRequestContext ------------------------------------------------
-
-// An instance of ExperimentURLRequestContext is created for each experiment
-// run by ConnectionTester. The class initializes network dependencies according
-// to the specified "experiment".
-class ExperimentURLRequestContext : public net::URLRequestContext {
- public:
- explicit ExperimentURLRequestContext(
- net::URLRequestContext* proxy_request_context) :
-#if !defined(OS_IOS)
- proxy_request_context_(proxy_request_context),
-#endif
- storage_(this),
- weak_factory_(this) {}
-
- ~ExperimentURLRequestContext() override { AssertNoURLRequests(); }
-
- // Creates a proxy config service for |experiment|. On success returns net::OK
- // and fills |config_service| with a new pointer. Otherwise returns a network
- // error code.
- int CreateProxyConfigService(
- ConnectionTester::ProxySettingsExperiment experiment,
- scoped_ptr<net::ProxyConfigService>* config_service,
- base::Callback<void(int)> callback) {
- switch (experiment) {
- case ConnectionTester::PROXY_EXPERIMENT_USE_SYSTEM_SETTINGS:
- return CreateSystemProxyConfigService(config_service);
- case ConnectionTester::PROXY_EXPERIMENT_USE_FIREFOX_SETTINGS:
- return CreateFirefoxProxyConfigService(config_service, callback);
- case ConnectionTester::PROXY_EXPERIMENT_USE_AUTO_DETECT:
- config_service->reset(new net::ProxyConfigServiceFixed(
- net::ProxyConfig::CreateAutoDetect()));
- return net::OK;
- case ConnectionTester::PROXY_EXPERIMENT_USE_DIRECT:
- config_service->reset(new net::ProxyConfigServiceFixed(
- net::ProxyConfig::CreateDirect()));
- return net::OK;
- default:
- NOTREACHED();
- return net::ERR_UNEXPECTED;
- }
- }
-
- int Init(const ConnectionTester::Experiment& experiment,
- scoped_ptr<net::ProxyConfigService>* proxy_config_service,
- net::NetLog* net_log) {
- int rv;
-
- // Create a custom HostResolver for this experiment.
- scoped_ptr<net::HostResolver> host_resolver_tmp;
- rv = CreateHostResolver(experiment.host_resolver_experiment,
- &host_resolver_tmp);
- if (rv != net::OK)
- return rv; // Failure.
- storage_.set_host_resolver(host_resolver_tmp.Pass());
-
- // Create a custom ProxyService for this this experiment.
- scoped_ptr<net::ProxyService> experiment_proxy_service;
- rv = CreateProxyService(experiment.proxy_settings_experiment,
- proxy_config_service, &experiment_proxy_service);
- if (rv != net::OK)
- return rv; // Failure.
- storage_.set_proxy_service(experiment_proxy_service.release());
-
- // The rest of the dependencies are standard, and don't depend on the
- // experiment being run.
- storage_.set_cert_verifier(net::CertVerifier::CreateDefault());
- storage_.set_transport_security_state(new net::TransportSecurityState);
- storage_.set_ssl_config_service(new net::SSLConfigServiceDefaults);
- storage_.set_http_auth_handler_factory(
- net::HttpAuthHandlerFactory::CreateDefault(host_resolver()));
- storage_.set_http_server_properties(
- scoped_ptr<net::HttpServerProperties>(
- new net::HttpServerPropertiesImpl()));
-
- net::HttpNetworkSession::Params session_params;
- session_params.host_resolver = host_resolver();
- session_params.cert_verifier = cert_verifier();
- session_params.transport_security_state = transport_security_state();
- session_params.proxy_service = proxy_service();
- session_params.ssl_config_service = ssl_config_service();
- session_params.http_auth_handler_factory = http_auth_handler_factory();
- session_params.http_server_properties = http_server_properties();
- session_params.net_log = net_log;
- scoped_refptr<net::HttpNetworkSession> network_session(
- new net::HttpNetworkSession(session_params));
- storage_.set_http_transaction_factory(new net::HttpCache(
- network_session.get(), net::HttpCache::DefaultBackend::InMemory(0)));
- // In-memory cookie store.
- storage_.set_cookie_store(
- content::CreateCookieStore(content::CookieStoreConfig()));
- // Creating a new job factory avoids added ProtocolHandlers and
- // layered URLRequestInterceptingJobFactories.
- storage_.set_job_factory(new net::URLRequestJobFactoryImpl());
-
- return net::OK;
- }
-
- private:
- // Creates a host resolver for |experiment|. On success returns net::OK and
- // fills |host_resolver| with a new pointer. Otherwise returns a network
- // error code.
- int CreateHostResolver(
- ConnectionTester::HostResolverExperiment experiment,
- scoped_ptr<net::HostResolver>* host_resolver) {
- // Create a vanilla HostResolver that disables caching.
- const size_t kMaxJobs = 50u;
- const size_t kMaxRetryAttempts = 4u;
- net::HostResolver::Options options;
- options.max_concurrent_resolves = kMaxJobs;
- options.max_retry_attempts = kMaxRetryAttempts;
- options.enable_caching = false;
- scoped_ptr<net::HostResolver> resolver(
- net::HostResolver::CreateSystemResolver(options, NULL /* NetLog */));
-
- // Modify it slightly based on the experiment being run.
- switch (experiment) {
- case ConnectionTester::HOST_RESOLVER_EXPERIMENT_PLAIN:
- break;
- case ConnectionTester::HOST_RESOLVER_EXPERIMENT_DISABLE_IPV6:
- resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_IPV4);
- break;
- case ConnectionTester::HOST_RESOLVER_EXPERIMENT_IPV6_PROBE: {
- // The system HostResolver will probe by default.
- break;
- }
- default:
- NOTREACHED();
- return net::ERR_UNEXPECTED;
- }
- host_resolver->swap(resolver);
- return net::OK;
- }
-
- // Creates a proxy service for |experiment|. On success returns net::OK
- // and fills |experiment_proxy_service| with a new pointer. Otherwise returns
- // a network error code.
- int CreateProxyService(
- ConnectionTester::ProxySettingsExperiment experiment,
- scoped_ptr<net::ProxyConfigService>* proxy_config_service,
- scoped_ptr<net::ProxyService>* experiment_proxy_service) {
- if (base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kSingleProcess)) {
- // We can't create a standard proxy resolver in single-process mode.
- // Rather than falling-back to some other implementation, fail.
- return net::ERR_NOT_IMPLEMENTED;
- }
-
- net::DhcpProxyScriptFetcherFactory dhcp_factory;
-
-#if defined(OS_IOS)
- experiment_proxy_service->reset(
- net::ProxyService::CreateUsingSystemProxyResolver(
- proxy_config_service->release(), 0u, NULL));
-#else
- experiment_proxy_service->reset(
- net::CreateProxyServiceUsingV8ProxyResolver(
- proxy_config_service->release(),
- new net::ProxyScriptFetcherImpl(proxy_request_context_),
- dhcp_factory.Create(proxy_request_context_),
- host_resolver(),
- NULL,
- NULL));
-#endif
-
- return net::OK;
- }
-
- // Creates a proxy config service that pulls from the system proxy settings.
- // On success returns net::OK and fills |config_service| with a new pointer.
- // Otherwise returns a network error code.
- int CreateSystemProxyConfigService(
- scoped_ptr<net::ProxyConfigService>* config_service) {
-#if defined(OS_LINUX) || defined(OS_OPENBSD)
- // TODO(eroman): This is not supported on Linux yet, because of how
- // construction needs ot happen on the UI thread.
- return net::ERR_NOT_IMPLEMENTED;
-#else
- config_service->reset(net::ProxyService::CreateSystemProxyConfigService(
- base::ThreadTaskRunnerHandle::Get().get(), NULL));
- return net::OK;
-#endif
- }
-
-#if !defined(OS_ANDROID) && !defined(OS_IOS)
- static int FirefoxProxySettingsTask(
- FirefoxProxySettings* firefox_settings) {
- if (!FirefoxProxySettings::GetSettings(firefox_settings))
- return net::ERR_FILE_NOT_FOUND;
- return net::OK;
- }
-
- void FirefoxProxySettingsReply(
- scoped_ptr<net::ProxyConfigService>* config_service,
- FirefoxProxySettings* firefox_settings,
- base::Callback<void(int)> callback,
- int rv) {
- if (rv == net::OK) {
- if (FirefoxProxySettings::SYSTEM == firefox_settings->config_type()) {
- rv = CreateSystemProxyConfigService(config_service);
- } else {
- net::ProxyConfig config;
- if (firefox_settings->ToProxyConfig(&config))
- config_service->reset(new net::ProxyConfigServiceFixed(config));
- else
- rv = net::ERR_FAILED;
- }
- }
- callback.Run(rv);
- }
-#endif
-
- // Creates a fixed proxy config service that is initialized using Firefox's
- // current proxy settings. On success returns net::OK and fills
- // |config_service| with a new pointer. Otherwise returns a network error
- // code.
- int CreateFirefoxProxyConfigService(
- scoped_ptr<net::ProxyConfigService>* config_service,
- base::Callback<void(int)> callback) {
-#if defined(OS_ANDROID) || defined(OS_IOS)
- // Chrome on Android and iOS do not support Firefox settings.
- return net::ERR_NOT_IMPLEMENTED;
-#else
- // Fetch Firefox's proxy settings (can fail if Firefox is not installed).
- FirefoxProxySettings* ff_settings = new FirefoxProxySettings();
- base::Callback<int(void)> task = base::Bind(
- &FirefoxProxySettingsTask, ff_settings);
- base::Callback<void(int)> reply = base::Bind(
- &ExperimentURLRequestContext::FirefoxProxySettingsReply,
- weak_factory_.GetWeakPtr(), config_service,
- base::Owned(ff_settings), callback);
- if (!content::BrowserThread::PostTaskAndReplyWithResult<int>(
- content::BrowserThread::FILE, FROM_HERE, task, reply))
- return net::ERR_FAILED;
- return net::ERR_IO_PENDING;
-#endif
- }
-
-#if !defined(OS_IOS)
- net::URLRequestContext* const proxy_request_context_;
-#endif
- net::URLRequestContextStorage storage_;
- base::WeakPtrFactory<ExperimentURLRequestContext> weak_factory_;
-};
-
-} // namespace
-
-// ConnectionTester::TestRunner ----------------------------------------------
-
-// TestRunner is a helper class for running an individual experiment. It can
-// be deleted any time after it is started, and this will abort the request.
-class ConnectionTester::TestRunner : public net::URLRequest::Delegate {
- public:
- // |tester| must remain alive throughout the TestRunner's lifetime.
- // |tester| will be notified of completion.
- TestRunner(ConnectionTester* tester, net::NetLog* net_log)
- : tester_(tester),
- net_log_(net_log),
- weak_factory_(this) {}
-
- // Finish running |experiment| once a ProxyConfigService has been created.
- // In the case of a FirefoxProxyConfigService, this will be called back
- // after disk access has completed.
- void ProxyConfigServiceCreated(
- const Experiment& experiment,
- scoped_ptr<net::ProxyConfigService>* proxy_config_service, int status);
-
- // Starts running |experiment|. Notifies tester->OnExperimentCompleted() when
- // it is done.
- void Run(const Experiment& experiment);
-
- // Overridden from net::URLRequest::Delegate:
- void OnResponseStarted(net::URLRequest* request) override;
- void OnReadCompleted(net::URLRequest* request, int bytes_read) override;
- // TODO(eroman): handle cases requiring authentication.
-
- private:
- // The number of bytes to read each response body chunk.
- static const int kReadBufferSize = 1024;
-
- // Starts reading the response's body (and keeps reading until an error or
- // end of stream).
- void ReadBody(net::URLRequest* request);
-
- // Called when the request has completed (for both success and failure).
- void OnResponseCompleted(net::URLRequest* request);
- void OnExperimentCompletedWithResult(int result);
-
- ConnectionTester* tester_;
- scoped_ptr<ExperimentURLRequestContext> request_context_;
- scoped_ptr<net::URLRequest> request_;
- net::NetLog* net_log_;
-
- base::WeakPtrFactory<TestRunner> weak_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(TestRunner);
-};
-
-void ConnectionTester::TestRunner::OnResponseStarted(net::URLRequest* request) {
- if (!request->status().is_success()) {
- OnResponseCompleted(request);
- return;
- }
-
- // Start reading the body.
- ReadBody(request);
-}
-
-void ConnectionTester::TestRunner::OnReadCompleted(net::URLRequest* request,
- int bytes_read) {
- if (bytes_read <= 0) {
- OnResponseCompleted(request);
- return;
- }
-
- // Keep reading until the stream is closed. Throw the data read away.
- ReadBody(request);
-}
-
-void ConnectionTester::TestRunner::ReadBody(net::URLRequest* request) {
- // Read the response body |kReadBufferSize| bytes at a time.
- scoped_refptr<net::IOBuffer> unused_buffer(
- new net::IOBuffer(kReadBufferSize));
- int num_bytes;
- if (request->Read(unused_buffer.get(), kReadBufferSize, &num_bytes)) {
- OnReadCompleted(request, num_bytes);
- } else if (!request->status().is_io_pending()) {
- // Read failed synchronously.
- OnResponseCompleted(request);
- }
-}
-
-void ConnectionTester::TestRunner::OnResponseCompleted(
- net::URLRequest* request) {
- int result = net::OK;
- if (!request->status().is_success()) {
- DCHECK_NE(net::ERR_IO_PENDING, request->status().error());
- result = request->status().error();
- }
-
- // Post a task to notify the parent rather than handling it right away,
- // to avoid re-entrancy problems with URLRequest. (Don't want the caller
- // to end up deleting the URLRequest while in the middle of processing).
- base::MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&TestRunner::OnExperimentCompletedWithResult,
- weak_factory_.GetWeakPtr(), result));
-}
-
-void ConnectionTester::TestRunner::OnExperimentCompletedWithResult(int result) {
- tester_->OnExperimentCompleted(result);
-}
-
-void ConnectionTester::TestRunner::ProxyConfigServiceCreated(
- const Experiment& experiment,
- scoped_ptr<net::ProxyConfigService>* proxy_config_service,
- int status) {
- if (status == net::OK)
- status = request_context_->Init(experiment,
- proxy_config_service,
- net_log_);
- if (status != net::OK) {
- tester_->OnExperimentCompleted(status);
- return;
- }
- // Fetch a request using the experimental context.
- request_ = request_context_->CreateRequest(
- experiment.url, net::DEFAULT_PRIORITY, this);
- request_->Start();
-}
-
-void ConnectionTester::TestRunner::Run(const Experiment& experiment) {
- // Try to create a net::URLRequestContext for this experiment.
- request_context_.reset(
- new ExperimentURLRequestContext(tester_->proxy_request_context_));
- scoped_ptr<net::ProxyConfigService>* proxy_config_service =
- new scoped_ptr<net::ProxyConfigService>();
- base::Callback<void(int)> config_service_callback =
- base::Bind(
- &TestRunner::ProxyConfigServiceCreated, weak_factory_.GetWeakPtr(),
- experiment, base::Owned(proxy_config_service));
- int rv = request_context_->CreateProxyConfigService(
- experiment.proxy_settings_experiment,
- proxy_config_service, config_service_callback);
- if (rv != net::ERR_IO_PENDING)
- ProxyConfigServiceCreated(experiment, proxy_config_service, rv);
-}
-
-// ConnectionTester ----------------------------------------------------------
-
-ConnectionTester::ConnectionTester(
- Delegate* delegate,
- net::URLRequestContext* proxy_request_context,
- net::NetLog* net_log)
- : delegate_(delegate),
- proxy_request_context_(proxy_request_context),
- net_log_(net_log) {
- DCHECK(delegate);
- DCHECK(proxy_request_context);
-}
-
-ConnectionTester::~ConnectionTester() {
- // Cancellation happens automatically by deleting test_runner_.
-}
-
-void ConnectionTester::RunAllTests(const GURL& url) {
- // Select all possible experiments to run. (In no particular order).
- // It is possible that some of these experiments are actually duplicates.
- GetAllPossibleExperimentCombinations(url, &remaining_experiments_);
-
- delegate_->OnStartConnectionTestSuite();
- StartNextExperiment();
-}
-
-// static
-base::string16 ConnectionTester::ProxySettingsExperimentDescription(
- ProxySettingsExperiment experiment) {
- // TODO(eroman): Use proper string resources.
- switch (experiment) {
- case PROXY_EXPERIMENT_USE_DIRECT:
- return base::ASCIIToUTF16("Don't use any proxy");
- case PROXY_EXPERIMENT_USE_SYSTEM_SETTINGS:
- return base::ASCIIToUTF16("Use system proxy settings");
- case PROXY_EXPERIMENT_USE_FIREFOX_SETTINGS:
- return base::ASCIIToUTF16("Use Firefox's proxy settings");
- case PROXY_EXPERIMENT_USE_AUTO_DETECT:
- return base::ASCIIToUTF16("Auto-detect proxy settings");
- default:
- NOTREACHED();
- return base::string16();
- }
-}
-
-// static
-base::string16 ConnectionTester::HostResolverExperimentDescription(
- HostResolverExperiment experiment) {
- // TODO(eroman): Use proper string resources.
- switch (experiment) {
- case HOST_RESOLVER_EXPERIMENT_PLAIN:
- return base::string16();
- case HOST_RESOLVER_EXPERIMENT_DISABLE_IPV6:
- return base::ASCIIToUTF16("Disable IPv6 host resolving");
- case HOST_RESOLVER_EXPERIMENT_IPV6_PROBE:
- return base::ASCIIToUTF16("Probe for IPv6 host resolving");
- default:
- NOTREACHED();
- return base::string16();
- }
-}
-
-// static
-void ConnectionTester::GetAllPossibleExperimentCombinations(
- const GURL& url,
- ConnectionTester::ExperimentList* list) {
- list->clear();
- for (size_t resolver_experiment = 0;
- resolver_experiment < HOST_RESOLVER_EXPERIMENT_COUNT;
- ++resolver_experiment) {
- for (size_t proxy_experiment = 0;
- proxy_experiment < PROXY_EXPERIMENT_COUNT;
- ++proxy_experiment) {
- Experiment experiment(
- url,
- static_cast<ProxySettingsExperiment>(proxy_experiment),
- static_cast<HostResolverExperiment>(resolver_experiment));
- list->push_back(experiment);
- }
- }
-}
-
-void ConnectionTester::StartNextExperiment() {
- DCHECK(!remaining_experiments_.empty());
- DCHECK(!current_test_runner_.get());
-
- delegate_->OnStartConnectionTestExperiment(current_experiment());
-
- current_test_runner_.reset(new TestRunner(this, net_log_));
- current_test_runner_->Run(current_experiment());
-}
-
-void ConnectionTester::OnExperimentCompleted(int result) {
- Experiment current = current_experiment();
-
- // Advance to the next experiment.
- remaining_experiments_.erase(remaining_experiments_.begin());
- current_test_runner_.reset();
-
- // Notify the delegate of completion.
- delegate_->OnCompletedConnectionTestExperiment(current, result);
-
- if (remaining_experiments_.empty()) {
- delegate_->OnCompletedConnectionTestSuite();
- } else {
- StartNextExperiment();
- }
-}
diff --git a/chrome/browser/net/connection_tester.h b/chrome/browser/net/connection_tester.h
deleted file mode 100644
index ba9dec9..0000000
--- a/chrome/browser/net/connection_tester.h
+++ /dev/null
@@ -1,186 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_NET_CONNECTION_TESTER_H_
-#define CHROME_BROWSER_NET_CONNECTION_TESTER_H_
-
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/memory/scoped_ptr.h"
-#include "net/base/completion_callback.h"
-#include "url/gurl.h"
-
-namespace net {
-class NetLog;
-class URLRequestContext;
-} // namespace net
-
-// ConnectionTester runs a suite of tests (also called "experiments"),
-// to try and discover why loading a particular URL is failing with an error
-// code.
-//
-// For example, one reason why the URL might have failed, is that the
-// network requires the URL to be routed through a proxy, however chrome is
-// not configured for that.
-//
-// The above issue might be detected by running test that fetches the URL using
-// auto-detect and seeing if it works this time. Or even by retrieving the
-// settings from another installed browser and trying with those.
-//
-// USAGE:
-//
-// To run the test suite, create an instance of ConnectionTester and then call
-// RunAllTests().
-//
-// This starts a sequence of tests, which will complete asynchronously.
-// The ConnectionTester object can be deleted at any time, and it will abort
-// any of the in-progress tests.
-//
-// As tests are started or completed, notification will be sent through the
-// "Delegate" object.
-
-class ConnectionTester {
- public:
- // This enum lists the possible proxy settings configurations.
- enum ProxySettingsExperiment {
- // Do not use any proxy.
- PROXY_EXPERIMENT_USE_DIRECT = 0,
-
- // Use the system proxy settings.
- PROXY_EXPERIMENT_USE_SYSTEM_SETTINGS,
-
- // Use Firefox's proxy settings if they are available.
- PROXY_EXPERIMENT_USE_FIREFOX_SETTINGS,
-
- // Use proxy auto-detect.
- PROXY_EXPERIMENT_USE_AUTO_DETECT,
-
- PROXY_EXPERIMENT_COUNT,
- };
-
- // This enum lists the possible host resolving configurations.
- enum HostResolverExperiment {
- // Use a default host resolver implementation.
- HOST_RESOLVER_EXPERIMENT_PLAIN = 0,
-
- // Disable IPv6 host resolving.
- HOST_RESOLVER_EXPERIMENT_DISABLE_IPV6,
-
- // Probe for IPv6 support.
- HOST_RESOLVER_EXPERIMENT_IPV6_PROBE,
-
- HOST_RESOLVER_EXPERIMENT_COUNT,
- };
-
- // The "Experiment" structure describes an individual test to run.
- struct Experiment {
- Experiment(const GURL& url,
- ProxySettingsExperiment proxy_settings_experiment,
- HostResolverExperiment host_resolver_experiment)
- : url(url),
- proxy_settings_experiment(proxy_settings_experiment),
- host_resolver_experiment(host_resolver_experiment) {
- }
-
- // The URL to try and fetch.
- GURL url;
-
- // The proxy settings to use.
- ProxySettingsExperiment proxy_settings_experiment;
-
- // The host resolver settings to use.
- HostResolverExperiment host_resolver_experiment;
- };
-
- typedef std::vector<Experiment> ExperimentList;
-
- // "Delegate" is an interface for receiving start and completion notification
- // of individual tests that are run by the ConnectionTester.
- //
- // NOTE: do not delete the ConnectionTester when executing within one of the
- // delegate methods.
- class Delegate {
- public:
- // Called once the test suite is about to start.
- virtual void OnStartConnectionTestSuite() = 0;
-
- // Called when an individual experiment is about to be started.
- virtual void OnStartConnectionTestExperiment(
- const Experiment& experiment) = 0;
-
- // Called when an individual experiment has completed.
- // |experiment| - the experiment that has completed.
- // |result| - the net error that the experiment completed with
- // (or net::OK if it was success).
- virtual void OnCompletedConnectionTestExperiment(
- const Experiment& experiment,
- int result) = 0;
-
- // Called once ALL tests have completed.
- virtual void OnCompletedConnectionTestSuite() = 0;
-
- protected:
- virtual ~Delegate() {}
- };
-
- // Constructs a ConnectionTester that notifies test progress to |delegate|.
- // |delegate| is owned by the caller, and must remain valid for the lifetime
- // of ConnectionTester.
- ConnectionTester(Delegate* delegate,
- net::URLRequestContext* proxy_request_context,
- net::NetLog* net_log);
-
- // Note that destruction cancels any in-progress tests.
- ~ConnectionTester();
-
- // Starts running the test suite on |url|. Notification of progress is sent to
- // |delegate_|.
- void RunAllTests(const GURL& url);
-
- // Returns a text string explaining what |experiment| is testing.
- static base::string16 ProxySettingsExperimentDescription(
- ProxySettingsExperiment experiment);
- static base::string16 HostResolverExperimentDescription(
- HostResolverExperiment experiment);
-
- private:
- // Internally each experiment run by ConnectionTester is handled by a
- // "TestRunner" instance.
- class TestRunner;
- friend class TestRunner;
-
- // Fills |list| with the set of all possible experiments for |url|.
- static void GetAllPossibleExperimentCombinations(const GURL& url,
- ExperimentList* list);
-
- // Starts the next experiment from |remaining_experiments_|.
- void StartNextExperiment();
-
- // Callback for when |current_test_runner_| finishes.
- void OnExperimentCompleted(int result);
-
- // Returns the experiment at the front of our list.
- const Experiment& current_experiment() const {
- return remaining_experiments_.front();
- }
-
- // The object to notify test progress to.
- Delegate* delegate_;
-
- // The current in-progress test, or NULL if there is no active test.
- scoped_ptr<TestRunner> current_test_runner_;
-
- // The ordered list of experiments to try next. The experiment at the front
- // of the list is the one currently in progress.
- ExperimentList remaining_experiments_;
-
- net::URLRequestContext* const proxy_request_context_;
-
- net::NetLog* net_log_;
-
- DISALLOW_COPY_AND_ASSIGN(ConnectionTester);
-};
-
-#endif // CHROME_BROWSER_NET_CONNECTION_TESTER_H_
diff --git a/chrome/browser/net/connection_tester_unittest.cc b/chrome/browser/net/connection_tester_unittest.cc
deleted file mode 100644
index ff5fe67..0000000
--- a/chrome/browser/net/connection_tester_unittest.cc
+++ /dev/null
@@ -1,176 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/net/connection_tester.h"
-
-#include "base/prefs/testing_pref_service.h"
-#include "content/public/browser/cookie_store_factory.h"
-#include "content/public/test/test_browser_thread.h"
-#include "content/public/browser/cookie_store_factory.h"
-#include "net/cert/mock_cert_verifier.h"
-#include "net/dns/mock_host_resolver.h"
-#include "net/ftp/ftp_network_layer.h"
-#include "net/http/http_auth_handler_factory.h"
-#include "net/http/http_network_layer.h"
-#include "net/http/http_network_session.h"
-#include "net/http/http_server_properties_impl.h"
-#include "net/http/transport_security_state.h"
-#include "net/proxy/proxy_config_service_fixed.h"
-#include "net/proxy/proxy_service.h"
-#include "net/ssl/ssl_config_service_defaults.h"
-#include "net/test/spawned_test_server/spawned_test_server.h"
-#include "net/url_request/url_request_context.h"
-#include "net/url_request/url_request_test_util.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "testing/platform_test.h"
-
-using content::BrowserThread;
-
-namespace {
-
-// This is a testing delegate which simply counts how many times each of
-// the delegate's methods were invoked.
-class ConnectionTesterDelegate : public ConnectionTester::Delegate {
- public:
- ConnectionTesterDelegate()
- : start_connection_test_suite_count_(0),
- start_connection_test_experiment_count_(0),
- completed_connection_test_experiment_count_(0),
- completed_connection_test_suite_count_(0) {
- }
-
- void OnStartConnectionTestSuite() override {
- start_connection_test_suite_count_++;
- }
-
- void OnStartConnectionTestExperiment(
- const ConnectionTester::Experiment& experiment) override {
- start_connection_test_experiment_count_++;
- }
-
- void OnCompletedConnectionTestExperiment(
- const ConnectionTester::Experiment& experiment,
- int result) override {
- completed_connection_test_experiment_count_++;
- }
-
- void OnCompletedConnectionTestSuite() override {
- completed_connection_test_suite_count_++;
- base::MessageLoop::current()->Quit();
- }
-
- int start_connection_test_suite_count() const {
- return start_connection_test_suite_count_;
- }
-
- int start_connection_test_experiment_count() const {
- return start_connection_test_experiment_count_;
- }
-
- int completed_connection_test_experiment_count() const {
- return completed_connection_test_experiment_count_;
- }
-
- int completed_connection_test_suite_count() const {
- return completed_connection_test_suite_count_;
- }
-
- private:
- int start_connection_test_suite_count_;
- int start_connection_test_experiment_count_;
- int completed_connection_test_experiment_count_;
- int completed_connection_test_suite_count_;
-};
-
-// The test fixture is responsible for:
-// - Making sure each test has an IO loop running
-// - Catching any host resolve requests and mapping them to localhost
-// (so the test doesn't use any external network dependencies).
-class ConnectionTesterTest : public PlatformTest {
- public:
- ConnectionTesterTest()
- : io_thread_(BrowserThread::IO, &message_loop_),
- test_server_(net::SpawnedTestServer::TYPE_HTTP,
- net::SpawnedTestServer::kLocalhost,
- // Nothing is read in this directory.
- base::FilePath(FILE_PATH_LITERAL("chrome"))) {
- }
-
- protected:
- // Destroy last the MessageLoop last to give a chance for objects like
- // ObserverListThreadSave to shut down properly. For example,
- // SSLClientAuthCache calls RemoveObserver when destroyed, but if the
- // MessageLoop is already destroyed, then the RemoveObserver will be a
- // no-op, and the ObserverList will contain invalid entries.
- base::MessageLoopForIO message_loop_;
- content::TestBrowserThread io_thread_;
- net::SpawnedTestServer test_server_;
- net::TestURLRequestContext proxy_script_fetcher_context_;
- ConnectionTesterDelegate test_delegate_;
-};
-
-TEST_F(ConnectionTesterTest, RunAllTests) {
- ASSERT_TRUE(test_server_.Start());
-
- ConnectionTester tester(&test_delegate_,
- &proxy_script_fetcher_context_,
- NULL);
-
- // Start the test suite on URL "echoall".
- // TODO(eroman): Is this URL right?
- tester.RunAllTests(test_server_.GetURL("echoall"));
-
- // Wait for all the tests to complete.
- base::MessageLoop::current()->Run();
-
- const int kNumExperiments =
- ConnectionTester::PROXY_EXPERIMENT_COUNT *
- ConnectionTester::HOST_RESOLVER_EXPERIMENT_COUNT;
-
- EXPECT_EQ(1, test_delegate_.start_connection_test_suite_count());
- EXPECT_EQ(kNumExperiments,
- test_delegate_.start_connection_test_experiment_count());
- EXPECT_EQ(kNumExperiments,
- test_delegate_.completed_connection_test_experiment_count());
- EXPECT_EQ(1, test_delegate_.completed_connection_test_suite_count());
-}
-
-TEST_F(ConnectionTesterTest, DeleteWhileInProgress) {
- ASSERT_TRUE(test_server_.Start());
-
- scoped_ptr<ConnectionTester> tester(
- new ConnectionTester(&test_delegate_,
- &proxy_script_fetcher_context_,
- NULL));
-
- // Start the test suite on URL "echoall".
- // TODO(eroman): Is this URL right?
- tester->RunAllTests(test_server_.GetURL("echoall"));
-
- // Don't run the message loop at all. Otherwise the experiment's request may
- // complete and post a task to run the next experiment before we quit the
- // message loop.
-
- EXPECT_EQ(1, test_delegate_.start_connection_test_suite_count());
- EXPECT_EQ(1, test_delegate_.start_connection_test_experiment_count());
- EXPECT_EQ(0, test_delegate_.completed_connection_test_experiment_count());
- EXPECT_EQ(0, test_delegate_.completed_connection_test_suite_count());
-
- // Delete the ConnectionTester while it is in progress.
- tester.reset();
-
- // Drain the tasks on the message loop.
- //
- // Note that we cannot simply stop the message loop, since that will delete
- // any pending tasks instead of running them. This causes a problem with
- // net::ClientSocketPoolBaseHelper, since the "Group" holds a pointer
- // |backup_task| that it will try to deref during the destructor, but
- // depending on the order that pending tasks were deleted in, it might
- // already be invalid! See http://crbug.com/43291.
- base::MessageLoop::current()->PostTask(FROM_HERE,
- base::MessageLoop::QuitClosure());
- base::MessageLoop::current()->Run();
-}
-
-} // namespace
diff --git a/chrome/browser/resources/net_internals/index.html b/chrome/browser/resources/net_internals/index.html
index a6a4ab2..cfd5f2d 100644
--- a/chrome/browser/resources/net_internals/index.html
+++ b/chrome/browser/resources/net_internals/index.html
@@ -39,7 +39,6 @@ found in the LICENSE file.
<include src="import_view.html">
<include src="export_view.html">
<include src="capture_view.html">
- <include src="test_view.html">
<include src="hsts_view.html">
<include src="events_view.html">
<include src="waterfall_view.html">
diff --git a/chrome/browser/resources/net_internals/index.js b/chrome/browser/resources/net_internals/index.js
index 20f1c61..55b9abf 100644
--- a/chrome/browser/resources/net_internals/index.js
+++ b/chrome/browser/resources/net_internals/index.js
@@ -11,7 +11,6 @@
<include src="capture_view.js">
<include src="export_view.js">
<include src="http_cache_view.js">
-<include src="test_view.js">
<include src="hsts_view.js">
<include src="browser_bridge.js">
<include src="events_tracker.js">
diff --git a/chrome/browser/resources/net_internals/main.js b/chrome/browser/resources/net_internals/main.js
index 37621cd..0b49ad7 100644
--- a/chrome/browser/resources/net_internals/main.js
+++ b/chrome/browser/resources/net_internals/main.js
@@ -197,7 +197,6 @@ var MainView = (function() {
addTab(SdchView);
addTab(HttpCacheView);
addTab(ModulesView);
- addTab(TestView);
addTab(HSTSView);
addTab(BandwidthView);
addTab(PrerenderView);
diff --git a/chrome/browser/resources/net_internals/test_view.html b/chrome/browser/resources/net_internals/test_view.html
deleted file mode 100644
index 9f1839c..0000000
--- a/chrome/browser/resources/net_internals/test_view.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!-- Connection tests -->
-<div id="test-view-tab-content" class="content-box">
- <div style='margin-bottom: 20px'>
- Input a URL which failed to load, and then click the button to run some
- tests for why it failed.
- </div>
- <form id="test-view-connection-tests-form">
- <label>URL: <input id="test-view-url-input" type="text"></label>
- <input id="test-view-connection-tests-submit" type="submit"
- value="Start tests">
- </form>
- <div id="test-view-summary"></div>
-</div>
diff --git a/chrome/browser/resources/net_internals/test_view.js b/chrome/browser/resources/net_internals/test_view.js
deleted file mode 100644
index a902bd0..0000000
--- a/chrome/browser/resources/net_internals/test_view.js
+++ /dev/null
@@ -1,163 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-/**
- * This view displays the progress and results from the "connection tester".
- *
- * - Has an input box to specify the URL.
- * - Has a button to start running the tests.
- * - Shows the set of experiments that have been run so far, and their
- * result.
- */
-var TestView = (function() {
- 'use strict';
-
- // We inherit from DivView.
- var superClass = DivView;
-
- /**
- * @constructor
- */
- function TestView() {
- assertFirstConstructorCall(TestView);
-
- // Call superclass's constructor.
- superClass.call(this, TestView.MAIN_BOX_ID);
-
- this.urlInput_ = $(TestView.URL_INPUT_ID);
- this.summaryDiv_ = $(TestView.SUMMARY_DIV_ID);
-
- var form = $(TestView.FORM_ID);
- form.addEventListener('submit', this.onSubmitForm_.bind(this), false);
-
- // Register to test information as it's received.
- g_browser.addConnectionTestsObserver(this);
- }
-
- TestView.TAB_ID = 'tab-handle-tests';
- TestView.TAB_NAME = 'Tests';
- TestView.TAB_HASH = '#tests';
-
- // IDs for special HTML elements in test_view.html
- TestView.MAIN_BOX_ID = 'test-view-tab-content';
- TestView.FORM_ID = 'test-view-connection-tests-form';
- TestView.URL_INPUT_ID = 'test-view-url-input';
- TestView.SUMMARY_DIV_ID = 'test-view-summary';
- // Needed by tests.
- TestView.SUBMIT_BUTTON_ID = 'test-view-connection-tests-submit';
-
-
- cr.addSingletonGetter(TestView);
-
- TestView.prototype = {
- // Inherit the superclass's methods.
- __proto__: superClass.prototype,
-
- onSubmitForm_: function(event) {
- g_browser.sendStartConnectionTests(this.urlInput_.value);
- event.preventDefault();
- },
-
- /**
- * Callback for when the connection tests have begun.
- */
- onStartedConnectionTestSuite: function() {
- this.summaryDiv_.innerHTML = '';
-
- var p = addNode(this.summaryDiv_, 'p');
- addTextNode(p, 'Started connection test suite suite on ');
- timeutil.addNodeWithDate(p, new Date());
-
- // Add a table that will hold the individual test results.
- var table = addNode(this.summaryDiv_, 'table');
- table.className = 'styled-table';
- var thead = addNode(table, 'thead');
- thead.innerHTML = '<tr><th>Result</th><th>Experiment</th>' +
- '<th>Error</th><th>Time (ms)</th></tr>';
-
- this.tbody_ = addNode(table, 'tbody');
- },
-
- /**
- * Callback for when an individual test in the suite has begun.
- */
- onStartedConnectionTestExperiment: function(experiment) {
- var tr = addNode(this.tbody_, 'tr');
-
- var passFailCell = addNode(tr, 'td');
-
- var experimentCell = addNode(tr, 'td');
-
- var resultCell = addNode(tr, 'td');
- addTextNode(resultCell, '?');
-
- var dtCell = addNode(tr, 'td');
- addTextNode(dtCell, '?');
-
- // We will fill in result cells with actual values (to replace the
- // placeholder '?') once the test has completed. For now we just
- // save references to these cells.
- this.currentExperimentRow_ = {
- experimentCell: experimentCell,
- dtCell: dtCell,
- resultCell: resultCell,
- passFailCell: passFailCell,
- startTime: timeutil.getCurrentTime()
- };
-
- addTextNode(experimentCell, 'Fetch ' + experiment.url);
-
- if (experiment.proxy_settings_experiment ||
- experiment.host_resolver_experiment) {
- var ul = addNode(experimentCell, 'ul');
-
- if (experiment.proxy_settings_experiment) {
- var li = addNode(ul, 'li');
- addTextNode(li, experiment.proxy_settings_experiment);
- }
-
- if (experiment.host_resolver_experiment) {
- var li = addNode(ul, 'li');
- addTextNode(li, experiment.host_resolver_experiment);
- }
- }
- },
-
- /**
- * Callback for when an individual test in the suite has finished.
- */
- onCompletedConnectionTestExperiment: function(experiment, result) {
- var r = this.currentExperimentRow_;
-
- var endTime = timeutil.getCurrentTime();
-
- r.dtCell.innerHTML = '';
- addTextNode(r.dtCell, (endTime - r.startTime));
-
- r.resultCell.innerHTML = '';
-
- if (result == 0) {
- r.passFailCell.style.color = 'green';
- addTextNode(r.passFailCell, 'PASS');
- } else {
- addTextNode(r.resultCell,
- netErrorToString(result) + ' (' + result + ')');
- r.passFailCell.style.color = '#e00';
- addTextNode(r.passFailCell, 'FAIL');
- }
-
- this.currentExperimentRow_ = null;
- },
-
- /**
- * Callback for when the last test in the suite has finished.
- */
- onCompletedConnectionTestSuite: function() {
- var p = addNode(this.summaryDiv_, 'p');
- addTextNode(p, 'Completed connection test suite suite');
- }
- };
-
- return TestView;
-})();
diff --git a/chrome/browser/ui/webui/net_internals/net_internals_ui.cc b/chrome/browser/ui/webui/net_internals/net_internals_ui.cc
index ba85b3b..e8a6f64 100644
--- a/chrome/browser/ui/webui/net_internals/net_internals_ui.cc
+++ b/chrome/browser/ui/webui/net_internals/net_internals_ui.cc
@@ -19,7 +19,6 @@
#include "base/files/file_util.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h"
-#include "base/metrics/histogram_macros.h"
#include "base/prefs/pref_member.h"
#include "base/sequenced_task_runner_helpers.h"
#include "base/strings/string_number_conversions.h"
@@ -36,7 +35,6 @@
#include "chrome/browser/io_thread.h"
#include "chrome/browser/net/chrome_net_log.h"
#include "chrome/browser/net/chrome_network_delegate.h"
-#include "chrome/browser/net/connection_tester.h"
#include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
#include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_factory.h"
#include "chrome/browser/prerender/prerender_manager.h"
@@ -113,35 +111,6 @@ namespace {
// sent to the page at once, which reduces context switching and CPU usage.
const int kNetLogEventDelayMilliseconds = 100;
-// TODO(eroman): Temporary while investigating http://crbug.com/472313
-//
-// The objective is to measure the usage of the connection tester relative to
-// the usage of chrome://net-internals. (It is expected that both will have low
-// overall usage).
-//
-// Rather than count total usages (which would be skewed towards the most active
-// users), only record 1 "usage" of these feature per launch of Chrome.
-
-enum Feature {
- FEATURE_NET_INTERNALS_USED,
- FEATURE_CONNECTION_TESTER,
- FEATURE_COUNT,
-};
-
-void HistogramUsage(Feature feature) {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
-
- // Static is safe because this code only runs on the IO thread.
- static unsigned int usages_bit_field = 0;
-
- unsigned int bit_flag = 1 << feature;
- if ((usages_bit_field & bit_flag) == 0) {
- usages_bit_field |= bit_flag;
- UMA_HISTOGRAM_ENUMERATION("Net.NetInternalsUi.Feature", feature,
- FEATURE_COUNT);
- }
-}
-
// Returns the HostCache for |context|'s primary HostResolver, or NULL if
// there is none.
net::HostCache* GetHostResolverCache(net::URLRequestContext* context) {
@@ -193,21 +162,6 @@ net::HttpNetworkSession* GetHttpNetworkSession(
return context->http_transaction_factory()->GetSession();
}
-base::Value* ExperimentToValue(const ConnectionTester::Experiment& experiment) {
- base::DictionaryValue* dict = new base::DictionaryValue();
-
- if (experiment.url.is_valid())
- dict->SetString("url", experiment.url.spec());
-
- dict->SetString("proxy_settings_experiment",
- ConnectionTester::ProxySettingsExperimentDescription(
- experiment.proxy_settings_experiment));
- dict->SetString("host_resolver_experiment",
- ConnectionTester::HostResolverExperimentDescription(
- experiment.host_resolver_experiment));
- return dict;
-}
-
content::WebUIDataSource* CreateNetInternalsHTMLSource() {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUINetInternalsHost);
@@ -293,8 +247,7 @@ class NetInternalsMessageHandler::IOThreadImpl
: public base::RefCountedThreadSafe<
NetInternalsMessageHandler::IOThreadImpl,
BrowserThread::DeleteOnUIThread>,
- public net::NetLog::ThreadSafeObserver,
- public ConnectionTester::Delegate {
+ public net::NetLog::ThreadSafeObserver {
public:
// Type for methods that can be used as MessageHandler callbacks.
typedef void (IOThreadImpl::*MessageHandler)(const base::ListValue*);
@@ -337,7 +290,6 @@ class NetInternalsMessageHandler::IOThreadImpl
void OnClearBadProxies(const base::ListValue* list);
void OnClearHostResolverCache(const base::ListValue* list);
void OnEnableIPv6(const base::ListValue* list);
- void OnStartConnectionTests(const base::ListValue* list);
void OnHSTSQuery(const base::ListValue* list);
void OnHSTSAdd(const base::ListValue* list);
void OnHSTSDelete(const base::ListValue* list);
@@ -352,15 +304,6 @@ class NetInternalsMessageHandler::IOThreadImpl
// ChromeNetLog::ThreadSafeObserver implementation:
void OnAddEntry(const net::NetLog::Entry& entry) override;
- // ConnectionTester::Delegate implementation:
- void OnStartConnectionTestSuite() override;
- void OnStartConnectionTestExperiment(
- const ConnectionTester::Experiment& experiment) override;
- void OnCompletedConnectionTestExperiment(
- const ConnectionTester::Experiment& experiment,
- int result) override;
- void OnCompletedConnectionTestSuite() override;
-
// Helper that calls g_browser.receive in the renderer, passing in |command|
// and |arg|. Takes ownership of |arg|. If the renderer is displaying a log
// file, the message will be ignored. Note that this can be called from any
@@ -409,9 +352,6 @@ class NetInternalsMessageHandler::IOThreadImpl
// The main URLRequestContextGetter for the tab's profile.
scoped_refptr<net::URLRequestContextGetter> main_context_getter_;
- // Helper that runs the suite of connection tests.
- scoped_ptr<ConnectionTester> connection_tester_;
-
// True if the Web UI has been deleted. This is used to prevent calling
// Javascript functions after the Web UI is destroyed. On refresh, the
// messages can end up being sent to the refreshed page, causing duplicate
@@ -495,10 +435,6 @@ void NetInternalsMessageHandler::RegisterMessages() {
base::Bind(&IOThreadImpl::CallbackHelper,
&IOThreadImpl::OnEnableIPv6, proxy_));
web_ui()->RegisterMessageCallback(
- "startConnectionTests",
- base::Bind(&IOThreadImpl::CallbackHelper,
- &IOThreadImpl::OnStartConnectionTests, proxy_));
- web_ui()->RegisterMessageCallback(
"hstsQuery",
base::Bind(&IOThreadImpl::CallbackHelper,
&IOThreadImpl::OnHSTSQuery, proxy_));
@@ -723,9 +659,6 @@ void NetInternalsMessageHandler::IOThreadImpl::Detach() {
// Unregister with network stack to observe events.
if (net_log())
net_log()->DeprecatedRemoveObserver(this);
-
- // Cancel any in-progress connection tests.
- connection_tester_.reset();
}
void NetInternalsMessageHandler::IOThreadImpl::OnWebUIDeleted() {
@@ -737,8 +670,6 @@ void NetInternalsMessageHandler::IOThreadImpl::OnRendererReady(
const base::ListValue* list) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- HistogramUsage(FEATURE_NET_INTERNALS_USED);
-
// If currently watching the NetLog, temporarily stop watching it and flush
// pending events, so they won't appear before the status events created for
// currently active network objects below.
@@ -806,25 +737,6 @@ void NetInternalsMessageHandler::IOThreadImpl::OnEnableIPv6(
SendNetInfo(net::NET_INFO_HOST_RESOLVER);
}
-void NetInternalsMessageHandler::IOThreadImpl::OnStartConnectionTests(
- const base::ListValue* list) {
- HistogramUsage(FEATURE_CONNECTION_TESTER);
-
- // |value| should be: [<URL to test>].
- base::string16 url_str;
- CHECK(list->GetString(0, &url_str));
-
- // Try to fix-up the user provided URL into something valid.
- // For example, turn "www.google.com" into "http://www.google.com".
- GURL url(url_fixer::FixupURL(base::UTF16ToUTF8(url_str), std::string()));
-
- connection_tester_.reset(new ConnectionTester(
- this,
- io_thread_->globals()->proxy_script_fetcher_context.get(),
- net_log()));
- connection_tester_->RunAllTests(url);
-}
-
void NetInternalsMessageHandler::IOThreadImpl::OnHSTSQuery(
const base::ListValue* list) {
// |list| should be: [<domain to query>].
@@ -1183,38 +1095,6 @@ void NetInternalsMessageHandler::IOThreadImpl::OnAddEntry(
base::Bind(&IOThreadImpl::AddEntryToQueue, this, entry.ToValue()));
}
-void NetInternalsMessageHandler::IOThreadImpl::OnStartConnectionTestSuite() {
- SendJavascriptCommand("receivedStartConnectionTestSuite", NULL);
-}
-
-void NetInternalsMessageHandler::IOThreadImpl::OnStartConnectionTestExperiment(
- const ConnectionTester::Experiment& experiment) {
- SendJavascriptCommand(
- "receivedStartConnectionTestExperiment",
- ExperimentToValue(experiment));
-}
-
-void
-NetInternalsMessageHandler::IOThreadImpl::OnCompletedConnectionTestExperiment(
- const ConnectionTester::Experiment& experiment,
- int result) {
- base::DictionaryValue* dict = new base::DictionaryValue();
-
- dict->Set("experiment", ExperimentToValue(experiment));
- dict->SetInteger("result", result);
-
- SendJavascriptCommand(
- "receivedCompletedConnectionTestExperiment",
- dict);
-}
-
-void
-NetInternalsMessageHandler::IOThreadImpl::OnCompletedConnectionTestSuite() {
- SendJavascriptCommand(
- "receivedCompletedConnectionTestSuite",
- NULL);
-}
-
// Note that this can be called from ANY THREAD.
void NetInternalsMessageHandler::IOThreadImpl::SendJavascriptCommand(
const std::string& command,
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index c6548f8..06e6883 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1811,8 +1811,6 @@
'browser/net/chrome_url_request_context_getter.h',
'browser/net/connect_interceptor.cc',
'browser/net/connect_interceptor.h',
- 'browser/net/connection_tester.cc',
- 'browser/net/connection_tester.h',
'browser/net/cookie_store_util.cc',
'browser/net/cookie_store_util.h',
'browser/net/crl_set_fetcher.cc',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 123f4bf..4a32316 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -883,7 +883,6 @@
'test/data/webui/net_internals/main.js',
'test/data/webui/net_internals/net_internals_test.js',
'test/data/webui/net_internals/prerender_view.js',
- 'test/data/webui/net_internals/test_view.js',
'test/data/webui/net_internals/timeline_view.js',
'test/data/webui/net_internals/waterfall_view.js',
'test/data/webui/net_internals/sdch_view.js',
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index 1d6305e..077140f 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -152,7 +152,6 @@
'browser/net/certificate_error_reporter_unittest.cc',
'browser/net/chrome_fraudulent_certificate_reporter_unittest.cc',
'browser/net/chrome_network_delegate_unittest.cc',
- 'browser/net/connection_tester_unittest.cc',
'browser/net/dns_probe_runner_unittest.cc',
'browser/net/dns_probe_service_unittest.cc',
'browser/net/evicted_domain_cookie_counter_unittest.cc',
diff --git a/chrome/test/data/webui/net_internals/log_util.js b/chrome/test/data/webui/net_internals/log_util.js
index 9b1d9e0..f8dca34 100644
--- a/chrome/test/data/webui/net_internals/log_util.js
+++ b/chrome/test/data/webui/net_internals/log_util.js
@@ -176,7 +176,6 @@ function checkViewsAfterLogLoaded() {
sdch: true,
httpCache: true,
modules: true,
- tests: false,
hsts: false,
prerender: true,
bandwidth: true,
@@ -206,7 +205,6 @@ function checkViewsAfterNetLogLoggerLogLoaded() {
sdch: false,
httpCache: false,
modules: false,
- tests: false,
hsts: false,
prerender: false,
bandwidth: false,
diff --git a/chrome/test/data/webui/net_internals/main.js b/chrome/test/data/webui/net_internals/main.js
index 0fa5fa6..533f66b 100644
--- a/chrome/test/data/webui/net_internals/main.js
+++ b/chrome/test/data/webui/net_internals/main.js
@@ -35,7 +35,6 @@ TEST_F('NetInternalsTest', 'netInternalsTourTabs', function() {
sdch: true,
httpCache: true,
modules: true,
- tests: true,
hsts: true,
prerender: true,
bandwidth: true,
diff --git a/chrome/test/data/webui/net_internals/net_internals_test.js b/chrome/test/data/webui/net_internals/net_internals_test.js
index d9b1864..4da682b 100644
--- a/chrome/test/data/webui/net_internals/net_internals_test.js
+++ b/chrome/test/data/webui/net_internals/net_internals_test.js
@@ -297,7 +297,6 @@ var NetInternalsTest = (function() {
sdch: SdchView.TAB_ID,
httpCache: HttpCacheView.TAB_ID,
modules: ModulesView.TAB_ID,
- tests: TestView.TAB_ID,
hsts: HSTSView.TAB_ID,
prerender: PrerenderView.TAB_ID,
bandwidth: BandwidthView.TAB_ID,
diff --git a/chrome/test/data/webui/net_internals/test_view.js b/chrome/test/data/webui/net_internals/test_view.js
deleted file mode 100644
index 85d91e6..0000000
--- a/chrome/test/data/webui/net_internals/test_view.js
+++ /dev/null
@@ -1,183 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Include test fixture.
-GEN_INCLUDE(['net_internals_test.js']);
-
-// Anonymous namespace
-(function() {
-
-/**
- * Navigates to the test tab, runs the test suite once, using a URL
- * either passed to the constructor or passed in from the previous task, and
- * expects to see |expectedResult| from the first experiment. If
- * |expectedResult| indicates failure, all experiments are expected to fail.
- * Otherwise, results of all experiments but the first are ignored.
- * Checks the order of events and several fields of the events received.
- *
- * Note that it is not safe for one RunTestSuiteTasks to run right after
- * another. Otherwise, the second Task would receive the final observer
- * message from the first task.
- *
- * @param {int} expectedResult Expected result of first test.
- * @param {string} url URL to test. If null, will use parameter passed to
- * start instead.
- * @extends {NetInternalsTest.Task}
- * @constructor
- */
-function RunTestSuiteTask(expectedResult, url) {
- NetInternalsTest.Task.call(this);
- // Complete asynchronously, so two RunTestSuiteTask can be run in a row.
- this.setCompleteAsync(true);
-
- this.url_ = url;
- this.expectedResult_ = expectedResult;
- this.seenStartSuite_ = false;
- this.seenStartExperiment_ = false;
- this.experimentsRun_ = 0;
-}
-
-RunTestSuiteTask.prototype = {
- __proto__: NetInternalsTest.Task.prototype,
-
- /**
- * Switches to the test view, and simulates entering |url| and submitting the
- * form. Also adds the task as a ConnectionTestObserver.
- * @param {string} url URL to run the test suite on.
- */
- start: function(url) {
- NetInternalsTest.switchToView('tests');
- if (this.url_ === null) {
- assertEquals('string', typeof(url));
- this.url_ = url;
- }
-
- g_browser.addConnectionTestsObserver(this);
-
- $(TestView.URL_INPUT_ID).value = this.url_;
- $(TestView.SUBMIT_BUTTON_ID).click();
- },
-
- /**
- * Checks that the table was created/cleared, and that no experiment is
- * currently running.
- */
- onStartedConnectionTestSuite: function() {
- if (this.isDone())
- return;
- expectFalse(this.seenStartSuite_, 'Suite started more than once.');
- checkTestTableRows(0);
- expectEquals(this.experimentsRun_, 0);
- expectFalse(this.seenStartSuite_);
-
- this.seenStartSuite_ = true;
- },
-
- /**
- * Checks that the table has one row per started experiment, and the events
- * occur in the proper order.
- * @param {object} experiment Experiment that was just started.
- */
- onStartedConnectionTestExperiment: function(experiment) {
- if (this.isDone())
- return;
- console.log('Experiment: ' + this.experimentsRun_);
- expectEquals(this.url_, experiment.url, 'Test run on wrong URL');
- expectTrue(this.seenStartSuite_, 'Experiment started before suite.');
- expectFalse(this.seenStartExperiment_,
- 'Two experiments running at once.');
- checkTestTableRows(this.experimentsRun_ + 1);
-
- this.seenStartExperiment_ = true;
- },
-
- /**
- * Checks that the table has one row per started experiment, and the events
- * occur in the proper order.
- * @param {object} experiment Experiment that finished.
- * @param {number} result Code indicating success or reason for failure.
- */
- onCompletedConnectionTestExperiment: function(experiment, result) {
- if (this.isDone())
- return;
- expectEquals(this.url_, experiment.url, 'Test run on wrong URL');
- // Can only rely on the error code of the first test.
- if (this.experimentsRun_ == 0)
- expectEquals(this.expectedResult_, result);
- // If the first expected result is an error, all tests should return some
- // error.
- if (this.expectedResult_ < 0)
- expectLT(result, 0);
-
- expectTrue(this.seenStartExperiment_,
- 'Experiment stopped without starting.');
- checkTestTableRows(this.experimentsRun_ + 1);
-
- this.seenStartExperiment_ = false;
- ++this.experimentsRun_;
- },
-
- /**
- * Checks that we've received all 12 sets of results, and either runs the
- * next test iteration, or ends the test, depending on the total number of
- * iterations.
- */
- onCompletedConnectionTestSuite: function() {
- if (this.isDone())
- return;
- expectTrue(this.seenStartSuite_, 'Suite stopped without being started.');
- expectFalse(this.seenStartExperiment_,
- 'Suite stopped while experiment was still running.');
- expectEquals(12, this.experimentsRun_,
- 'Incorrect number of experiments run.');
- checkTestTableRows(this.experimentsRun_);
-
- this.onTaskDone();
- }
-};
-
-/**
- * Checks that there are |expected| rows in the test table.
- * @param {number} expectedRows Expected number of rows in the table.
- */
-function checkTestTableRows(expectedRows) {
- NetInternalsTest.checkTbodyRows(TestView.SUMMARY_DIV_ID, expectedRows);
-}
-
-/**
- * Runs the test suite twice, expecting a passing result the first time. Checks
- * the first result, the order of events that occur, and the number of rows in
- * the table. Uses the TestServer.
- */
-TEST_F('NetInternalsTest', 'netInternalsTestViewPassTwice', function() {
- var taskQueue = new NetInternalsTest.TaskQueue(true);
- taskQueue.addTask(
- new NetInternalsTest.GetTestServerURLTask('files/title1.html'));
- // 0 indicates success, the null means we'll use the URL resulting from the
- // previous task.
- taskQueue.addTask(new RunTestSuiteTask(0, null));
-
- taskQueue.addTask(
- new NetInternalsTest.GetTestServerURLTask('files/title2.html'));
- // 0 indicates success, the null means we'll use the URL resulting from the
- // previous task.
- taskQueue.addTask(new RunTestSuiteTask(0, null));
- taskQueue.run();
-});
-
-/**
- * Runs the test suite twice. Checks the exact error code of the first result,
- * the order of events that occur, and the number of rows in the HTML table.
- * Does not use the TestServer.
- */
-TEST_F('NetInternalsTest', 'netInternalsTestViewFailTwice', function() {
- var taskQueue = new NetInternalsTest.TaskQueue(true);
- taskQueue.addTask(new RunTestSuiteTask(NetError.ERR_UNSAFE_PORT,
- 'http://127.0.0.1:7/'));
- taskQueue.addTask(new RunTestSuiteTask(NetError.ERR_UNSAFE_PORT,
- 'http://127.0.0.1:7/'));
- taskQueue.run();
-});
-
-})(); // Anonymous namespace
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index a4ba40f..0e5ff1c 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -18859,6 +18859,9 @@ Therefore, the affected-histogram name has to have at least one dot in it.
</histogram>
<histogram name="Net.NetInternalsUi.Feature" enum="NetInternalsUiFeature">
+ <obsolete>
+ Removed in Chrome 44.
+ </obsolete>
<owner>eroman@chromium.org</owner>
<summary>
Counts the number of browser launches where chrome://net-internals and