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