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

Side by Side Diff: net/http/http_cache_transaction.cc

Issue 773373002: Update from https://crrev.com/306706 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 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
« no previous file with comments | « net/http/disk_cache_based_quic_server_info.cc ('k') | net/net.gyp » ('j') | 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) 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
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) {
445 callback_ = callback; 445 callback_ = tracked_objects::ScopedTracker::TrackCallback(
446 FROM_HERE_WITH_EXPLICIT_FUNCTION(
447 "422516 HttpCache::Transaction::Start"),
448 callback);
449 }
446 450
447 return rv; 451 return rv;
448 } 452 }
449 453
450 int HttpCache::Transaction::RestartIgnoringLastError( 454 int HttpCache::Transaction::RestartIgnoringLastError(
451 const CompletionCallback& callback) { 455 const CompletionCallback& callback) {
452 DCHECK(!callback.is_null()); 456 DCHECK(!callback.is_null());
453 457
454 // Ensure that we only have one asynchronous call at a time. 458 // Ensure that we only have one asynchronous call at a time.
455 DCHECK(callback_.is_null()); 459 DCHECK(callback_.is_null());
456 460
457 if (!cache_.get()) 461 if (!cache_.get())
458 return ERR_UNEXPECTED; 462 return ERR_UNEXPECTED;
459 463
460 int rv = RestartNetworkRequest(); 464 int rv = RestartNetworkRequest();
461 465
462 if (rv == ERR_IO_PENDING) 466 if (rv == ERR_IO_PENDING) {
463 callback_ = callback; 467 callback_ = tracked_objects::ScopedTracker::TrackCallback(
468 FROM_HERE_WITH_EXPLICIT_FUNCTION(
469 "422516 HttpCache::Transaction::RestartIgnoringLastError"),
470 callback);
471 }
464 472
465 return rv; 473 return rv;
466 } 474 }
467 475
468 int HttpCache::Transaction::RestartWithCertificate( 476 int HttpCache::Transaction::RestartWithCertificate(
469 X509Certificate* client_cert, 477 X509Certificate* client_cert,
470 const CompletionCallback& callback) { 478 const CompletionCallback& callback) {
471 DCHECK(!callback.is_null()); 479 DCHECK(!callback.is_null());
472 480
473 // Ensure that we only have one asynchronous call at a time. 481 // Ensure that we only have one asynchronous call at a time.
474 DCHECK(callback_.is_null()); 482 DCHECK(callback_.is_null());
475 483
476 if (!cache_.get()) 484 if (!cache_.get())
477 return ERR_UNEXPECTED; 485 return ERR_UNEXPECTED;
478 486
479 int rv = RestartNetworkRequestWithCertificate(client_cert); 487 int rv = RestartNetworkRequestWithCertificate(client_cert);
480 488
481 if (rv == ERR_IO_PENDING) 489 if (rv == ERR_IO_PENDING) {
482 callback_ = callback; 490 callback_ = tracked_objects::ScopedTracker::TrackCallback(
491 FROM_HERE_WITH_EXPLICIT_FUNCTION(
492 "422516 HttpCache::Transaction::RestartWithCertificate"),
493 callback);
494 }
483 495
484 return rv; 496 return rv;
485 } 497 }
486 498
487 int HttpCache::Transaction::RestartWithAuth( 499 int HttpCache::Transaction::RestartWithAuth(
488 const AuthCredentials& credentials, 500 const AuthCredentials& credentials,
489 const CompletionCallback& callback) { 501 const CompletionCallback& callback) {
490 DCHECK(auth_response_.headers.get()); 502 DCHECK(auth_response_.headers.get());
491 DCHECK(!callback.is_null()); 503 DCHECK(!callback.is_null());
492 504
493 // Ensure that we only have one asynchronous call at a time. 505 // Ensure that we only have one asynchronous call at a time.
494 DCHECK(callback_.is_null()); 506 DCHECK(callback_.is_null());
495 507
496 if (!cache_.get()) 508 if (!cache_.get())
497 return ERR_UNEXPECTED; 509 return ERR_UNEXPECTED;
498 510
499 // Clear the intermediate response since we are going to start over. 511 // Clear the intermediate response since we are going to start over.
500 auth_response_ = HttpResponseInfo(); 512 auth_response_ = HttpResponseInfo();
501 513
502 int rv = RestartNetworkRequestWithAuth(credentials); 514 int rv = RestartNetworkRequestWithAuth(credentials);
503 515
504 if (rv == ERR_IO_PENDING) 516 if (rv == ERR_IO_PENDING) {
505 callback_ = callback; 517 callback_ = tracked_objects::ScopedTracker::TrackCallback(
518 FROM_HERE_WITH_EXPLICIT_FUNCTION(
519 "422516 HttpCache::Transaction::RestartWithAuth"),
520 callback);
521 }
506 522
507 return rv; 523 return rv;
508 } 524 }
509 525
510 bool HttpCache::Transaction::IsReadyToRestartForAuth() { 526 bool HttpCache::Transaction::IsReadyToRestartForAuth() {
511 if (!network_trans_.get()) 527 if (!network_trans_.get())
512 return false; 528 return false;
513 return network_trans_->IsReadyToRestartForAuth(); 529 return network_trans_->IsReadyToRestartForAuth();
514 } 530 }
515 531
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 case READ: 569 case READ:
554 rv = ReadFromEntry(buf, buf_len); 570 rv = ReadFromEntry(buf, buf_len);
555 break; 571 break;
556 default: 572 default:
557 NOTREACHED(); 573 NOTREACHED();
558 rv = ERR_FAILED; 574 rv = ERR_FAILED;
559 } 575 }
560 576
561 if (rv == ERR_IO_PENDING) { 577 if (rv == ERR_IO_PENDING) {
562 DCHECK(callback_.is_null()); 578 DCHECK(callback_.is_null());
563 callback_ = callback; 579 callback_ = tracked_objects::ScopedTracker::TrackCallback(
580 FROM_HERE_WITH_EXPLICIT_FUNCTION("422516 HttpCache::Transaction::Read"),
581 callback);
564 } 582 }
565 return rv; 583 return rv;
566 } 584 }
567 585
568 void HttpCache::Transaction::StopCaching() { 586 void HttpCache::Transaction::StopCaching() {
569 // We really don't know where we are now. Hopefully there is no operation in 587 // 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 588 // 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 589 // 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 590 // 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 591 // free, that would be an asynchronous operation). In other words, keep the
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 710
693 int HttpCache::Transaction::ResumeNetworkStart() { 711 int HttpCache::Transaction::ResumeNetworkStart() {
694 if (network_trans_) 712 if (network_trans_)
695 return network_trans_->ResumeNetworkStart(); 713 return network_trans_->ResumeNetworkStart();
696 return ERR_UNEXPECTED; 714 return ERR_UNEXPECTED;
697 } 715 }
698 716
699 //----------------------------------------------------------------------------- 717 //-----------------------------------------------------------------------------
700 718
701 void HttpCache::Transaction::DoCallback(int rv) { 719 void HttpCache::Transaction::DoCallback(int rv) {
720 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed.
721 tracked_objects::ScopedTracker tracking_profile(
722 FROM_HERE_WITH_EXPLICIT_FUNCTION(
723 "422516 HttpCache::Transaction::DoCallback"));
724
702 DCHECK(rv != ERR_IO_PENDING); 725 DCHECK(rv != ERR_IO_PENDING);
703 DCHECK(!callback_.is_null()); 726 DCHECK(!callback_.is_null());
704 727
705 read_buf_ = NULL; // Release the buffer before invoking the callback. 728 read_buf_ = NULL; // Release the buffer before invoking the callback.
706 729
707 // Since Run may result in Read being called, clear callback_ up front. 730 // Since Run may result in Read being called, clear callback_ up front.
708 CompletionCallback c = callback_; 731 CompletionCallback c = callback_;
709 callback_.Reset(); 732 callback_.Reset();
710 c.Run(rv); 733 c.Run(rv);
711 } 734 }
(...skipping 2217 matching lines...) Expand 10 before | Expand all | Expand 10 after
2929 2952
2930 void HttpCache::Transaction::OnIOComplete(int result) { 2953 void HttpCache::Transaction::OnIOComplete(int result) {
2931 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed. 2954 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed.
2932 tracked_objects::ScopedTracker tracking_profile( 2955 tracked_objects::ScopedTracker tracking_profile(
2933 FROM_HERE_WITH_EXPLICIT_FUNCTION("422516 Transaction::OnIOComplete")); 2956 FROM_HERE_WITH_EXPLICIT_FUNCTION("422516 Transaction::OnIOComplete"));
2934 2957
2935 DoLoop(result); 2958 DoLoop(result);
2936 } 2959 }
2937 2960
2938 } // namespace net 2961 } // namespace net
OLDNEW
« no previous file with comments | « net/http/disk_cache_based_quic_server_info.cc ('k') | net/net.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698