Chromium Code Reviews| 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" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/profiler/scoped_tracker.h" | |
| 13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
| 15 #include "base/threading/thread_restrictions.h" | 16 #include "base/threading/thread_restrictions.h" |
| 16 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 17 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 18 #include "content/public/browser/cookie_store_factory.h" | 19 #include "content/public/browser/cookie_store_factory.h" |
| 19 #include "net/base/io_buffer.h" | 20 #include "net/base/io_buffer.h" |
| 20 #include "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" |
| 21 #include "net/base/net_util.h" | 22 #include "net/base/net_util.h" |
| 22 #include "net/base/request_priority.h" | 23 #include "net/base/request_priority.h" |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 336 scoped_ptr<ExperimentURLRequestContext> request_context_; | 337 scoped_ptr<ExperimentURLRequestContext> request_context_; |
| 337 scoped_ptr<net::URLRequest> request_; | 338 scoped_ptr<net::URLRequest> request_; |
| 338 net::NetLog* net_log_; | 339 net::NetLog* net_log_; |
| 339 | 340 |
| 340 base::WeakPtrFactory<TestRunner> weak_factory_; | 341 base::WeakPtrFactory<TestRunner> weak_factory_; |
| 341 | 342 |
| 342 DISALLOW_COPY_AND_ASSIGN(TestRunner); | 343 DISALLOW_COPY_AND_ASSIGN(TestRunner); |
| 343 }; | 344 }; |
| 344 | 345 |
| 345 void ConnectionTester::TestRunner::OnResponseStarted(net::URLRequest* request) { | 346 void ConnectionTester::TestRunner::OnResponseStarted(net::URLRequest* request) { |
| 347 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
| 348 tracked_objects::ScopedTracker tracking_profile( | |
| 349 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 350 "422516 ConnectionTester::TestRunner::OnResponseStarted")); | |
| 351 | |
| 346 if (!request->status().is_success()) { | 352 if (!request->status().is_success()) { |
| 347 OnResponseCompleted(request); | 353 OnResponseCompleted(request); |
| 348 return; | 354 return; |
| 349 } | 355 } |
| 350 | 356 |
| 351 // Start reading the body. | 357 // Start reading the body. |
| 352 ReadBody(request); | 358 ReadBody(request); |
| 353 } | 359 } |
| 354 | 360 |
| 355 void ConnectionTester::TestRunner::OnReadCompleted(net::URLRequest* request, | 361 void ConnectionTester::TestRunner::OnReadCompleted(net::URLRequest* request, |
| 356 int bytes_read) { | 362 int bytes_read) { |
| 363 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
| 364 tracked_objects::ScopedTracker tracking_profile( | |
| 365 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 366 "422516 ConnectionTester::TestRunner::OnReadCompleted")); | |
|
mmenke
2014/11/17 15:38:16
This file is not worth instrumenting. It's only u
vadimt
2014/11/18 01:14:27
Done.
| |
| 367 | |
| 357 if (bytes_read <= 0) { | 368 if (bytes_read <= 0) { |
| 358 OnResponseCompleted(request); | 369 OnResponseCompleted(request); |
| 359 return; | 370 return; |
| 360 } | 371 } |
| 361 | 372 |
| 362 // Keep reading until the stream is closed. Throw the data read away. | 373 // Keep reading until the stream is closed. Throw the data read away. |
| 363 ReadBody(request); | 374 ReadBody(request); |
| 364 } | 375 } |
| 365 | 376 |
| 366 void ConnectionTester::TestRunner::ReadBody(net::URLRequest* request) { | 377 void ConnectionTester::TestRunner::ReadBody(net::URLRequest* request) { |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 533 | 544 |
| 534 // Notify the delegate of completion. | 545 // Notify the delegate of completion. |
| 535 delegate_->OnCompletedConnectionTestExperiment(current, result); | 546 delegate_->OnCompletedConnectionTestExperiment(current, result); |
| 536 | 547 |
| 537 if (remaining_experiments_.empty()) { | 548 if (remaining_experiments_.empty()) { |
| 538 delegate_->OnCompletedConnectionTestSuite(); | 549 delegate_->OnCompletedConnectionTestSuite(); |
| 539 } else { | 550 } else { |
| 540 StartNextExperiment(); | 551 StartNextExperiment(); |
| 541 } | 552 } |
| 542 } | 553 } |
| OLD | NEW |