Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: chrome/browser/net/connection_tester.cc

Issue 11959029: Make the v8 Isolate used in the proxy resolver explicit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed component build Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 net::ProxyConfig::CreateDirect())); 80 net::ProxyConfig::CreateDirect()));
81 return net::OK; 81 return net::OK;
82 default: 82 default:
83 NOTREACHED(); 83 NOTREACHED();
84 return net::ERR_UNEXPECTED; 84 return net::ERR_UNEXPECTED;
85 } 85 }
86 } 86 }
87 87
88 int Init(const ConnectionTester::Experiment& experiment, 88 int Init(const ConnectionTester::Experiment& experiment,
89 scoped_ptr<net::ProxyConfigService>* proxy_config_service, 89 scoped_ptr<net::ProxyConfigService>* proxy_config_service,
90 v8::Isolate* v8_default_isolate,
90 net::NetLog* net_log) { 91 net::NetLog* net_log) {
91 int rv; 92 int rv;
92 93
93 // Create a custom HostResolver for this experiment. 94 // Create a custom HostResolver for this experiment.
94 scoped_ptr<net::HostResolver> host_resolver_tmp; 95 scoped_ptr<net::HostResolver> host_resolver_tmp;
95 rv = CreateHostResolver(experiment.host_resolver_experiment, 96 rv = CreateHostResolver(experiment.host_resolver_experiment,
96 &host_resolver_tmp); 97 &host_resolver_tmp);
97 if (rv != net::OK) 98 if (rv != net::OK)
98 return rv; // Failure. 99 return rv; // Failure.
99 storage_.set_host_resolver(host_resolver_tmp.Pass()); 100 storage_.set_host_resolver(host_resolver_tmp.Pass());
100 101
101 // Create a custom ProxyService for this this experiment. 102 // Create a custom ProxyService for this this experiment.
102 scoped_ptr<net::ProxyService> experiment_proxy_service; 103 scoped_ptr<net::ProxyService> experiment_proxy_service;
103 rv = CreateProxyService(experiment.proxy_settings_experiment, 104 rv = CreateProxyService(experiment.proxy_settings_experiment,
104 proxy_config_service, &experiment_proxy_service); 105 proxy_config_service, &experiment_proxy_service,
106 v8_default_isolate);
105 if (rv != net::OK) 107 if (rv != net::OK)
106 return rv; // Failure. 108 return rv; // Failure.
107 storage_.set_proxy_service(experiment_proxy_service.release()); 109 storage_.set_proxy_service(experiment_proxy_service.release());
108 110
109 // The rest of the dependencies are standard, and don't depend on the 111 // The rest of the dependencies are standard, and don't depend on the
110 // experiment being run. 112 // experiment being run.
111 storage_.set_cert_verifier(net::CertVerifier::CreateDefault()); 113 storage_.set_cert_verifier(net::CertVerifier::CreateDefault());
112 #if !defined(DISABLE_FTP_SUPPORT) 114 #if !defined(DISABLE_FTP_SUPPORT)
113 storage_.set_ftp_transaction_factory( 115 storage_.set_ftp_transaction_factory(
114 new net::FtpNetworkLayer(host_resolver())); 116 new net::FtpNetworkLayer(host_resolver()));
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 host_resolver->swap(resolver); 179 host_resolver->swap(resolver);
178 return net::OK; 180 return net::OK;
179 } 181 }
180 182
181 // Creates a proxy service for |experiment|. On success returns net::OK 183 // Creates a proxy service for |experiment|. On success returns net::OK
182 // and fills |experiment_proxy_service| with a new pointer. Otherwise returns 184 // and fills |experiment_proxy_service| with a new pointer. Otherwise returns
183 // a network error code. 185 // a network error code.
184 int CreateProxyService( 186 int CreateProxyService(
185 ConnectionTester::ProxySettingsExperiment experiment, 187 ConnectionTester::ProxySettingsExperiment experiment,
186 scoped_ptr<net::ProxyConfigService>* proxy_config_service, 188 scoped_ptr<net::ProxyConfigService>* proxy_config_service,
187 scoped_ptr<net::ProxyService>* experiment_proxy_service) { 189 scoped_ptr<net::ProxyService>* experiment_proxy_service,
190 v8::Isolate* v8_default_isolate) {
188 if (CommandLine::ForCurrentProcess()->HasSwitch( 191 if (CommandLine::ForCurrentProcess()->HasSwitch(
189 switches::kSingleProcess)) { 192 switches::kSingleProcess)) {
190 // We can't create a standard proxy resolver in single-process mode. 193 // We can't create a standard proxy resolver in single-process mode.
191 // Rather than falling-back to some other implementation, fail. 194 // Rather than falling-back to some other implementation, fail.
192 return net::ERR_NOT_IMPLEMENTED; 195 return net::ERR_NOT_IMPLEMENTED;
193 } 196 }
194 197
195 net::DhcpProxyScriptFetcherFactory dhcp_factory; 198 net::DhcpProxyScriptFetcherFactory dhcp_factory;
196 if (CommandLine::ForCurrentProcess()->HasSwitch( 199 if (CommandLine::ForCurrentProcess()->HasSwitch(
197 switches::kDisableDhcpWpad)) { 200 switches::kDisableDhcpWpad)) {
198 dhcp_factory.set_enabled(false); 201 dhcp_factory.set_enabled(false);
199 } 202 }
200 203
201 #if defined(OS_IOS) 204 #if defined(OS_IOS)
202 experiment_proxy_service->reset( 205 experiment_proxy_service->reset(
203 net::ProxyService::CreateUsingSystemProxyResolver( 206 net::ProxyService::CreateUsingSystemProxyResolver(
204 proxy_config_service->release(), 0u, NULL)); 207 proxy_config_service->release(), 0u, NULL));
205 #else 208 #else
206 experiment_proxy_service->reset( 209 experiment_proxy_service->reset(
207 net::CreateProxyServiceUsingV8ProxyResolver( 210 net::CreateProxyServiceUsingV8ProxyResolver(
208 proxy_config_service->release(), 211 proxy_config_service->release(),
209 0u, 212 0u,
210 new net::ProxyScriptFetcherImpl(proxy_request_context_), 213 new net::ProxyScriptFetcherImpl(proxy_request_context_),
211 dhcp_factory.Create(proxy_request_context_), 214 dhcp_factory.Create(proxy_request_context_),
212 host_resolver(), 215 host_resolver(),
213 NULL, 216 NULL,
214 NULL)); 217 NULL,
218 v8_default_isolate));
215 #endif 219 #endif
216 220
217 return net::OK; 221 return net::OK;
218 } 222 }
219 223
220 // Creates a proxy config service that pulls from the system proxy settings. 224 // Creates a proxy config service that pulls from the system proxy settings.
221 // On success returns net::OK and fills |config_service| with a new pointer. 225 // On success returns net::OK and fills |config_service| with a new pointer.
222 // Otherwise returns a network error code. 226 // Otherwise returns a network error code.
223 int CreateSystemProxyConfigService( 227 int CreateSystemProxyConfigService(
224 scoped_ptr<net::ProxyConfigService>* config_service) { 228 scoped_ptr<net::ProxyConfigService>* config_service) {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 tester_->OnExperimentCompleted(result); 407 tester_->OnExperimentCompleted(result);
404 } 408 }
405 409
406 void ConnectionTester::TestRunner::ProxyConfigServiceCreated( 410 void ConnectionTester::TestRunner::ProxyConfigServiceCreated(
407 const Experiment& experiment, 411 const Experiment& experiment,
408 scoped_ptr<net::ProxyConfigService>* proxy_config_service, 412 scoped_ptr<net::ProxyConfigService>* proxy_config_service,
409 int status) { 413 int status) {
410 if (status == net::OK) 414 if (status == net::OK)
411 status = request_context_->Init(experiment, 415 status = request_context_->Init(experiment,
412 proxy_config_service, 416 proxy_config_service,
417 tester_->v8_default_isolate_,
413 net_log_); 418 net_log_);
414 if (status != net::OK) { 419 if (status != net::OK) {
415 tester_->OnExperimentCompleted(status); 420 tester_->OnExperimentCompleted(status);
416 return; 421 return;
417 } 422 }
418 // Fetch a request using the experimental context. 423 // Fetch a request using the experimental context.
419 request_.reset(request_context_->CreateRequest(experiment.url, this)); 424 request_.reset(request_context_->CreateRequest(experiment.url, this));
420 request_->Start(); 425 request_->Start();
421 } 426 }
422 427
(...skipping 12 matching lines...) Expand all
435 proxy_config_service, config_service_callback); 440 proxy_config_service, config_service_callback);
436 if (rv != net::ERR_IO_PENDING) 441 if (rv != net::ERR_IO_PENDING)
437 ProxyConfigServiceCreated(experiment, proxy_config_service, rv); 442 ProxyConfigServiceCreated(experiment, proxy_config_service, rv);
438 } 443 }
439 444
440 // ConnectionTester ---------------------------------------------------------- 445 // ConnectionTester ----------------------------------------------------------
441 446
442 ConnectionTester::ConnectionTester( 447 ConnectionTester::ConnectionTester(
443 Delegate* delegate, 448 Delegate* delegate,
444 net::URLRequestContext* proxy_request_context, 449 net::URLRequestContext* proxy_request_context,
445 net::NetLog* net_log) 450 net::NetLog* net_log,
451 v8::Isolate* v8_default_isolate)
446 : delegate_(delegate), 452 : delegate_(delegate),
447 proxy_request_context_(proxy_request_context), 453 proxy_request_context_(proxy_request_context),
448 net_log_(net_log) { 454 net_log_(net_log),
455 v8_default_isolate_(v8_default_isolate) {
449 DCHECK(delegate); 456 DCHECK(delegate);
450 DCHECK(proxy_request_context); 457 DCHECK(proxy_request_context);
458 DCHECK(v8_default_isolate);
451 } 459 }
452 460
453 ConnectionTester::~ConnectionTester() { 461 ConnectionTester::~ConnectionTester() {
454 // Cancellation happens automatically by deleting test_runner_. 462 // Cancellation happens automatically by deleting test_runner_.
455 } 463 }
456 464
457 void ConnectionTester::RunAllTests(const GURL& url) { 465 void ConnectionTester::RunAllTests(const GURL& url) {
458 // Select all possible experiments to run. (In no particular order). 466 // Select all possible experiments to run. (In no particular order).
459 // It is possible that some of these experiments are actually duplicates. 467 // It is possible that some of these experiments are actually duplicates.
460 GetAllPossibleExperimentCombinations(url, &remaining_experiments_); 468 GetAllPossibleExperimentCombinations(url, &remaining_experiments_);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 546
539 // Notify the delegate of completion. 547 // Notify the delegate of completion.
540 delegate_->OnCompletedConnectionTestExperiment(current, result); 548 delegate_->OnCompletedConnectionTestExperiment(current, result);
541 549
542 if (remaining_experiments_.empty()) { 550 if (remaining_experiments_.empty()) {
543 delegate_->OnCompletedConnectionTestSuite(); 551 delegate_->OnCompletedConnectionTestSuite();
544 } else { 552 } else {
545 StartNextExperiment(); 553 StartNextExperiment();
546 } 554 }
547 } 555 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698