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 "net/http/http_cache_transaction.h" | 5 #include "net/http/http_cache_transaction.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #if defined(OS_POSIX) | 9 #if defined(OS_POSIX) |
10 #include <unistd.h> | 10 #include <unistd.h> |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
434 return ERR_UNEXPECTED; | 434 return ERR_UNEXPECTED; |
435 | 435 |
436 SetRequest(net_log, request); | 436 SetRequest(net_log, request); |
437 | 437 |
438 // We have to wait until the backend is initialized so we start the SM. | 438 // We have to wait until the backend is initialized so we start the SM. |
439 next_state_ = STATE_GET_BACKEND; | 439 next_state_ = STATE_GET_BACKEND; |
440 int rv = DoLoop(OK); | 440 int rv = DoLoop(OK); |
441 | 441 |
442 // Setting this here allows us to check for the existence of a callback_ to | 442 // Setting this here allows us to check for the existence of a callback_ to |
443 // determine if we are still inside Start. | 443 // determine if we are still inside Start. |
444 if (rv == ERR_IO_PENDING) | 444 if (rv == ERR_IO_PENDING) |
gavinp
2014/12/03 01:17:13
You need curly braces here now, see http://google-
vadimt
2014/12/03 01:41:53
Done.
| |
445 callback_ = callback; | 445 callback_ = tracked_objects::ScopedTracker::TrackCallback( |
446 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
447 "422516 HttpCache::Transaction::Start"), | |
448 callback); | |
446 | 449 |
447 return rv; | 450 return rv; |
448 } | 451 } |
449 | 452 |
450 int HttpCache::Transaction::RestartIgnoringLastError( | 453 int HttpCache::Transaction::RestartIgnoringLastError( |
451 const CompletionCallback& callback) { | 454 const CompletionCallback& callback) { |
452 DCHECK(!callback.is_null()); | 455 DCHECK(!callback.is_null()); |
453 | 456 |
454 // Ensure that we only have one asynchronous call at a time. | 457 // Ensure that we only have one asynchronous call at a time. |
455 DCHECK(callback_.is_null()); | 458 DCHECK(callback_.is_null()); |
456 | 459 |
457 if (!cache_.get()) | 460 if (!cache_.get()) |
458 return ERR_UNEXPECTED; | 461 return ERR_UNEXPECTED; |
459 | 462 |
460 int rv = RestartNetworkRequest(); | 463 int rv = RestartNetworkRequest(); |
461 | 464 |
462 if (rv == ERR_IO_PENDING) | 465 if (rv == ERR_IO_PENDING) |
463 callback_ = callback; | 466 callback_ = tracked_objects::ScopedTracker::TrackCallback( |
467 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
468 "422516 HttpCache::Transaction::RestartIgnoringLastError"), | |
469 callback); | |
464 | 470 |
465 return rv; | 471 return rv; |
466 } | 472 } |
467 | 473 |
468 int HttpCache::Transaction::RestartWithCertificate( | 474 int HttpCache::Transaction::RestartWithCertificate( |
469 X509Certificate* client_cert, | 475 X509Certificate* client_cert, |
470 const CompletionCallback& callback) { | 476 const CompletionCallback& callback) { |
471 DCHECK(!callback.is_null()); | 477 DCHECK(!callback.is_null()); |
472 | 478 |
473 // Ensure that we only have one asynchronous call at a time. | 479 // Ensure that we only have one asynchronous call at a time. |
474 DCHECK(callback_.is_null()); | 480 DCHECK(callback_.is_null()); |
475 | 481 |
476 if (!cache_.get()) | 482 if (!cache_.get()) |
477 return ERR_UNEXPECTED; | 483 return ERR_UNEXPECTED; |
478 | 484 |
479 int rv = RestartNetworkRequestWithCertificate(client_cert); | 485 int rv = RestartNetworkRequestWithCertificate(client_cert); |
480 | 486 |
481 if (rv == ERR_IO_PENDING) | 487 if (rv == ERR_IO_PENDING) |
482 callback_ = callback; | 488 callback_ = tracked_objects::ScopedTracker::TrackCallback( |
489 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
490 "422516 HttpCache::Transaction::RestartWithCertificate"), | |
491 callback); | |
483 | 492 |
484 return rv; | 493 return rv; |
485 } | 494 } |
486 | 495 |
487 int HttpCache::Transaction::RestartWithAuth( | 496 int HttpCache::Transaction::RestartWithAuth( |
488 const AuthCredentials& credentials, | 497 const AuthCredentials& credentials, |
489 const CompletionCallback& callback) { | 498 const CompletionCallback& callback) { |
490 DCHECK(auth_response_.headers.get()); | 499 DCHECK(auth_response_.headers.get()); |
491 DCHECK(!callback.is_null()); | 500 DCHECK(!callback.is_null()); |
492 | 501 |
493 // Ensure that we only have one asynchronous call at a time. | 502 // Ensure that we only have one asynchronous call at a time. |
494 DCHECK(callback_.is_null()); | 503 DCHECK(callback_.is_null()); |
495 | 504 |
496 if (!cache_.get()) | 505 if (!cache_.get()) |
497 return ERR_UNEXPECTED; | 506 return ERR_UNEXPECTED; |
498 | 507 |
499 // Clear the intermediate response since we are going to start over. | 508 // Clear the intermediate response since we are going to start over. |
500 auth_response_ = HttpResponseInfo(); | 509 auth_response_ = HttpResponseInfo(); |
501 | 510 |
502 int rv = RestartNetworkRequestWithAuth(credentials); | 511 int rv = RestartNetworkRequestWithAuth(credentials); |
503 | 512 |
504 if (rv == ERR_IO_PENDING) | 513 if (rv == ERR_IO_PENDING) |
505 callback_ = callback; | 514 callback_ = tracked_objects::ScopedTracker::TrackCallback( |
515 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
516 "422516 HttpCache::Transaction::RestartWithAuth"), | |
517 callback); | |
506 | 518 |
507 return rv; | 519 return rv; |
508 } | 520 } |
509 | 521 |
510 bool HttpCache::Transaction::IsReadyToRestartForAuth() { | 522 bool HttpCache::Transaction::IsReadyToRestartForAuth() { |
511 if (!network_trans_.get()) | 523 if (!network_trans_.get()) |
512 return false; | 524 return false; |
513 return network_trans_->IsReadyToRestartForAuth(); | 525 return network_trans_->IsReadyToRestartForAuth(); |
514 } | 526 } |
515 | 527 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
553 case READ: | 565 case READ: |
554 rv = ReadFromEntry(buf, buf_len); | 566 rv = ReadFromEntry(buf, buf_len); |
555 break; | 567 break; |
556 default: | 568 default: |
557 NOTREACHED(); | 569 NOTREACHED(); |
558 rv = ERR_FAILED; | 570 rv = ERR_FAILED; |
559 } | 571 } |
560 | 572 |
561 if (rv == ERR_IO_PENDING) { | 573 if (rv == ERR_IO_PENDING) { |
562 DCHECK(callback_.is_null()); | 574 DCHECK(callback_.is_null()); |
563 callback_ = callback; | 575 callback_ = tracked_objects::ScopedTracker::TrackCallback( |
576 FROM_HERE_WITH_EXPLICIT_FUNCTION("422516 HttpCache::Transaction::Read"), | |
577 callback); | |
564 } | 578 } |
565 return rv; | 579 return rv; |
566 } | 580 } |
567 | 581 |
568 void HttpCache::Transaction::StopCaching() { | 582 void HttpCache::Transaction::StopCaching() { |
569 // We really don't know where we are now. Hopefully there is no operation in | 583 // We really don't know where we are now. Hopefully there is no operation in |
570 // progress, but nothing really prevents this method to be called after we | 584 // progress, but nothing really prevents this method to be called after we |
571 // returned ERR_IO_PENDING. We cannot attempt to truncate the entry at this | 585 // returned ERR_IO_PENDING. We cannot attempt to truncate the entry at this |
572 // point because we need the state machine for that (and even if we are really | 586 // point because we need the state machine for that (and even if we are really |
573 // free, that would be an asynchronous operation). In other words, keep the | 587 // free, that would be an asynchronous operation). In other words, keep the |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
692 | 706 |
693 int HttpCache::Transaction::ResumeNetworkStart() { | 707 int HttpCache::Transaction::ResumeNetworkStart() { |
694 if (network_trans_) | 708 if (network_trans_) |
695 return network_trans_->ResumeNetworkStart(); | 709 return network_trans_->ResumeNetworkStart(); |
696 return ERR_UNEXPECTED; | 710 return ERR_UNEXPECTED; |
697 } | 711 } |
698 | 712 |
699 //----------------------------------------------------------------------------- | 713 //----------------------------------------------------------------------------- |
700 | 714 |
701 void HttpCache::Transaction::DoCallback(int rv) { | 715 void HttpCache::Transaction::DoCallback(int rv) { |
716 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | |
717 tracked_objects::ScopedTracker tracking_profile( | |
718 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
719 "422516 HttpCache::Transaction::DoCallback")); | |
720 | |
702 DCHECK(rv != ERR_IO_PENDING); | 721 DCHECK(rv != ERR_IO_PENDING); |
703 DCHECK(!callback_.is_null()); | 722 DCHECK(!callback_.is_null()); |
704 | 723 |
705 read_buf_ = NULL; // Release the buffer before invoking the callback. | 724 read_buf_ = NULL; // Release the buffer before invoking the callback. |
706 | 725 |
707 // Since Run may result in Read being called, clear callback_ up front. | 726 // Since Run may result in Read being called, clear callback_ up front. |
708 CompletionCallback c = callback_; | 727 CompletionCallback c = callback_; |
709 callback_.Reset(); | 728 callback_.Reset(); |
710 c.Run(rv); | 729 c.Run(rv); |
711 } | 730 } |
(...skipping 2216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2928 | 2947 |
2929 void HttpCache::Transaction::OnIOComplete(int result) { | 2948 void HttpCache::Transaction::OnIOComplete(int result) { |
2930 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. | 2949 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. |
2931 tracked_objects::ScopedTracker tracking_profile( | 2950 tracked_objects::ScopedTracker tracking_profile( |
2932 FROM_HERE_WITH_EXPLICIT_FUNCTION("422516 Transaction::OnIOComplete")); | 2951 FROM_HERE_WITH_EXPLICIT_FUNCTION("422516 Transaction::OnIOComplete")); |
2933 | 2952 |
2934 DoLoop(result); | 2953 DoLoop(result); |
2935 } | 2954 } |
2936 | 2955 |
2937 } // namespace net | 2956 } // namespace net |
OLD | NEW |