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

Side by Side Diff: net/url_request/url_request_http_job.cc

Issue 5556004: Fix URLRequestHttpJob to use ScopedRunnableMethodFactory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years 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
« no previous file with comments | « net/url_request/url_request_http_job.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "net/url_request/url_request_http_job.h" 5 #include "net/url_request/url_request_http_job.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.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/file_util.h" 10 #include "base/file_util.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 this, &URLRequestHttpJob::OnStartCompleted)), 91 this, &URLRequestHttpJob::OnStartCompleted)),
92 ALLOW_THIS_IN_INITIALIZER_LIST(read_callback_( 92 ALLOW_THIS_IN_INITIALIZER_LIST(read_callback_(
93 this, &URLRequestHttpJob::OnReadCompleted)), 93 this, &URLRequestHttpJob::OnReadCompleted)),
94 read_in_progress_(false), 94 read_in_progress_(false),
95 transaction_(NULL), 95 transaction_(NULL),
96 throttling_entry_(net::URLRequestThrottlerManager::GetInstance()-> 96 throttling_entry_(net::URLRequestThrottlerManager::GetInstance()->
97 RegisterRequestUrl(request->url())), 97 RegisterRequestUrl(request->url())),
98 sdch_dictionary_advertised_(false), 98 sdch_dictionary_advertised_(false),
99 sdch_test_activated_(false), 99 sdch_test_activated_(false),
100 sdch_test_control_(false), 100 sdch_test_control_(false),
101 is_cached_content_(false) { 101 is_cached_content_(false),
102 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
102 } 103 }
103 104
104 URLRequestHttpJob::~URLRequestHttpJob() { 105 URLRequestHttpJob::~URLRequestHttpJob() {
105 DCHECK(!sdch_test_control_ || !sdch_test_activated_); 106 DCHECK(!sdch_test_control_ || !sdch_test_activated_);
106 if (!IsCachedContent()) { 107 if (!IsCachedContent()) {
107 if (sdch_test_control_) 108 if (sdch_test_control_)
108 RecordPacketStats(SDCH_EXPERIMENT_HOLDBACK); 109 RecordPacketStats(SDCH_EXPERIMENT_HOLDBACK);
109 if (sdch_test_activated_) 110 if (sdch_test_activated_)
110 RecordPacketStats(SDCH_EXPERIMENT_DECODE); 111 RecordPacketStats(SDCH_EXPERIMENT_DECODE);
111 } 112 }
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 response_cookies_.clear(); 363 response_cookies_.clear();
363 364
364 // OK, let the consumer read the error page... 365 // OK, let the consumer read the error page...
365 // 366 //
366 // Because we set the AUTH_STATE_CANCELED flag, NeedsAuth will return false, 367 // Because we set the AUTH_STATE_CANCELED flag, NeedsAuth will return false,
367 // which will cause the consumer to receive OnResponseStarted instead of 368 // which will cause the consumer to receive OnResponseStarted instead of
368 // OnAuthRequired. 369 // OnAuthRequired.
369 // 370 //
370 // We have to do this via InvokeLater to avoid "recursing" the consumer. 371 // We have to do this via InvokeLater to avoid "recursing" the consumer.
371 // 372 //
372 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( 373 MessageLoop::current()->PostTask(
373 this, &URLRequestHttpJob::OnStartCompleted, net::OK)); 374 FROM_HERE,
375 method_factory_.NewRunnableMethod(
376 &URLRequestHttpJob::OnStartCompleted, net::OK));
eroman 2010/12/03 06:03:19 nit: indent by 4
374 } 377 }
375 378
376 void URLRequestHttpJob::ContinueWithCertificate( 379 void URLRequestHttpJob::ContinueWithCertificate(
377 net::X509Certificate* client_cert) { 380 net::X509Certificate* client_cert) {
378 DCHECK(transaction_.get()); 381 DCHECK(transaction_.get());
379 382
380 DCHECK(!response_info_) << "should not have a response yet"; 383 DCHECK(!response_info_) << "should not have a response yet";
381 384
382 // No matter what, we want to report our status as IO pending since we will 385 // No matter what, we want to report our status as IO pending since we will
383 // be notifying our consumer asynchronously via OnStartCompleted. 386 // be notifying our consumer asynchronously via OnStartCompleted.
384 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); 387 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0));
385 388
386 int rv = transaction_->RestartWithCertificate(client_cert, &start_callback_); 389 int rv = transaction_->RestartWithCertificate(client_cert, &start_callback_);
387 if (rv == net::ERR_IO_PENDING) 390 if (rv == net::ERR_IO_PENDING)
388 return; 391 return;
389 392
390 // The transaction started synchronously, but we need to notify the 393 // The transaction started synchronously, but we need to notify the
391 // net::URLRequest delegate via the message loop. 394 // net::URLRequest delegate via the message loop.
392 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( 395 MessageLoop::current()->PostTask(
393 this, &URLRequestHttpJob::OnStartCompleted, rv)); 396 FROM_HERE,
397 method_factory_.NewRunnableMethod(
398 &URLRequestHttpJob::OnStartCompleted, rv));
394 } 399 }
395 400
396 void URLRequestHttpJob::ContinueDespiteLastError() { 401 void URLRequestHttpJob::ContinueDespiteLastError() {
397 // If the transaction was destroyed, then the job was cancelled. 402 // If the transaction was destroyed, then the job was cancelled.
398 if (!transaction_.get()) 403 if (!transaction_.get())
399 return; 404 return;
400 405
401 DCHECK(!response_info_) << "should not have a response yet"; 406 DCHECK(!response_info_) << "should not have a response yet";
402 407
403 // No matter what, we want to report our status as IO pending since we will 408 // No matter what, we want to report our status as IO pending since we will
404 // be notifying our consumer asynchronously via OnStartCompleted. 409 // be notifying our consumer asynchronously via OnStartCompleted.
405 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0)); 410 SetStatus(URLRequestStatus(URLRequestStatus::IO_PENDING, 0));
406 411
407 int rv = transaction_->RestartIgnoringLastError(&start_callback_); 412 int rv = transaction_->RestartIgnoringLastError(&start_callback_);
408 if (rv == net::ERR_IO_PENDING) 413 if (rv == net::ERR_IO_PENDING)
409 return; 414 return;
410 415
411 // The transaction started synchronously, but we need to notify the 416 // The transaction started synchronously, but we need to notify the
412 // net::URLRequest delegate via the message loop. 417 // net::URLRequest delegate via the message loop.
413 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( 418 MessageLoop::current()->PostTask(
414 this, &URLRequestHttpJob::OnStartCompleted, rv)); 419 FROM_HERE,
420 method_factory_.NewRunnableMethod(
421 &URLRequestHttpJob::OnStartCompleted, rv));
415 } 422 }
416 423
417 bool URLRequestHttpJob::ReadRawData(net::IOBuffer* buf, int buf_size, 424 bool URLRequestHttpJob::ReadRawData(net::IOBuffer* buf, int buf_size,
418 int *bytes_read) { 425 int *bytes_read) {
419 DCHECK_NE(buf_size, 0); 426 DCHECK_NE(buf_size, 0);
420 DCHECK(bytes_read); 427 DCHECK(bytes_read);
421 DCHECK(!read_in_progress_); 428 DCHECK(!read_in_progress_);
422 429
423 int rv = transaction_->Read(buf, buf_size, &read_callback_); 430 int rv = transaction_->Read(buf, buf_size, &read_callback_);
424 if (rv >= 0) { 431 if (rv >= 0) {
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 // transaction. 660 // transaction.
654 context_ = request_->context(); 661 context_ = request_->context();
655 } 662 }
656 } 663 }
657 664
658 if (rv == net::ERR_IO_PENDING) 665 if (rv == net::ERR_IO_PENDING)
659 return; 666 return;
660 667
661 // The transaction started synchronously, but we need to notify the 668 // The transaction started synchronously, but we need to notify the
662 // net::URLRequest delegate via the message loop. 669 // net::URLRequest delegate via the message loop.
663 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( 670 MessageLoop::current()->PostTask(
664 this, &URLRequestHttpJob::OnStartCompleted, rv)); 671 FROM_HERE,
672 method_factory_.NewRunnableMethod(
673 &URLRequestHttpJob::OnStartCompleted, rv));
665 } 674 }
666 675
667 void URLRequestHttpJob::AddExtraHeaders() { 676 void URLRequestHttpJob::AddExtraHeaders() {
668 // TODO(jar): Consider optimizing away SDCH advertising bytes when the URL is 677 // TODO(jar): Consider optimizing away SDCH advertising bytes when the URL is
669 // probably an img or such (and SDCH encoding is not likely). 678 // probably an img or such (and SDCH encoding is not likely).
670 bool advertise_sdch = SdchManager::Global() && 679 bool advertise_sdch = SdchManager::Global() &&
671 SdchManager::Global()->IsInSupportedDomain(request_->url()); 680 SdchManager::Global()->IsInSupportedDomain(request_->url());
672 std::string avail_dictionaries; 681 std::string avail_dictionaries;
673 if (advertise_sdch) { 682 if (advertise_sdch) {
674 SdchManager::Global()->GetAvailDictionaryList(request_->url(), 683 SdchManager::Global()->GetAvailDictionaryList(request_->url(),
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 HTTPSProberDelegate* delegate = 943 HTTPSProberDelegate* delegate =
935 new HTTPSProberDelegate(request_info_.url.host(), max_age, 944 new HTTPSProberDelegate(request_info_.url.host(), max_age,
936 include_subdomains, 945 include_subdomains,
937 ctx->transport_security_state()); 946 ctx->transport_security_state());
938 if (!prober->ProbeHost(request_info_.url.host(), request()->context(), 947 if (!prober->ProbeHost(request_info_.url.host(), request()->context(),
939 delegate)) { 948 delegate)) {
940 delete delegate; 949 delete delegate;
941 } 950 }
942 } 951 }
943 } 952 }
OLDNEW
« no previous file with comments | « net/url_request/url_request_http_job.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698