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/connection_tester.h" | 5 #include "chrome/browser/net/connection_tester.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 session_params.host_resolver = host_resolver(); | 117 session_params.host_resolver = host_resolver(); |
118 session_params.cert_verifier = cert_verifier(); | 118 session_params.cert_verifier = cert_verifier(); |
119 session_params.proxy_service = proxy_service(); | 119 session_params.proxy_service = proxy_service(); |
120 session_params.ssl_config_service = ssl_config_service(); | 120 session_params.ssl_config_service = ssl_config_service(); |
121 session_params.http_auth_handler_factory = http_auth_handler_factory(); | 121 session_params.http_auth_handler_factory = http_auth_handler_factory(); |
122 session_params.http_server_properties = http_server_properties(); | 122 session_params.http_server_properties = http_server_properties(); |
123 session_params.net_log = net_log; | 123 session_params.net_log = net_log; |
124 scoped_refptr<net::HttpNetworkSession> network_session( | 124 scoped_refptr<net::HttpNetworkSession> network_session( |
125 new net::HttpNetworkSession(session_params)); | 125 new net::HttpNetworkSession(session_params)); |
126 storage_.set_http_transaction_factory(new net::HttpCache( | 126 storage_.set_http_transaction_factory(new net::HttpCache( |
127 network_session, | 127 network_session.get(), net::HttpCache::DefaultBackend::InMemory(0))); |
128 net::HttpCache::DefaultBackend::InMemory(0))); | |
129 // In-memory cookie store. | 128 // In-memory cookie store. |
130 storage_.set_cookie_store(new net::CookieMonster(NULL, NULL)); | 129 storage_.set_cookie_store(new net::CookieMonster(NULL, NULL)); |
131 | 130 |
132 return net::OK; | 131 return net::OK; |
133 } | 132 } |
134 | 133 |
135 private: | 134 private: |
136 // Creates a host resolver for |experiment|. On success returns net::OK and | 135 // Creates a host resolver for |experiment|. On success returns net::OK and |
137 // fills |host_resolver| with a new pointer. Otherwise returns a network | 136 // fills |host_resolver| with a new pointer. Otherwise returns a network |
138 // error code. | 137 // error code. |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 | 361 |
363 // Keep reading until the stream is closed. Throw the data read away. | 362 // Keep reading until the stream is closed. Throw the data read away. |
364 ReadBody(request); | 363 ReadBody(request); |
365 } | 364 } |
366 | 365 |
367 void ConnectionTester::TestRunner::ReadBody(net::URLRequest* request) { | 366 void ConnectionTester::TestRunner::ReadBody(net::URLRequest* request) { |
368 // Read the response body |kReadBufferSize| bytes at a time. | 367 // Read the response body |kReadBufferSize| bytes at a time. |
369 scoped_refptr<net::IOBuffer> unused_buffer( | 368 scoped_refptr<net::IOBuffer> unused_buffer( |
370 new net::IOBuffer(kReadBufferSize)); | 369 new net::IOBuffer(kReadBufferSize)); |
371 int num_bytes; | 370 int num_bytes; |
372 if (request->Read(unused_buffer, kReadBufferSize, &num_bytes)) { | 371 if (request->Read(unused_buffer.get(), kReadBufferSize, &num_bytes)) { |
373 OnReadCompleted(request, num_bytes); | 372 OnReadCompleted(request, num_bytes); |
374 } else if (!request->status().is_io_pending()) { | 373 } else if (!request->status().is_io_pending()) { |
375 // Read failed synchronously. | 374 // Read failed synchronously. |
376 OnResponseCompleted(request); | 375 OnResponseCompleted(request); |
377 } | 376 } |
378 } | 377 } |
379 | 378 |
380 void ConnectionTester::TestRunner::OnResponseCompleted( | 379 void ConnectionTester::TestRunner::OnResponseCompleted( |
381 net::URLRequest* request) { | 380 net::URLRequest* request) { |
382 int result = net::OK; | 381 int result = net::OK; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 | 532 |
534 // Notify the delegate of completion. | 533 // Notify the delegate of completion. |
535 delegate_->OnCompletedConnectionTestExperiment(current, result); | 534 delegate_->OnCompletedConnectionTestExperiment(current, result); |
536 | 535 |
537 if (remaining_experiments_.empty()) { | 536 if (remaining_experiments_.empty()) { |
538 delegate_->OnCompletedConnectionTestSuite(); | 537 delegate_->OnCompletedConnectionTestSuite(); |
539 } else { | 538 } else { |
540 StartNextExperiment(); | 539 StartNextExperiment(); |
541 } | 540 } |
542 } | 541 } |
OLD | NEW |