| 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 c72fd3db7148254fa21964d411d9c5f363b138f9..49d0e73f534e5afddbd76387845d7bc1762c147c 100644
|
| --- a/net/http/http_stream_factory_impl_job_controller.cc
|
| +++ b/net/http/http_stream_factory_impl_job_controller.cc
|
| @@ -36,30 +36,53 @@ std::unique_ptr<base::Value> NetLogHttpStreamJobDelayCallback(
|
| return std::move(dict);
|
| }
|
|
|
| +// Returns parameters associated with the start of a JobController.
|
| +std::unique_ptr<base::Value> NetLogJobControllerCallback(
|
| + const NetLogSource& source,
|
| + bool is_preconnect,
|
| + NetLogCaptureMode /* capture_mode */) {
|
| + std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
|
| + if (source.IsValid())
|
| + source.AddToEventParameters(dict.get());
|
| + 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,
|
| + bool is_preconnect,
|
| + const NetLogWithSource& net_log)
|
| : 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),
|
| + net_log_(
|
| + NetLogWithSource::Make(net_log.net_log(),
|
| + NetLogSourceType::HTTP_STREAM_JOB_CONTROLLER)),
|
| ptr_factory_(this) {
|
| DCHECK(factory);
|
| + net_log.AddEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER,
|
| + net_log_.source().ToEventParametersCallback());
|
| + net_log_.BeginEvent(NetLogEventType::HTTP_STREAM_JOB_CONTROLLER,
|
| + base::Bind(&NetLogJobControllerCallback, net_log.source(),
|
| + is_preconnect));
|
| }
|
|
|
| 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() {
|
| @@ -71,7 +94,6 @@ HttpStreamFactoryImpl::Request* HttpStreamFactoryImpl::JobController::Start(
|
| HttpStreamRequest::Delegate* delegate,
|
| WebSocketHandshakeStreamBase::CreateHelper*
|
| websocket_handshake_stream_create_helper,
|
| - const NetLogWithSource& net_log,
|
| HttpStreamRequest::StreamType stream_type,
|
| RequestPriority priority,
|
| const SSLConfig& server_ssl_config,
|
| @@ -80,11 +102,11 @@ HttpStreamFactoryImpl::Request* HttpStreamFactoryImpl::JobController::Start(
|
| DCHECK(!request_);
|
|
|
| request_ = new Request(request_info.url, this, delegate,
|
| - websocket_handshake_stream_create_helper, net_log,
|
| + websocket_handshake_stream_create_helper, &net_log_,
|
| stream_type);
|
|
|
| CreateJobs(request_info, priority, server_ssl_config, proxy_ssl_config,
|
| - delegate, stream_type, net_log);
|
| + delegate, stream_type);
|
|
|
| return request_;
|
| }
|
| @@ -97,7 +119,6 @@ void HttpStreamFactoryImpl::JobController::Preconnect(
|
| DCHECK(!main_job_);
|
| DCHECK(!alternative_job_);
|
|
|
| - is_preconnect_ = true;
|
| HostPortPair destination(HostPortPair::FromURL(request_info.url));
|
| GURL origin_url = ApplyHostMappingRules(request_info.url, &destination);
|
|
|
| @@ -441,7 +462,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_;
|
| @@ -485,7 +505,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);
|
| @@ -523,7 +543,7 @@ void HttpStreamFactoryImpl::JobController::AddConnectionAttemptsToRequest(
|
| }
|
|
|
| void HttpStreamFactoryImpl::JobController::ResumeMainJob() {
|
| - main_job_->net_log().AddEvent(
|
| + net_log_.AddEvent(
|
| NetLogEventType::HTTP_STREAM_JOB_DELAYED,
|
| base::Bind(&NetLogHttpStreamJobDelayCallback, main_job_wait_time_));
|
|
|
| @@ -623,10 +643,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_;
|
| }
|
|
|
| void HttpStreamFactoryImpl::JobController::MaybeSetWaitTimeForMainJob(
|
| @@ -647,8 +664,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));
|
| @@ -656,7 +672,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.
|
| @@ -677,7 +693,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;
|
| @@ -707,13 +723,8 @@ void HttpStreamFactoryImpl::JobController::BindJob(Job* job) {
|
| bound_job_ = job;
|
| factory_->request_map_.erase(job);
|
|
|
| - request_->net_log().AddEvent(
|
| - NetLogEventType::HTTP_STREAM_REQUEST_BOUND_TO_JOB,
|
| - job->net_log().source().ToEventParametersCallback());
|
| - job->net_log().AddEvent(
|
| - NetLogEventType::HTTP_STREAM_JOB_BOUND_TO_REQUEST,
|
| - request_->net_log().source().ToEventParametersCallback());
|
| -
|
| + net_log_.AddEvent(NetLogEventType::HTTP_STREAM_REQUEST_BOUND_TO_JOB,
|
| + job->net_log().source().ToEventParametersCallback());
|
| OrphanUnboundJob();
|
| }
|
|
|
|
|