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/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 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 #include "net/spdy/spdy_http_stream.h" | 43 #include "net/spdy/spdy_http_stream.h" |
44 #include "net/spdy/spdy_session.h" | 44 #include "net/spdy/spdy_session.h" |
45 #include "net/spdy/spdy_session_pool.h" | 45 #include "net/spdy/spdy_session_pool.h" |
46 #include "net/ssl/ssl_cert_request_info.h" | 46 #include "net/ssl/ssl_cert_request_info.h" |
47 #include "net/ssl/ssl_failure_state.h" | 47 #include "net/ssl/ssl_failure_state.h" |
48 | 48 |
49 namespace net { | 49 namespace net { |
50 | 50 |
51 // Returns parameters associated with the start of a HTTP stream job. | 51 // Returns parameters associated with the start of a HTTP stream job. |
52 scoped_ptr<base::Value> NetLogHttpStreamJobCallback( | 52 scoped_ptr<base::Value> NetLogHttpStreamJobCallback( |
53 const NetLog::Source& source, | |
53 const GURL* original_url, | 54 const GURL* original_url, |
54 const GURL* url, | 55 const GURL* url, |
55 const AlternativeService* alternative_service, | 56 const AlternativeService* alternative_service, |
56 RequestPriority priority, | 57 RequestPriority priority, |
57 NetLogCaptureMode /* capture_mode */) { | 58 NetLogCaptureMode /* capture_mode */) { |
58 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 59 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
60 if (source.IsValid()) | |
61 source.AddToEventParameters(dict.get()); | |
59 dict->SetString("original_url", original_url->GetOrigin().spec()); | 62 dict->SetString("original_url", original_url->GetOrigin().spec()); |
60 dict->SetString("url", url->GetOrigin().spec()); | 63 dict->SetString("url", url->GetOrigin().spec()); |
61 dict->SetString("alternative_service", alternative_service->ToString()); | 64 dict->SetString("alternative_service", alternative_service->ToString()); |
62 dict->SetString("priority", RequestPriorityToString(priority)); | 65 dict->SetString("priority", RequestPriorityToString(priority)); |
63 return dict.Pass(); | 66 return dict.Pass(); |
64 } | 67 } |
65 | 68 |
66 // Returns parameters associated with the Proto (with NPN negotiation) of a HTTP | 69 // Returns parameters associated with the Proto (with NPN negotiation) of a HTTP |
67 // stream. | 70 // stream. |
68 scoped_ptr<base::Value> NetLogHttpStreamProtoCallback( | 71 scoped_ptr<base::Value> NetLogHttpStreamProtoCallback( |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 if (next_state_ == STATE_WAIT_FOR_JOB_COMPLETE) { | 223 if (next_state_ == STATE_WAIT_FOR_JOB_COMPLETE) { |
221 base::ThreadTaskRunnerHandle::Get()->PostTask( | 224 base::ThreadTaskRunnerHandle::Get()->PostTask( |
222 FROM_HERE, base::Bind(&HttpStreamFactoryImpl::Job::OnIOComplete, | 225 FROM_HERE, base::Bind(&HttpStreamFactoryImpl::Job::OnIOComplete, |
223 ptr_factory_.GetWeakPtr(), OK)); | 226 ptr_factory_.GetWeakPtr(), OK)); |
224 } | 227 } |
225 } | 228 } |
226 | 229 |
227 void HttpStreamFactoryImpl::Job::Orphan(const Request* request) { | 230 void HttpStreamFactoryImpl::Job::Orphan(const Request* request) { |
228 DCHECK_EQ(request_, request); | 231 DCHECK_EQ(request_, request); |
229 request_ = NULL; | 232 request_ = NULL; |
233 net_log_.AddEvent(NetLog::TYPE_HTTP_STREAM_JOB_ORPHANED); | |
230 if (blocking_job_) { | 234 if (blocking_job_) { |
231 // We've been orphaned, but there's a job we're blocked on. Don't bother | 235 // We've been orphaned, but there's a job we're blocked on. Don't bother |
232 // racing, just cancel ourself. | 236 // racing, just cancel ourself. |
233 DCHECK(blocking_job_->waiting_job_); | 237 DCHECK(blocking_job_->waiting_job_); |
234 blocking_job_->waiting_job_ = NULL; | 238 blocking_job_->waiting_job_ = NULL; |
235 blocking_job_ = NULL; | 239 blocking_job_ = NULL; |
236 if (stream_factory_->for_websockets_ && | 240 if (stream_factory_->for_websockets_ && |
237 connection_ && connection_->socket()) { | 241 connection_ && connection_->socket()) { |
238 connection_->socket()->Disconnect(); | 242 connection_->socket()->Disconnect(); |
239 } | 243 } |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
659 server_ = alternative_service_.host_port_pair(); | 663 server_ = alternative_service_.host_port_pair(); |
660 } else { | 664 } else { |
661 server_ = HostPortPair::FromURL(request_info_.url); | 665 server_ = HostPortPair::FromURL(request_info_.url); |
662 } | 666 } |
663 origin_url_ = | 667 origin_url_ = |
664 stream_factory_->ApplyHostMappingRules(request_info_.url, &server_); | 668 stream_factory_->ApplyHostMappingRules(request_info_.url, &server_); |
665 valid_spdy_session_pool_.reset(new ValidSpdySessionPool( | 669 valid_spdy_session_pool_.reset(new ValidSpdySessionPool( |
666 session_->spdy_session_pool(), origin_url_, IsSpdyAlternative())); | 670 session_->spdy_session_pool(), origin_url_, IsSpdyAlternative())); |
667 | 671 |
668 net_log_.BeginEvent( | 672 net_log_.BeginEvent( |
669 NetLog::TYPE_HTTP_STREAM_JOB, | 673 NetLog::TYPE_HTTP_STREAM_JOB, |
mmenke
2015/06/25 23:23:27
Should update the docs for this method's parameter
davidben
2015/06/26 16:35:43
Done.
| |
670 base::Bind(&NetLogHttpStreamJobCallback, &request_info_.url, &origin_url_, | 674 base::Bind(&NetLogHttpStreamJobCallback, |
671 &alternative_service_, priority_)); | 675 request_ ? request_->net_log().source() : NetLog::Source(), |
676 &request_info_.url, &origin_url_, &alternative_service_, | |
677 priority_)); | |
678 if (request_) { | |
679 request_->net_log().AddEvent(NetLog::TYPE_HTTP_STREAM_REQUEST_STARTED_JOB, | |
680 net_log_.source().ToEventParametersCallback()); | |
681 } | |
672 | 682 |
673 // Don't connect to restricted ports. | 683 // Don't connect to restricted ports. |
674 if (!IsPortAllowedForScheme(server_.port(), request_info_.url.scheme())) { | 684 if (!IsPortAllowedForScheme(server_.port(), request_info_.url.scheme())) { |
675 if (waiting_job_) { | 685 if (waiting_job_) { |
676 waiting_job_->Resume(this); | 686 waiting_job_->Resume(this); |
677 waiting_job_ = NULL; | 687 waiting_job_ = NULL; |
678 } | 688 } |
679 return ERR_UNSAFE_PORT; | 689 return ERR_UNSAFE_PORT; |
680 } | 690 } |
681 | 691 |
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1573 if (connection_->socket()) { | 1583 if (connection_->socket()) { |
1574 ConnectionAttempts socket_attempts; | 1584 ConnectionAttempts socket_attempts; |
1575 connection_->socket()->GetConnectionAttempts(&socket_attempts); | 1585 connection_->socket()->GetConnectionAttempts(&socket_attempts); |
1576 request_->AddConnectionAttempts(socket_attempts); | 1586 request_->AddConnectionAttempts(socket_attempts); |
1577 } else { | 1587 } else { |
1578 request_->AddConnectionAttempts(connection_->connection_attempts()); | 1588 request_->AddConnectionAttempts(connection_->connection_attempts()); |
1579 } | 1589 } |
1580 } | 1590 } |
1581 | 1591 |
1582 } // namespace net | 1592 } // namespace net |
OLD | NEW |