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

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

Issue 6338002: net: Remove typedef net::URLRequestContext URLRequestContext; (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for real Created 9 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/threading/thread_restrictions.h" 11 #include "base/threading/thread_restrictions.h"
(...skipping 19 matching lines...) Expand all
31 #include "net/url_request/url_request.h" 31 #include "net/url_request/url_request.h"
32 #include "net/url_request/url_request_context.h" 32 #include "net/url_request/url_request_context.h"
33 33
34 namespace { 34 namespace {
35 35
36 // ExperimentURLRequestContext ------------------------------------------------ 36 // ExperimentURLRequestContext ------------------------------------------------
37 37
38 // An instance of ExperimentURLRequestContext is created for each experiment 38 // An instance of ExperimentURLRequestContext is created for each experiment
39 // run by ConnectionTester. The class initializes network dependencies according 39 // run by ConnectionTester. The class initializes network dependencies according
40 // to the specified "experiment". 40 // to the specified "experiment".
41 class ExperimentURLRequestContext : public URLRequestContext { 41 class ExperimentURLRequestContext : public net::URLRequestContext {
42 public: 42 public:
43 explicit ExperimentURLRequestContext(URLRequestContext* proxy_request_context) 43 explicit ExperimentURLRequestContext(
44 net::URLRequestContext* proxy_request_context)
44 : proxy_request_context_(proxy_request_context) {} 45 : proxy_request_context_(proxy_request_context) {}
45 46
46 int Init(const ConnectionTester::Experiment& experiment) { 47 int Init(const ConnectionTester::Experiment& experiment) {
47 int rv; 48 int rv;
48 49
49 // Create a custom HostResolver for this experiment. 50 // Create a custom HostResolver for this experiment.
50 rv = CreateHostResolver(experiment.host_resolver_experiment, 51 rv = CreateHostResolver(experiment.host_resolver_experiment,
51 &host_resolver_); 52 &host_resolver_);
52 if (rv != net::OK) 53 if (rv != net::OK)
53 return rv; // Failure. 54 return rv; // Failure.
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 217
217 net::ProxyConfig config; 218 net::ProxyConfig config;
218 if (firefox_settings.ToProxyConfig(&config)) { 219 if (firefox_settings.ToProxyConfig(&config)) {
219 config_service->reset(new net::ProxyConfigServiceFixed(config)); 220 config_service->reset(new net::ProxyConfigServiceFixed(config));
220 return net::OK; 221 return net::OK;
221 } 222 }
222 223
223 return net::ERR_FAILED; 224 return net::ERR_FAILED;
224 } 225 }
225 226
226 const scoped_refptr<URLRequestContext> proxy_request_context_; 227 const scoped_refptr<net::URLRequestContext> proxy_request_context_;
227 }; 228 };
228 229
229 } // namespace 230 } // namespace
230 231
231 // ConnectionTester::TestRunner ---------------------------------------------- 232 // ConnectionTester::TestRunner ----------------------------------------------
232 233
233 // TestRunner is a helper class for running an individual experiment. It can 234 // TestRunner is a helper class for running an individual experiment. It can
234 // be deleted any time after it is started, and this will abort the request. 235 // be deleted any time after it is started, and this will abort the request.
235 class ConnectionTester::TestRunner : public net::URLRequest::Delegate { 236 class ConnectionTester::TestRunner : public net::URLRequest::Delegate {
236 public: 237 public:
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 net::URLRequest* request) { 303 net::URLRequest* request) {
303 int result = net::OK; 304 int result = net::OK;
304 if (!request->status().is_success()) { 305 if (!request->status().is_success()) {
305 DCHECK_NE(net::ERR_IO_PENDING, request->status().os_error()); 306 DCHECK_NE(net::ERR_IO_PENDING, request->status().os_error());
306 result = request->status().os_error(); 307 result = request->status().os_error();
307 } 308 }
308 tester_->OnExperimentCompleted(result); 309 tester_->OnExperimentCompleted(result);
309 } 310 }
310 311
311 void ConnectionTester::TestRunner::Run(const Experiment& experiment) { 312 void ConnectionTester::TestRunner::Run(const Experiment& experiment) {
312 // Try to create a URLRequestContext for this experiment. 313 // Try to create a net::URLRequestContext for this experiment.
313 scoped_refptr<ExperimentURLRequestContext> context( 314 scoped_refptr<ExperimentURLRequestContext> context(
314 new ExperimentURLRequestContext(tester_->proxy_request_context_)); 315 new ExperimentURLRequestContext(tester_->proxy_request_context_));
315 int rv = context->Init(experiment); 316 int rv = context->Init(experiment);
316 if (rv != net::OK) { 317 if (rv != net::OK) {
317 // Complete the experiment with a failure. 318 // Complete the experiment with a failure.
318 tester_->OnExperimentCompleted(rv); 319 tester_->OnExperimentCompleted(rv);
319 return; 320 return;
320 } 321 }
321 322
322 // Fetch a request using the experimental context. 323 // Fetch a request using the experimental context.
323 request_.reset(new net::URLRequest(experiment.url, this)); 324 request_.reset(new net::URLRequest(experiment.url, this));
324 request_->set_context(context); 325 request_->set_context(context);
325 request_->Start(); 326 request_->Start();
326 } 327 }
327 328
328 // ConnectionTester ---------------------------------------------------------- 329 // ConnectionTester ----------------------------------------------------------
329 330
330 ConnectionTester::ConnectionTester(Delegate* delegate, 331 ConnectionTester::ConnectionTester(
331 URLRequestContext* proxy_request_context) 332 Delegate* delegate,
333 net::URLRequestContext* proxy_request_context)
332 : delegate_(delegate), proxy_request_context_(proxy_request_context) { 334 : delegate_(delegate), proxy_request_context_(proxy_request_context) {
333 DCHECK(delegate); 335 DCHECK(delegate);
334 DCHECK(proxy_request_context); 336 DCHECK(proxy_request_context);
335 } 337 }
336 338
337 ConnectionTester::~ConnectionTester() { 339 ConnectionTester::~ConnectionTester() {
338 // Cancellation happens automatically by deleting test_runner_. 340 // Cancellation happens automatically by deleting test_runner_.
339 } 341 }
340 342
341 void ConnectionTester::RunAllTests(const GURL& url) { 343 void ConnectionTester::RunAllTests(const GURL& url) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 424
423 // Notify the delegate of completion. 425 // Notify the delegate of completion.
424 delegate_->OnCompletedConnectionTestExperiment(current, result); 426 delegate_->OnCompletedConnectionTestExperiment(current, result);
425 427
426 if (remaining_experiments_.empty()) { 428 if (remaining_experiments_.empty()) {
427 delegate_->OnCompletedConnectionTestSuite(); 429 delegate_->OnCompletedConnectionTestSuite();
428 } else { 430 } else {
429 StartNextExperiment(); 431 StartNextExperiment();
430 } 432 }
431 } 433 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698