| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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_stream_factory_impl_job_controller.h" | 5 #include "net/http/http_stream_factory_impl_job_controller.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 net_log_.BeginEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER, | 100 net_log_.BeginEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER, |
| 101 base::Bind(&NetLogJobControllerCallback, | 101 base::Bind(&NetLogJobControllerCallback, |
| 102 &request_info.url, is_preconnect)); | 102 &request_info.url, is_preconnect)); |
| 103 } | 103 } |
| 104 | 104 |
| 105 HttpStreamFactoryImpl::JobController::~JobController() { | 105 HttpStreamFactoryImpl::JobController::~JobController() { |
| 106 main_job_.reset(); | 106 main_job_.reset(); |
| 107 alternative_job_.reset(); | 107 alternative_job_.reset(); |
| 108 bound_job_ = nullptr; | 108 bound_job_ = nullptr; |
| 109 if (pac_request_) { | 109 if (pac_request_) { |
| 110 // TODO(mmenke): Convert this to a DCHECK once https://crbug.com/723589 is | 110 DCHECK_EQ(STATE_RESOLVE_PROXY_COMPLETE, next_state_); |
| 111 // resolved. | |
| 112 CHECK_EQ(STATE_RESOLVE_PROXY_COMPLETE, next_state_); | |
| 113 session_->proxy_service()->CancelPacRequest(pac_request_); | 111 session_->proxy_service()->CancelPacRequest(pac_request_); |
| 114 } | 112 } |
| 115 net_log_.EndEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER); | 113 net_log_.EndEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER); |
| 116 } | 114 } |
| 117 | 115 |
| 118 bool HttpStreamFactoryImpl::JobController::for_websockets() { | 116 bool HttpStreamFactoryImpl::JobController::for_websockets() { |
| 119 return factory_->for_websockets_; | 117 return factory_->for_websockets_; |
| 120 } | 118 } |
| 121 | 119 |
| 122 std::unique_ptr<HttpStreamFactoryImpl::Request> | 120 std::unique_ptr<HttpStreamFactoryImpl::Request> |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 break; | 702 break; |
| 705 default: | 703 default: |
| 706 NOTREACHED() << "bad state"; | 704 NOTREACHED() << "bad state"; |
| 707 break; | 705 break; |
| 708 } | 706 } |
| 709 } while (next_state_ != STATE_NONE && rv != ERR_IO_PENDING); | 707 } while (next_state_ != STATE_NONE && rv != ERR_IO_PENDING); |
| 710 return rv; | 708 return rv; |
| 711 } | 709 } |
| 712 | 710 |
| 713 int HttpStreamFactoryImpl::JobController::DoResolveProxy() { | 711 int HttpStreamFactoryImpl::JobController::DoResolveProxy() { |
| 714 // TODO(mmenke): Convert this to a DCHECK once https://crbug.com/723589 is | 712 DCHECK(!pac_request_); |
| 715 // resolved. | |
| 716 CHECK(!pac_request_); | |
| 717 DCHECK(session_); | 713 DCHECK(session_); |
| 718 | 714 |
| 719 next_state_ = STATE_RESOLVE_PROXY_COMPLETE; | 715 next_state_ = STATE_RESOLVE_PROXY_COMPLETE; |
| 720 | 716 |
| 721 if (request_info_.load_flags & LOAD_BYPASS_PROXY) { | 717 if (request_info_.load_flags & LOAD_BYPASS_PROXY) { |
| 722 proxy_info_.UseDirect(); | 718 proxy_info_.UseDirect(); |
| 723 return OK; | 719 return OK; |
| 724 } | 720 } |
| 725 | 721 |
| 726 HostPortPair destination(HostPortPair::FromURL(request_info_.url)); | 722 HostPortPair destination(HostPortPair::FromURL(request_info_.url)); |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1238 } | 1234 } |
| 1239 | 1235 |
| 1240 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const { | 1236 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const { |
| 1241 return !request_ || (job_bound_ && bound_job_ != job); | 1237 return !request_ || (job_bound_ && bound_job_ != job); |
| 1242 } | 1238 } |
| 1243 | 1239 |
| 1244 int HttpStreamFactoryImpl::JobController::ReconsiderProxyAfterError(Job* job, | 1240 int HttpStreamFactoryImpl::JobController::ReconsiderProxyAfterError(Job* job, |
| 1245 int error) { | 1241 int error) { |
| 1246 // ReconsiderProxyAfterError() should only be called when the last job fails. | 1242 // ReconsiderProxyAfterError() should only be called when the last job fails. |
| 1247 DCHECK(!(alternative_job_ && main_job_)); | 1243 DCHECK(!(alternative_job_ && main_job_)); |
| 1248 // TODO(mmenke): Convert this to a DCHECK once https://crbug.com/723589 is | 1244 DCHECK(!pac_request_); |
| 1249 // resolved. | |
| 1250 CHECK(!pac_request_); | |
| 1251 DCHECK(session_); | 1245 DCHECK(session_); |
| 1252 | 1246 |
| 1253 if (!job->should_reconsider_proxy()) | 1247 if (!job->should_reconsider_proxy()) |
| 1254 return error; | 1248 return error; |
| 1255 | 1249 |
| 1256 DCHECK(!job->alternative_proxy_server().is_valid()); | 1250 DCHECK(!job->alternative_proxy_server().is_valid()); |
| 1257 | 1251 |
| 1258 // Do not bypass non-QUIC proxy on ERR_MSG_TOO_BIG. | 1252 // Do not bypass non-QUIC proxy on ERR_MSG_TOO_BIG. |
| 1259 if (!proxy_info_.is_quic() && error == ERR_MSG_TOO_BIG) | 1253 if (!proxy_info_.is_quic() && error == ERR_MSG_TOO_BIG) |
| 1260 return error; | 1254 return error; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1285 // If ReconsiderProxyAfterError() failed synchronously, it means | 1279 // If ReconsiderProxyAfterError() failed synchronously, it means |
| 1286 // there was nothing left to fall-back to, so fail the transaction | 1280 // there was nothing left to fall-back to, so fail the transaction |
| 1287 // with the last connection error we got. | 1281 // with the last connection error we got. |
| 1288 // TODO(eroman): This is a confusing contract, make it more obvious. | 1282 // TODO(eroman): This is a confusing contract, make it more obvious. |
| 1289 rv = error; | 1283 rv = error; |
| 1290 } | 1284 } |
| 1291 return rv; | 1285 return rv; |
| 1292 } | 1286 } |
| 1293 | 1287 |
| 1294 } // namespace net | 1288 } // namespace net |
| OLD | NEW |