Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: net/http/http_stream_factory_impl_job.cc

Issue 2315613002: Extracted NetLog class's inner enum types into their own enum classes and (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_stream_factory_impl_job.h" 5 #include "net/http/http_stream_factory_impl_job.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 19 matching lines...) Expand all
30 #include "net/http/bidirectional_stream_impl.h" 30 #include "net/http/bidirectional_stream_impl.h"
31 #include "net/http/http_basic_stream.h" 31 #include "net/http/http_basic_stream.h"
32 #include "net/http/http_network_session.h" 32 #include "net/http/http_network_session.h"
33 #include "net/http/http_proxy_client_socket.h" 33 #include "net/http/http_proxy_client_socket.h"
34 #include "net/http/http_proxy_client_socket_pool.h" 34 #include "net/http/http_proxy_client_socket_pool.h"
35 #include "net/http/http_request_info.h" 35 #include "net/http/http_request_info.h"
36 #include "net/http/http_server_properties.h" 36 #include "net/http/http_server_properties.h"
37 #include "net/http/http_stream_factory.h" 37 #include "net/http/http_stream_factory.h"
38 #include "net/http/http_stream_factory_impl_request.h" 38 #include "net/http/http_stream_factory_impl_request.h"
39 #include "net/log/net_log.h" 39 #include "net/log/net_log.h"
40 #include "net/log/net_log_event_type.h"
41 #include "net/log/net_log_source_type.h"
40 #include "net/quic/chromium/quic_http_stream.h" 42 #include "net/quic/chromium/quic_http_stream.h"
41 #include "net/socket/client_socket_handle.h" 43 #include "net/socket/client_socket_handle.h"
42 #include "net/socket/client_socket_pool.h" 44 #include "net/socket/client_socket_pool.h"
43 #include "net/socket/client_socket_pool_manager.h" 45 #include "net/socket/client_socket_pool_manager.h"
44 #include "net/socket/socks_client_socket_pool.h" 46 #include "net/socket/socks_client_socket_pool.h"
45 #include "net/socket/ssl_client_socket.h" 47 #include "net/socket/ssl_client_socket.h"
46 #include "net/socket/ssl_client_socket_pool.h" 48 #include "net/socket/ssl_client_socket_pool.h"
47 #include "net/spdy/bidirectional_stream_spdy_impl.h" 49 #include "net/spdy/bidirectional_stream_spdy_impl.h"
48 #include "net/spdy/spdy_http_stream.h" 50 #include "net/spdy/spdy_http_stream.h"
49 #include "net/spdy/spdy_protocol.h" 51 #include "net/spdy/spdy_protocol.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 const SSLConfig& proxy_ssl_config, 176 const SSLConfig& proxy_ssl_config,
175 HostPortPair destination, 177 HostPortPair destination,
176 GURL origin_url, 178 GURL origin_url,
177 AlternativeService alternative_service, 179 AlternativeService alternative_service,
178 const ProxyServer& alternative_proxy_server, 180 const ProxyServer& alternative_proxy_server,
179 NetLog* net_log) 181 NetLog* net_log)
180 : request_info_(request_info), 182 : request_info_(request_info),
181 priority_(priority), 183 priority_(priority),
182 server_ssl_config_(server_ssl_config), 184 server_ssl_config_(server_ssl_config),
183 proxy_ssl_config_(proxy_ssl_config), 185 proxy_ssl_config_(proxy_ssl_config),
184 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_HTTP_STREAM_JOB)), 186 net_log_(BoundNetLog::Make(net_log, NetLogSourceType::HTTP_STREAM_JOB)),
185 io_callback_(base::Bind(&Job::OnIOComplete, base::Unretained(this))), 187 io_callback_(base::Bind(&Job::OnIOComplete, base::Unretained(this))),
186 connection_(new ClientSocketHandle), 188 connection_(new ClientSocketHandle),
187 session_(session), 189 session_(session),
188 next_state_(STATE_NONE), 190 next_state_(STATE_NONE),
189 pac_request_(NULL), 191 pac_request_(NULL),
190 destination_(destination), 192 destination_(destination),
191 origin_url_(origin_url), 193 origin_url_(origin_url),
192 alternative_service_(alternative_service), 194 alternative_service_(alternative_service),
193 delegate_(delegate), 195 delegate_(delegate),
194 alternative_proxy_server_(alternative_proxy_server), 196 alternative_proxy_server_(alternative_proxy_server),
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 if (IsSpdyAlternative()) { 232 if (IsSpdyAlternative()) {
231 DCHECK(origin_url_.SchemeIs("https")); 233 DCHECK(origin_url_.SchemeIs("https"));
232 } 234 }
233 if (IsQuicAlternative()) { 235 if (IsQuicAlternative()) {
234 DCHECK(session_->params().enable_quic); 236 DCHECK(session_->params().enable_quic);
235 using_quic_ = true; 237 using_quic_ = true;
236 } 238 }
237 } 239 }
238 240
239 HttpStreamFactoryImpl::Job::~Job() { 241 HttpStreamFactoryImpl::Job::~Job() {
240 net_log_.EndEvent(NetLog::TYPE_HTTP_STREAM_JOB); 242 net_log_.EndEvent(NetLogEventType::HTTP_STREAM_JOB);
241 243
242 // When we're in a partially constructed state, waiting for the user to 244 // When we're in a partially constructed state, waiting for the user to
243 // provide certificate handling information or authentication, we can't reuse 245 // provide certificate handling information or authentication, we can't reuse
244 // this stream at all. 246 // this stream at all.
245 if (next_state_ == STATE_WAITING_USER_ACTION) { 247 if (next_state_ == STATE_WAITING_USER_ACTION) {
246 connection_->socket()->Disconnect(); 248 connection_->socket()->Disconnect();
247 connection_.reset(); 249 connection_.reset();
248 } 250 }
249 251
250 if (pac_request_) 252 if (pac_request_)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 } 297 }
296 } 298 }
297 299
298 void HttpStreamFactoryImpl::Job::Resume() { 300 void HttpStreamFactoryImpl::Job::Resume() {
299 DCHECK_EQ(job_type_, MAIN); 301 DCHECK_EQ(job_type_, MAIN);
300 DCHECK_EQ(next_state_, STATE_WAIT_COMPLETE); 302 DCHECK_EQ(next_state_, STATE_WAIT_COMPLETE);
301 OnIOComplete(OK); 303 OnIOComplete(OK);
302 } 304 }
303 305
304 void HttpStreamFactoryImpl::Job::Orphan() { 306 void HttpStreamFactoryImpl::Job::Orphan() {
305 net_log_.AddEvent(NetLog::TYPE_HTTP_STREAM_JOB_ORPHANED); 307 net_log_.AddEvent(NetLogEventType::HTTP_STREAM_JOB_ORPHANED);
306 308
307 if (delegate_->for_websockets()) { 309 if (delegate_->for_websockets()) {
308 // We cancel this job because a WebSocketHandshakeStream can't be created 310 // We cancel this job because a WebSocketHandshakeStream can't be created
309 // without a WebSocketHandshakeStreamBase::CreateHelper which is stored in 311 // without a WebSocketHandshakeStreamBase::CreateHelper which is stored in
310 // the Request class and isn't retrievable by this job. 312 // the Request class and isn't retrievable by this job.
311 if (connection_ && connection_->socket()) { 313 if (connection_ && connection_->socket()) {
312 connection_->socket()->Disconnect(); 314 connection_->socket()->Disconnect();
313 } 315 }
314 delegate_->OnOrphanedJobComplete(this); 316 delegate_->OnOrphanedJobComplete(this);
315 } 317 }
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 int rv = RunLoop(OK); 689 int rv = RunLoop(OK);
688 DCHECK_EQ(ERR_IO_PENDING, rv); 690 DCHECK_EQ(ERR_IO_PENDING, rv);
689 return rv; 691 return rv;
690 } 692 }
691 693
692 int HttpStreamFactoryImpl::Job::DoStart() { 694 int HttpStreamFactoryImpl::Job::DoStart() {
693 const BoundNetLog* net_log = delegate_->GetNetLog(this); 695 const BoundNetLog* net_log = delegate_->GetNetLog(this);
694 696
695 if (net_log) { 697 if (net_log) {
696 net_log_.BeginEvent( 698 net_log_.BeginEvent(
697 NetLog::TYPE_HTTP_STREAM_JOB, 699 NetLogEventType::HTTP_STREAM_JOB,
698 base::Bind(&NetLogHttpStreamJobCallback, net_log->source(), 700 base::Bind(&NetLogHttpStreamJobCallback, net_log->source(),
699 &request_info_.url, &origin_url_, &alternative_service_, 701 &request_info_.url, &origin_url_, &alternative_service_,
700 priority_)); 702 priority_));
701 net_log->AddEvent(NetLog::TYPE_HTTP_STREAM_REQUEST_STARTED_JOB, 703 net_log->AddEvent(NetLogEventType::HTTP_STREAM_REQUEST_STARTED_JOB,
702 net_log_.source().ToEventParametersCallback()); 704 net_log_.source().ToEventParametersCallback());
703 } 705 }
704 706
705 // Don't connect to restricted ports. 707 // Don't connect to restricted ports.
706 if (!IsPortAllowedForScheme(destination_.port(), 708 if (!IsPortAllowedForScheme(destination_.port(),
707 request_info_.url.scheme())) { 709 request_info_.url.scheme())) {
708 return ERR_UNSAFE_PORT; 710 return ERR_UNSAFE_PORT;
709 } 711 }
710 712
711 next_state_ = STATE_RESOLVE_PROXY; 713 next_state_ = STATE_RESOLVE_PROXY;
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 if (using_quic_ && result == OK) { 1019 if (using_quic_ && result == OK) {
1018 was_npn_negotiated_ = true; 1020 was_npn_negotiated_ = true;
1019 negotiated_protocol_ = kProtoQUIC1SPDY3; 1021 negotiated_protocol_ = kProtoQUIC1SPDY3;
1020 } else { 1022 } else {
1021 SSLClientSocket* ssl_socket = 1023 SSLClientSocket* ssl_socket =
1022 static_cast<SSLClientSocket*>(connection_->socket()); 1024 static_cast<SSLClientSocket*>(connection_->socket());
1023 if (ssl_socket->WasNpnNegotiated()) { 1025 if (ssl_socket->WasNpnNegotiated()) {
1024 was_npn_negotiated_ = true; 1026 was_npn_negotiated_ = true;
1025 negotiated_protocol_ = ssl_socket->GetNegotiatedProtocol(); 1027 negotiated_protocol_ = ssl_socket->GetNegotiatedProtocol();
1026 net_log_.AddEvent( 1028 net_log_.AddEvent(
1027 NetLog::TYPE_HTTP_STREAM_REQUEST_PROTO, 1029 NetLogEventType::HTTP_STREAM_REQUEST_PROTO,
1028 base::Bind(&NetLogHttpStreamProtoCallback, negotiated_protocol_)); 1030 base::Bind(&NetLogHttpStreamProtoCallback, negotiated_protocol_));
1029 if (negotiated_protocol_ == kProtoHTTP2) 1031 if (negotiated_protocol_ == kProtoHTTP2)
1030 SwitchToSpdyMode(); 1032 SwitchToSpdyMode();
1031 } 1033 }
1032 } 1034 }
1033 } else if (proxy_info_.is_https() && connection_->socket() && 1035 } else if (proxy_info_.is_https() && connection_->socket() &&
1034 result == OK) { 1036 result == OK) {
1035 ProxyClientSocket* proxy_socket = 1037 ProxyClientSocket* proxy_socket =
1036 static_cast<ProxyClientSocket*>(connection_->socket()); 1038 static_cast<ProxyClientSocket*>(connection_->socket());
1037 // http://crbug.com/642354 1039 // http://crbug.com/642354
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
1629 1631
1630 ConnectionAttempts socket_attempts = connection_->connection_attempts(); 1632 ConnectionAttempts socket_attempts = connection_->connection_attempts();
1631 if (connection_->socket()) { 1633 if (connection_->socket()) {
1632 connection_->socket()->GetConnectionAttempts(&socket_attempts); 1634 connection_->socket()->GetConnectionAttempts(&socket_attempts);
1633 } 1635 }
1634 1636
1635 delegate_->AddConnectionAttemptsToRequest(this, socket_attempts); 1637 delegate_->AddConnectionAttemptsToRequest(this, socket_attempts);
1636 } 1638 }
1637 1639
1638 } // namespace net 1640 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698