Commit 801f2616 authored by mmenke@chromium.org's avatar mmenke@chromium.org

Use a NetLog for test requests seny by the the about:net-internals

connection tester.

BUG=none

Review URL: https://chromiumcodereview.appspot.com/10796112

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148670 0039d316-1c4b-4281-b951-d872f2087c98
parent af73c256
...@@ -83,7 +83,8 @@ class ExperimentURLRequestContext : public net::URLRequestContext { ...@@ -83,7 +83,8 @@ class ExperimentURLRequestContext : public net::URLRequestContext {
} }
int Init(const ConnectionTester::Experiment& experiment, int Init(const ConnectionTester::Experiment& experiment,
scoped_ptr<net::ProxyConfigService>* proxy_config_service) { scoped_ptr<net::ProxyConfigService>* proxy_config_service,
net::NetLog* net_log) {
int rv; int rv;
// Create a custom HostResolver for this experiment. // Create a custom HostResolver for this experiment.
...@@ -116,9 +117,10 @@ class ExperimentURLRequestContext : public net::URLRequestContext { ...@@ -116,9 +117,10 @@ class ExperimentURLRequestContext : public net::URLRequestContext {
session_params.host_resolver = host_resolver(); session_params.host_resolver = host_resolver();
session_params.cert_verifier = cert_verifier(); session_params.cert_verifier = cert_verifier();
session_params.proxy_service = proxy_service(); 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_auth_handler_factory = http_auth_handler_factory();
session_params.http_server_properties = http_server_properties(); session_params.http_server_properties = http_server_properties();
session_params.ssl_config_service = ssl_config_service(); session_params.net_log = net_log;
scoped_refptr<net::HttpNetworkSession> network_session( scoped_refptr<net::HttpNetworkSession> network_session(
new net::HttpNetworkSession(session_params)); new net::HttpNetworkSession(session_params));
storage_.set_http_transaction_factory(new net::HttpCache( storage_.set_http_transaction_factory(new net::HttpCache(
...@@ -288,8 +290,9 @@ class ConnectionTester::TestRunner : public net::URLRequest::Delegate { ...@@ -288,8 +290,9 @@ class ConnectionTester::TestRunner : public net::URLRequest::Delegate {
public: public:
// |tester| must remain alive throughout the TestRunner's lifetime. // |tester| must remain alive throughout the TestRunner's lifetime.
// |tester| will be notified of completion. // |tester| will be notified of completion.
explicit TestRunner(ConnectionTester* tester) TestRunner(ConnectionTester* tester, net::NetLog* net_log)
: tester_(tester), : tester_(tester),
net_log_(net_log),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {} ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {}
// Finish running |experiment| once a ProxyConfigService has been created. // Finish running |experiment| once a ProxyConfigService has been created.
...@@ -323,6 +326,7 @@ class ConnectionTester::TestRunner : public net::URLRequest::Delegate { ...@@ -323,6 +326,7 @@ class ConnectionTester::TestRunner : public net::URLRequest::Delegate {
ConnectionTester* tester_; ConnectionTester* tester_;
scoped_ptr<ExperimentURLRequestContext> request_context_; scoped_ptr<ExperimentURLRequestContext> request_context_;
scoped_ptr<net::URLRequest> request_; scoped_ptr<net::URLRequest> request_;
net::NetLog* net_log_;
base::WeakPtrFactory<TestRunner> weak_factory_; base::WeakPtrFactory<TestRunner> weak_factory_;
...@@ -389,7 +393,9 @@ void ConnectionTester::TestRunner::ProxyConfigServiceCreated( ...@@ -389,7 +393,9 @@ void ConnectionTester::TestRunner::ProxyConfigServiceCreated(
scoped_ptr<net::ProxyConfigService>* proxy_config_service, scoped_ptr<net::ProxyConfigService>* proxy_config_service,
int status) { int status) {
if (status == net::OK) if (status == net::OK)
status = request_context_->Init(experiment, proxy_config_service); status = request_context_->Init(experiment,
proxy_config_service,
net_log_);
if (status != net::OK) { if (status != net::OK) {
tester_->OnExperimentCompleted(status); tester_->OnExperimentCompleted(status);
return; return;
...@@ -422,8 +428,11 @@ void ConnectionTester::TestRunner::Run(const Experiment& experiment) { ...@@ -422,8 +428,11 @@ void ConnectionTester::TestRunner::Run(const Experiment& experiment) {
ConnectionTester::ConnectionTester( ConnectionTester::ConnectionTester(
Delegate* delegate, Delegate* delegate,
net::URLRequestContext* proxy_request_context) net::URLRequestContext* proxy_request_context,
: delegate_(delegate), proxy_request_context_(proxy_request_context) { net::NetLog* net_log)
: delegate_(delegate),
proxy_request_context_(proxy_request_context),
net_log_(net_log) {
DCHECK(delegate); DCHECK(delegate);
DCHECK(proxy_request_context); DCHECK(proxy_request_context);
} }
...@@ -503,7 +512,7 @@ void ConnectionTester::StartNextExperiment() { ...@@ -503,7 +512,7 @@ void ConnectionTester::StartNextExperiment() {
delegate_->OnStartConnectionTestExperiment(current_experiment()); delegate_->OnStartConnectionTestExperiment(current_experiment());
current_test_runner_.reset(new TestRunner(this)); current_test_runner_.reset(new TestRunner(this, net_log_));
current_test_runner_->Run(current_experiment()); current_test_runner_->Run(current_experiment());
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "net/base/completion_callback.h" #include "net/base/completion_callback.h"
namespace net { namespace net {
class NetLog;
class URLRequestContext; class URLRequestContext;
} // namespace net } // namespace net
...@@ -128,7 +129,8 @@ class ConnectionTester { ...@@ -128,7 +129,8 @@ class ConnectionTester {
// |delegate| is owned by the caller, and must remain valid for the lifetime // |delegate| is owned by the caller, and must remain valid for the lifetime
// of ConnectionTester. // of ConnectionTester.
ConnectionTester(Delegate* delegate, ConnectionTester(Delegate* delegate,
net::URLRequestContext* proxy_request_context); net::URLRequestContext* proxy_request_context,
net::NetLog* net_log);
// Note that destruction cancels any in-progress tests. // Note that destruction cancels any in-progress tests.
~ConnectionTester(); ~ConnectionTester();
...@@ -176,6 +178,8 @@ class ConnectionTester { ...@@ -176,6 +178,8 @@ class ConnectionTester {
net::URLRequestContext* const proxy_request_context_; net::URLRequestContext* const proxy_request_context_;
net::NetLog* net_log_;
DISALLOW_COPY_AND_ASSIGN(ConnectionTester); DISALLOW_COPY_AND_ASSIGN(ConnectionTester);
}; };
......
...@@ -148,7 +148,9 @@ class ConnectionTesterTest : public PlatformTest { ...@@ -148,7 +148,9 @@ class ConnectionTesterTest : public PlatformTest {
TEST_F(ConnectionTesterTest, RunAllTests) { TEST_F(ConnectionTesterTest, RunAllTests) {
ASSERT_TRUE(test_server_.Start()); ASSERT_TRUE(test_server_.Start());
ConnectionTester tester(&test_delegate_, proxy_script_fetcher_context_.get()); ConnectionTester tester(&test_delegate_,
proxy_script_fetcher_context_.get(),
NULL);
// Start the test suite on URL "echoall". // Start the test suite on URL "echoall".
// TODO(eroman): Is this URL right? // TODO(eroman): Is this URL right?
...@@ -174,7 +176,8 @@ TEST_F(ConnectionTesterTest, DeleteWhileInProgress) { ...@@ -174,7 +176,8 @@ TEST_F(ConnectionTesterTest, DeleteWhileInProgress) {
scoped_ptr<ConnectionTester> tester( scoped_ptr<ConnectionTester> tester(
new ConnectionTester(&test_delegate_, new ConnectionTester(&test_delegate_,
proxy_script_fetcher_context_.get())); proxy_script_fetcher_context_.get(),
NULL));
// Start the test suite on URL "echoall". // Start the test suite on URL "echoall".
// TODO(eroman): Is this URL right? // TODO(eroman): Is this URL right?
......
...@@ -1081,7 +1081,9 @@ void NetInternalsMessageHandler::IOThreadImpl::OnStartConnectionTests( ...@@ -1081,7 +1081,9 @@ void NetInternalsMessageHandler::IOThreadImpl::OnStartConnectionTests(
GURL url(URLFixerUpper::FixupURL(UTF16ToUTF8(url_str), std::string())); GURL url(URLFixerUpper::FixupURL(UTF16ToUTF8(url_str), std::string()));
connection_tester_.reset(new ConnectionTester( connection_tester_.reset(new ConnectionTester(
this, io_thread_->globals()->proxy_script_fetcher_context.get())); this,
io_thread_->globals()->proxy_script_fetcher_context.get(),
net_log()));
connection_tester_->RunAllTests(url); connection_tester_->RunAllTests(url);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment