| 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 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 DCHECK(!network_trans_); | 644 DCHECK(!network_trans_); |
| 645 before_proxy_headers_sent_callback_ = callback; | 645 before_proxy_headers_sent_callback_ = callback; |
| 646 } | 646 } |
| 647 | 647 |
| 648 int HttpCache::Transaction::ResumeNetworkStart() { | 648 int HttpCache::Transaction::ResumeNetworkStart() { |
| 649 if (network_trans_) | 649 if (network_trans_) |
| 650 return network_trans_->ResumeNetworkStart(); | 650 return network_trans_->ResumeNetworkStart(); |
| 651 return ERR_UNEXPECTED; | 651 return ERR_UNEXPECTED; |
| 652 } | 652 } |
| 653 | 653 |
| 654 void HttpCache::Transaction::GetConnectionAttempts( |
| 655 ConnectionAttempts* out) const { |
| 656 ConnectionAttempts new_connection_attempts; |
| 657 if (network_trans_) |
| 658 network_trans_->GetConnectionAttempts(&new_connection_attempts); |
| 659 |
| 660 out->swap(new_connection_attempts); |
| 661 out->insert(out->begin(), old_connection_attempts_.begin(), |
| 662 old_connection_attempts_.end()); |
| 663 } |
| 664 |
| 654 //----------------------------------------------------------------------------- | 665 //----------------------------------------------------------------------------- |
| 655 | 666 |
| 656 void HttpCache::Transaction::DoCallback(int rv) { | 667 void HttpCache::Transaction::DoCallback(int rv) { |
| 657 DCHECK(rv != ERR_IO_PENDING); | 668 DCHECK(rv != ERR_IO_PENDING); |
| 658 DCHECK(!callback_.is_null()); | 669 DCHECK(!callback_.is_null()); |
| 659 | 670 |
| 660 read_buf_ = NULL; // Release the buffer before invoking the callback. | 671 read_buf_ = NULL; // Release the buffer before invoking the callback. |
| 661 | 672 |
| 662 // Since Run may result in Read being called, clear callback_ up front. | 673 // Since Run may result in Read being called, clear callback_ up front. |
| 663 CompletionCallback c = callback_; | 674 CompletionCallback c = callback_; |
| (...skipping 2173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2837 } | 2848 } |
| 2838 } | 2849 } |
| 2839 | 2850 |
| 2840 void HttpCache::Transaction::ResetNetworkTransaction() { | 2851 void HttpCache::Transaction::ResetNetworkTransaction() { |
| 2841 DCHECK(!old_network_trans_load_timing_); | 2852 DCHECK(!old_network_trans_load_timing_); |
| 2842 DCHECK(network_trans_); | 2853 DCHECK(network_trans_); |
| 2843 LoadTimingInfo load_timing; | 2854 LoadTimingInfo load_timing; |
| 2844 if (network_trans_->GetLoadTimingInfo(&load_timing)) | 2855 if (network_trans_->GetLoadTimingInfo(&load_timing)) |
| 2845 old_network_trans_load_timing_.reset(new LoadTimingInfo(load_timing)); | 2856 old_network_trans_load_timing_.reset(new LoadTimingInfo(load_timing)); |
| 2846 total_received_bytes_ += network_trans_->GetTotalReceivedBytes(); | 2857 total_received_bytes_ += network_trans_->GetTotalReceivedBytes(); |
| 2858 ConnectionAttempts attempts; |
| 2859 network_trans_->GetConnectionAttempts(&attempts); |
| 2860 for (const auto& attempt : attempts) |
| 2861 old_connection_attempts_.push_back(attempt); |
| 2847 network_trans_.reset(); | 2862 network_trans_.reset(); |
| 2848 } | 2863 } |
| 2849 | 2864 |
| 2850 // Histogram data from the end of 2010 show the following distribution of | 2865 // Histogram data from the end of 2010 show the following distribution of |
| 2851 // response headers: | 2866 // response headers: |
| 2852 // | 2867 // |
| 2853 // Content-Length............... 87% | 2868 // Content-Length............... 87% |
| 2854 // Date......................... 98% | 2869 // Date......................... 98% |
| 2855 // Last-Modified................ 49% | 2870 // Last-Modified................ 49% |
| 2856 // Etag......................... 19% | 2871 // Etag......................... 19% |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2964 default: | 2979 default: |
| 2965 NOTREACHED(); | 2980 NOTREACHED(); |
| 2966 } | 2981 } |
| 2967 } | 2982 } |
| 2968 | 2983 |
| 2969 void HttpCache::Transaction::OnIOComplete(int result) { | 2984 void HttpCache::Transaction::OnIOComplete(int result) { |
| 2970 DoLoop(result); | 2985 DoLoop(result); |
| 2971 } | 2986 } |
| 2972 | 2987 |
| 2973 } // namespace net | 2988 } // namespace net |
| OLD | NEW |