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

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

Issue 4192012: Convert implicit scoped_refptr constructor calls to explicit ones, part 1 (Closed) Base URL: http://git.chromium.org/git/chromium.git
Patch Set: fix presubmit Created 10 years, 1 month 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) 2010 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"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 OnResponseCompleted(request); 270 OnResponseCompleted(request);
271 return; 271 return;
272 } 272 }
273 273
274 // Keep reading until the stream is closed. Throw the data read away. 274 // Keep reading until the stream is closed. Throw the data read away.
275 ReadBody(request); 275 ReadBody(request);
276 } 276 }
277 277
278 void ConnectionTester::TestRunner::ReadBody(URLRequest* request) { 278 void ConnectionTester::TestRunner::ReadBody(URLRequest* request) {
279 // Read the response body |kReadBufferSize| bytes at a time. 279 // Read the response body |kReadBufferSize| bytes at a time.
280 scoped_refptr<net::IOBuffer> unused_buffer = 280 scoped_refptr<net::IOBuffer> unused_buffer(
281 new net::IOBuffer(kReadBufferSize); 281 new net::IOBuffer(kReadBufferSize));
282 int num_bytes; 282 int num_bytes;
283 if (request->Read(unused_buffer, kReadBufferSize, &num_bytes)) { 283 if (request->Read(unused_buffer, kReadBufferSize, &num_bytes)) {
284 OnReadCompleted(request, num_bytes); 284 OnReadCompleted(request, num_bytes);
285 } else if (!request->status().is_io_pending()) { 285 } else if (!request->status().is_io_pending()) {
286 // Read failed synchronously. 286 // Read failed synchronously.
287 OnResponseCompleted(request); 287 OnResponseCompleted(request);
288 } 288 }
289 } 289 }
290 290
291 void ConnectionTester::TestRunner::OnResponseCompleted(URLRequest* request) { 291 void ConnectionTester::TestRunner::OnResponseCompleted(URLRequest* request) {
292 int result = net::OK; 292 int result = net::OK;
293 if (!request->status().is_success()) { 293 if (!request->status().is_success()) {
294 DCHECK_NE(net::ERR_IO_PENDING, request->status().os_error()); 294 DCHECK_NE(net::ERR_IO_PENDING, request->status().os_error());
295 result = request->status().os_error(); 295 result = request->status().os_error();
296 } 296 }
297 tester_->OnExperimentCompleted(result); 297 tester_->OnExperimentCompleted(result);
298 } 298 }
299 299
300 void ConnectionTester::TestRunner::Run(const Experiment& experiment) { 300 void ConnectionTester::TestRunner::Run(const Experiment& experiment) {
301 // Try to create a URLRequestContext for this experiment. 301 // Try to create a URLRequestContext for this experiment.
302 scoped_refptr<ExperimentURLRequestContext> context = 302 scoped_refptr<ExperimentURLRequestContext> context(
303 new ExperimentURLRequestContext(tester_->io_thread_); 303 new ExperimentURLRequestContext(tester_->io_thread_));
304 int rv = context->Init(experiment); 304 int rv = context->Init(experiment);
305 if (rv != net::OK) { 305 if (rv != net::OK) {
306 // Complete the experiment with a failure. 306 // Complete the experiment with a failure.
307 tester_->OnExperimentCompleted(rv); 307 tester_->OnExperimentCompleted(rv);
308 return; 308 return;
309 } 309 }
310 310
311 // Fetch a request using the experimental context. 311 // Fetch a request using the experimental context.
312 request_.reset(new URLRequest(experiment.url, this)); 312 request_.reset(new URLRequest(experiment.url, this));
313 request_->set_context(context); 313 request_->set_context(context);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 410
411 // Notify the delegate of completion. 411 // Notify the delegate of completion.
412 delegate_->OnCompletedConnectionTestExperiment(current, result); 412 delegate_->OnCompletedConnectionTestExperiment(current, result);
413 413
414 if (remaining_experiments_.empty()) { 414 if (remaining_experiments_.empty()) {
415 delegate_->OnCompletedConnectionTestSuite(); 415 delegate_->OnCompletedConnectionTestSuite();
416 } else { 416 } else {
417 StartNextExperiment(); 417 StartNextExperiment();
418 } 418 }
419 } 419 }
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_service.cc ('k') | chrome/browser/net/connection_tester_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698