| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 CHECK_EQ(STATE_RESOLVE_PROXY_COMPLETE, next_state_); | 112 CHECK_EQ(STATE_RESOLVE_PROXY_COMPLETE, next_state_); |
| 113 session_->proxy_service()->CancelPacRequest(pac_request_); | 113 session_->proxy_service()->CancelPacRequest(pac_request_); |
| 114 } | 114 } |
| 115 net_log_.EndEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER); | 115 net_log_.EndEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER); |
| 116 } | 116 } |
| 117 | 117 |
| 118 bool HttpStreamFactoryImpl::JobController::for_websockets() { | 118 bool HttpStreamFactoryImpl::JobController::for_websockets() { |
| 119 return factory_->for_websockets_; | 119 return factory_->for_websockets_; |
| 120 } | 120 } |
| 121 | 121 |
| 122 HttpStreamFactoryImpl::Request* HttpStreamFactoryImpl::JobController::Start( | 122 std::unique_ptr<HttpStreamFactoryImpl::Request> |
| 123 HttpStreamFactoryImpl::JobController::Start( |
| 123 HttpStreamRequest::Delegate* delegate, | 124 HttpStreamRequest::Delegate* delegate, |
| 124 WebSocketHandshakeStreamBase::CreateHelper* | 125 WebSocketHandshakeStreamBase::CreateHelper* |
| 125 websocket_handshake_stream_create_helper, | 126 websocket_handshake_stream_create_helper, |
| 126 const NetLogWithSource& source_net_log, | 127 const NetLogWithSource& source_net_log, |
| 127 HttpStreamRequest::StreamType stream_type, | 128 HttpStreamRequest::StreamType stream_type, |
| 128 RequestPriority priority) { | 129 RequestPriority priority) { |
| 129 DCHECK(factory_); | 130 DCHECK(factory_); |
| 130 DCHECK(!request_); | 131 DCHECK(!request_); |
| 131 | 132 |
| 132 stream_type_ = stream_type; | 133 stream_type_ = stream_type; |
| 133 priority_ = priority; | 134 priority_ = priority; |
| 134 | 135 |
| 135 request_ = new Request(request_info_.url, this, delegate, | 136 auto request = base::MakeUnique<Request>( |
| 136 websocket_handshake_stream_create_helper, | 137 request_info_.url, this, delegate, |
| 137 source_net_log, stream_type); | 138 websocket_handshake_stream_create_helper, source_net_log, stream_type); |
| 139 // Keep a raw pointer but release ownership of Request instance. |
| 140 request_ = request.get(); |
| 141 |
| 138 // Associates |net_log_| with |source_net_log|. | 142 // Associates |net_log_| with |source_net_log|. |
| 139 source_net_log.AddEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER_BOUND, | 143 source_net_log.AddEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER_BOUND, |
| 140 net_log_.source().ToEventParametersCallback()); | 144 net_log_.source().ToEventParametersCallback()); |
| 141 net_log_.AddEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER_BOUND, | 145 net_log_.AddEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER_BOUND, |
| 142 source_net_log.source().ToEventParametersCallback()); | 146 source_net_log.source().ToEventParametersCallback()); |
| 143 | 147 |
| 144 RunLoop(OK); | 148 RunLoop(OK); |
| 145 return request_; | 149 return request; |
| 146 } | 150 } |
| 147 | 151 |
| 148 void HttpStreamFactoryImpl::JobController::Preconnect(int num_streams) { | 152 void HttpStreamFactoryImpl::JobController::Preconnect(int num_streams) { |
| 149 DCHECK(!main_job_); | 153 DCHECK(!main_job_); |
| 150 DCHECK(!alternative_job_); | 154 DCHECK(!alternative_job_); |
| 151 DCHECK(is_preconnect_); | 155 DCHECK(is_preconnect_); |
| 152 | 156 |
| 153 stream_type_ = HttpStreamRequest::HTTP_STREAM; | 157 stream_type_ = HttpStreamRequest::HTTP_STREAM; |
| 154 num_streams_ = num_streams; | 158 num_streams_ = num_streams; |
| 155 | 159 |
| (...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1266 // If ReconsiderProxyAfterError() failed synchronously, it means | 1270 // If ReconsiderProxyAfterError() failed synchronously, it means |
| 1267 // there was nothing left to fall-back to, so fail the transaction | 1271 // there was nothing left to fall-back to, so fail the transaction |
| 1268 // with the last connection error we got. | 1272 // with the last connection error we got. |
| 1269 // TODO(eroman): This is a confusing contract, make it more obvious. | 1273 // TODO(eroman): This is a confusing contract, make it more obvious. |
| 1270 rv = error; | 1274 rv = error; |
| 1271 } | 1275 } |
| 1272 return rv; | 1276 return rv; |
| 1273 } | 1277 } |
| 1274 | 1278 |
| 1275 } // namespace net | 1279 } // namespace net |
| OLD | NEW |