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 5284b321d4033b0d2e2ff0eeec1ac6263be070f9..ba0ce30e69eba8baefb629ba893ea82d56698267 100644 |
| --- a/net/http/http_stream_factory_impl_job_controller.cc |
| +++ b/net/http/http_stream_factory_impl_job_controller.cc |
| @@ -8,6 +8,7 @@ |
| #include <string> |
| #include <utility> |
| +#include "base/memory/ptr_util.h" |
| #include "base/metrics/histogram_macros.h" |
| #include "base/strings/string_number_conversions.h" |
| #include "base/strings/string_util.h" |
| @@ -36,31 +37,51 @@ 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 = |
|
Bence
2017/01/28 02:08:25
Optional: feel free to use auto here (as suggested
xunjieli
2017/01/30 14:08:39
Done.
|
| + base::MakeUnique<base::DictionaryValue>(); |
| + 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_net_error_(OK), |
| 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)); |
| } |
| 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 +93,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 +104,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 +125,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); |
| @@ -441,7 +467,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 +510,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); |
| @@ -623,10 +648,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( |
| @@ -664,8 +686,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)); |
| @@ -673,7 +694,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. |
| @@ -694,7 +715,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; |