Chromium Code Reviews| Index: net/http/http_stream_factory_impl_job_controller.cc |
| diff --git a/net/http/http_stream_factory_impl_job_controller.cc b/net/http/http_stream_factory_impl_job_controller.cc |
| index 0103707961050f5ce6842015009a5a84de3ab0ca..ce2ecf5686dfe789831330394b01c92dcc09cb98 100644 |
| --- a/net/http/http_stream_factory_impl_job_controller.cc |
| +++ b/net/http/http_stream_factory_impl_job_controller.cc |
| @@ -36,31 +36,50 @@ std::unique_ptr<base::Value> NetLogHttpStreamJobDelayCallback( |
| return std::move(dict); |
| } |
| +std::unique_ptr<base::Value> NetLogJobControllerCallback( |
| + const GURL* url, |
| + bool is_preconnect, |
| + NetLogCaptureMode /* capture_mode */) { |
| + std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
|
eroman
2017/01/26 23:37:00
[optional] style: MakeUnique
xunjieli
2017/01/27 14:35:30
Done.
|
| + dict->SetString("url", url->possibly_invalid_spec()); |
| + dict->SetBoolean("is_preconnect", is_preconnect); |
| + return std::move(dict); |
| +} |
| + |
| HttpStreamFactoryImpl::JobController::JobController( |
| HttpStreamFactoryImpl* factory, |
| HttpStreamRequest::Delegate* delegate, |
| HttpNetworkSession* session, |
| - JobFactory* job_factory) |
| + JobFactory* job_factory, |
| + const HttpRequestInfo& request_info, |
| + bool is_preconnect) |
| : factory_(factory), |
| session_(session), |
| job_factory_(job_factory), |
| request_(nullptr), |
| delegate_(delegate), |
| - is_preconnect_(false), |
| + is_preconnect_(is_preconnect), |
| alternative_job_failed_(false), |
| job_bound_(false), |
| main_job_is_blocked_(false), |
| bound_job_(nullptr), |
| can_start_alternative_proxy_job_(false), |
| privacy_mode_(PRIVACY_MODE_DISABLED), |
| + net_log_( |
| + NetLogWithSource::Make(session->net_log(), |
| + NetLogSourceType::HTTP_STREAM_JOB_CONTROLLER)), |
| ptr_factory_(this) { |
| DCHECK(factory); |
| + net_log_.BeginEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER, |
| + base::Bind(&NetLogJobControllerCallback, |
| + &request_info.url, /*is_preconnect=*/false)); |
|
Zhongyi Shi
2017/01/27 00:50:32
Why this is always set to false?
xunjieli
2017/01/27 14:35:30
Ah, sorry about that. Done.
|
| } |
| HttpStreamFactoryImpl::JobController::~JobController() { |
| main_job_.reset(); |
| alternative_job_.reset(); |
| bound_job_ = nullptr; |
| + net_log_.EndEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER); |
| } |
| bool HttpStreamFactoryImpl::JobController::for_websockets() { |
| @@ -72,7 +91,7 @@ HttpStreamFactoryImpl::Request* HttpStreamFactoryImpl::JobController::Start( |
| HttpStreamRequest::Delegate* delegate, |
| WebSocketHandshakeStreamBase::CreateHelper* |
| websocket_handshake_stream_create_helper, |
| - const NetLogWithSource& net_log, |
| + const NetLogWithSource& source_net_log, |
| HttpStreamRequest::StreamType stream_type, |
| RequestPriority priority, |
| const SSLConfig& server_ssl_config, |
| @@ -83,11 +102,16 @@ HttpStreamFactoryImpl::Request* HttpStreamFactoryImpl::JobController::Start( |
| privacy_mode_ = request_info.privacy_mode; |
| request_ = new Request(request_info.url, this, delegate, |
| - websocket_handshake_stream_create_helper, net_log, |
| - stream_type); |
| + websocket_handshake_stream_create_helper, |
| + source_net_log, stream_type); |
| + // Associates |net_log_| with |source_net_log|. |
| + source_net_log.AddEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER_BOUND, |
| + net_log_.source().ToEventParametersCallback()); |
| + net_log_.AddEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER_BOUND, |
| + source_net_log.source().ToEventParametersCallback()); |
| CreateJobs(request_info, priority, server_ssl_config, proxy_ssl_config, |
| - delegate, stream_type, net_log); |
| + delegate, stream_type); |
| return request_; |
| } |
| @@ -99,10 +123,10 @@ void HttpStreamFactoryImpl::JobController::Preconnect( |
| const SSLConfig& proxy_ssl_config) { |
| DCHECK(!main_job_); |
| DCHECK(!alternative_job_); |
| + DCHECK(is_preconnect_); |
| privacy_mode_ = request_info.privacy_mode; |
| - is_preconnect_ = true; |
| HostPortPair destination(HostPortPair::FromURL(request_info.url)); |
| GURL origin_url = ApplyHostMappingRules(request_info.url, &destination); |
| @@ -439,7 +463,6 @@ void HttpStreamFactoryImpl::JobController::OnNewSpdySessionReady( |
| const bool was_alpn_negotiated = job->was_alpn_negotiated(); |
| const NextProto negotiated_protocol = job->negotiated_protocol(); |
| const bool using_spdy = job->using_spdy(); |
| - const NetLogWithSource net_log = job->net_log(); |
| // Cache this so we can still use it if the JobController is deleted. |
| HttpStreamFactoryImpl* factory = factory_; |
| @@ -483,7 +506,7 @@ void HttpStreamFactoryImpl::JobController::OnNewSpdySessionReady( |
| if (spdy_session && spdy_session->IsAvailable()) { |
| factory->OnNewSpdySessionReady(spdy_session, direct, used_ssl_config, |
| used_proxy_info, was_alpn_negotiated, |
| - negotiated_protocol, using_spdy, net_log); |
| + negotiated_protocol, using_spdy); |
| } |
| if (is_job_orphaned) { |
| OnOrphanedJobComplete(job); |
| @@ -621,10 +644,7 @@ void HttpStreamFactoryImpl::JobController:: |
| const NetLogWithSource* HttpStreamFactoryImpl::JobController::GetNetLog( |
| Job* job) const { |
| - if (is_preconnect_ || (job_bound_ && bound_job_ != job)) |
| - return nullptr; |
| - DCHECK(request_); |
| - return &request_->net_log(); |
| + return &net_log_; |
|
Zhongyi Shi
2017/01/27 00:50:32
nit: you might want o move the implementation of t
xunjieli
2017/01/27 14:35:30
Done.
xunjieli
2017/01/27 15:01:34
Hmm.. actually this is a virtual function so I can
|
| } |
| void HttpStreamFactoryImpl::JobController::MaybeSetWaitTimeForMainJob( |
| @@ -662,8 +682,7 @@ void HttpStreamFactoryImpl::JobController::CreateJobs( |
| const SSLConfig& server_ssl_config, |
| const SSLConfig& proxy_ssl_config, |
| HttpStreamRequest::Delegate* delegate, |
| - HttpStreamRequest::StreamType stream_type, |
| - const NetLogWithSource& net_log) { |
| + HttpStreamRequest::StreamType stream_type) { |
| DCHECK(!main_job_); |
| DCHECK(!alternative_job_); |
| HostPortPair destination(HostPortPair::FromURL(request_info.url)); |
| @@ -671,7 +690,7 @@ void HttpStreamFactoryImpl::JobController::CreateJobs( |
| main_job_.reset(job_factory_->CreateJob( |
| this, MAIN, session_, request_info, priority, server_ssl_config, |
| - proxy_ssl_config, destination, origin_url, net_log.net_log())); |
| + proxy_ssl_config, destination, origin_url, net_log_.net_log())); |
| AttachJob(main_job_.get()); |
| // Create an alternative job if alternative service is set up for this domain. |
| @@ -692,7 +711,7 @@ void HttpStreamFactoryImpl::JobController::CreateJobs( |
| alternative_job_.reset(job_factory_->CreateJob( |
| this, ALTERNATIVE, session_, request_info, priority, server_ssl_config, |
| proxy_ssl_config, alternative_destination, origin_url, |
| - alternative_service, net_log.net_log())); |
| + alternative_service, net_log_.net_log())); |
| AttachJob(alternative_job_.get()); |
| main_job_is_blocked_ = true; |