| 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/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/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 } else { | 1100 } else { |
| 1101 // Unknown encoding type. Pass through raw response body. | 1101 // Unknown encoding type. Pass through raw response body. |
| 1102 return upstream; | 1102 return upstream; |
| 1103 } | 1103 } |
| 1104 } | 1104 } |
| 1105 | 1105 |
| 1106 // Sdch specific hacks: | 1106 // Sdch specific hacks: |
| 1107 std::string mime_type; | 1107 std::string mime_type; |
| 1108 bool success = GetMimeType(&mime_type); | 1108 bool success = GetMimeType(&mime_type); |
| 1109 DCHECK(success || mime_type.empty()); | 1109 DCHECK(success || mime_type.empty()); |
| 1110 DCHECK(request()); | |
| 1111 SdchPolicyDelegate::FixUpSdchContentEncodings( | 1110 SdchPolicyDelegate::FixUpSdchContentEncodings( |
| 1112 request()->net_log(), mime_type, dictionaries_advertised_.get(), &types); | 1111 request()->net_log(), mime_type, dictionaries_advertised_.get(), &types); |
| 1113 | 1112 |
| 1114 for (std::vector<SourceStream::SourceType>::reverse_iterator r_iter = | 1113 for (std::vector<SourceStream::SourceType>::reverse_iterator r_iter = |
| 1115 types.rbegin(); | 1114 types.rbegin(); |
| 1116 r_iter != types.rend(); ++r_iter) { | 1115 r_iter != types.rend(); ++r_iter) { |
| 1117 std::unique_ptr<FilterSourceStream> downstream; | 1116 std::unique_ptr<FilterSourceStream> downstream; |
| 1118 SourceStream::SourceType type = *r_iter; | 1117 SourceStream::SourceType type = *r_iter; |
| 1119 switch (type) { | 1118 switch (type) { |
| 1120 case SourceStream::TYPE_BROTLI: | 1119 case SourceStream::TYPE_BROTLI: |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1532 | 1531 |
| 1533 start_time_ = base::TimeTicks(); | 1532 start_time_ = base::TimeTicks(); |
| 1534 } | 1533 } |
| 1535 | 1534 |
| 1536 void URLRequestHttpJob::DoneWithRequest(CompletionCause reason) { | 1535 void URLRequestHttpJob::DoneWithRequest(CompletionCause reason) { |
| 1537 if (done_) | 1536 if (done_) |
| 1538 return; | 1537 return; |
| 1539 done_ = true; | 1538 done_ = true; |
| 1540 | 1539 |
| 1541 // Notify NetworkQualityEstimator. | 1540 // Notify NetworkQualityEstimator. |
| 1542 if (request()) { | 1541 NetworkQualityEstimator* network_quality_estimator = |
| 1543 NetworkQualityEstimator* network_quality_estimator = | 1542 request()->context()->network_quality_estimator(); |
| 1544 request()->context()->network_quality_estimator(); | 1543 if (network_quality_estimator) { |
| 1545 if (network_quality_estimator) | 1544 network_quality_estimator->NotifyRequestCompleted( |
| 1546 network_quality_estimator->NotifyRequestCompleted( | 1545 *request(), request_->status().error()); |
| 1547 *request(), request_->status().error()); | |
| 1548 } | 1546 } |
| 1549 | 1547 |
| 1550 RecordPerfHistograms(reason); | 1548 RecordPerfHistograms(reason); |
| 1551 if (request_) | 1549 request()->set_received_response_content_length(prefilter_bytes_read()); |
| 1552 request_->set_received_response_content_length(prefilter_bytes_read()); | |
| 1553 } | 1550 } |
| 1554 | 1551 |
| 1555 HttpResponseHeaders* URLRequestHttpJob::GetResponseHeaders() const { | 1552 HttpResponseHeaders* URLRequestHttpJob::GetResponseHeaders() const { |
| 1556 DCHECK(transaction_.get()); | 1553 DCHECK(transaction_.get()); |
| 1557 DCHECK(transaction_->GetResponseInfo()); | 1554 DCHECK(transaction_->GetResponseInfo()); |
| 1558 return override_response_headers_.get() ? | 1555 return override_response_headers_.get() ? |
| 1559 override_response_headers_.get() : | 1556 override_response_headers_.get() : |
| 1560 transaction_->GetResponseInfo()->headers.get(); | 1557 transaction_->GetResponseInfo()->headers.get(); |
| 1561 } | 1558 } |
| 1562 | 1559 |
| 1563 void URLRequestHttpJob::NotifyURLRequestDestroyed() { | 1560 void URLRequestHttpJob::NotifyURLRequestDestroyed() { |
| 1564 awaiting_callback_ = false; | 1561 awaiting_callback_ = false; |
| 1565 | 1562 |
| 1566 // Notify NetworkQualityEstimator. | 1563 // Notify NetworkQualityEstimator. |
| 1567 if (request()) { | 1564 NetworkQualityEstimator* network_quality_estimator = |
| 1568 NetworkQualityEstimator* network_quality_estimator = | 1565 request()->context()->network_quality_estimator(); |
| 1569 request()->context()->network_quality_estimator(); | 1566 if (network_quality_estimator) |
| 1570 if (network_quality_estimator) | 1567 network_quality_estimator->NotifyURLRequestDestroyed(*request()); |
| 1571 network_quality_estimator->NotifyURLRequestDestroyed(*request()); | |
| 1572 } | |
| 1573 } | 1568 } |
| 1574 | 1569 |
| 1575 } // namespace net | 1570 } // namespace net |
| OLD | NEW |