Skip to content

Commit

Permalink
Change QuicStreamFactory::active_jobs_ to a Map from QuicServerId to Job
Browse files Browse the repository at this point in the history
as auxiliary Job is no longer supported. There should be at most one Job
serving the same QuicServerId.

BUG=707953

Review-Url: https://codereview.chromium.org/2842883002
Cr-Commit-Position: refs/heads/master@{#467380}
  • Loading branch information
zyshi authored and Commit bot committed Apr 26, 2017
1 parent 0452df8 commit bc11943
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 45 deletions.
3 changes: 0 additions & 3 deletions net/log/net_log_event_type_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -1687,9 +1687,6 @@ EVENT_TYPE(QUIC_STREAM_FACTORY_JOB)
// }
EVENT_TYPE(QUIC_STREAM_FACTORY_JOB_BOUND_TO_HTTP_STREAM_JOB)

// Measures the time taken to load server information.
EVENT_TYPE(QUIC_STREAM_FACTORY_JOB_LOAD_SERVER_INFO)

// Measures the time taken to establish a QUIC connection.
// The event parameters are:
// {
Expand Down
39 changes: 8 additions & 31 deletions net/quic/chromium/quic_stream_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -898,19 +898,13 @@ int QuicStreamFactory::Create(const QuicServerId& server_id,
// Associate with active job to |server_id| if such exists.
auto it = active_jobs_.find(server_id);
if (it != active_jobs_.end()) {
const JobSet& job_set = it->second;
// TODO(zhongyi): figure out how to link the NetLogs if there are more than
// one job serving the same server id, i.e., auxiliary job is also
// created.
if (job_set.size() == 1) {
const NetLogWithSource& job_net_log = job_set.begin()->first->net_log();
job_net_log.AddEvent(
NetLogEventType::QUIC_STREAM_FACTORY_JOB_BOUND_TO_HTTP_STREAM_JOB,
net_log.source().ToEventParametersCallback());
net_log.AddEvent(
NetLogEventType::HTTP_STREAM_JOB_BOUND_TO_QUIC_STREAM_FACTORY_JOB,
job_net_log.source().ToEventParametersCallback());
}
const NetLogWithSource& job_net_log = it->second->net_log();
job_net_log.AddEvent(
NetLogEventType::QUIC_STREAM_FACTORY_JOB_BOUND_TO_HTTP_STREAM_JOB,
net_log.source().ToEventParametersCallback());
net_log.AddEvent(
NetLogEventType::HTTP_STREAM_JOB_BOUND_TO_QUIC_STREAM_FACTORY_JOB,
job_net_log.source().ToEventParametersCallback());
job_requests_map_[server_id].insert(request);
return ERR_IO_PENDING;
}
Expand Down Expand Up @@ -942,8 +936,7 @@ int QuicStreamFactory::Create(const QuicServerId& server_id,
base::Unretained(this), job.get()));
if (rv == ERR_IO_PENDING) {
job_requests_map_[server_id].insert(request);
Job* job_ptr = job.get();
active_jobs_[server_id][job_ptr] = std::move(job);
active_jobs_[server_id] = std::move(job);
return rv;
}
if (rv == OK) {
Expand Down Expand Up @@ -1007,16 +1000,6 @@ void QuicStreamFactory::OnJobComplete(Job* job, int rv) {
// Copy |server_id|, because |job| might be destroyed before this method
// returns.
const QuicServerId server_id(job->key().server_id());
if (rv != OK) {
JobSet* jobs = &(active_jobs_[server_id]);
if (jobs->size() > 1) {
// If there is another pending job, then we can delete this job and let
// the other job handle the request.
job->Cancel();
jobs->erase(job);
return;
}
}

ServerIDRequestsMap::iterator requests_iter =
job_requests_map_.find(server_id);
Expand Down Expand Up @@ -1045,12 +1028,6 @@ void QuicStreamFactory::OnJobComplete(Job* job, int rv) {
request->OnRequestComplete(rv);
}

for (auto& other_job : active_jobs_[server_id]) {
if (other_job.first != job)
other_job.first->Cancel();
}

active_jobs_[server_id].clear();
active_jobs_.erase(server_id);
job_requests_map_.erase(requests_iter);
}
Expand Down
3 changes: 1 addition & 2 deletions net/quic/chromium/quic_stream_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,7 @@ class NET_EXPORT_PRIVATE QuicStreamFactory
typedef std::set<QuicChromiumClientSession*> SessionSet;
typedef std::map<IPEndPoint, SessionSet> IPAliasMap;
typedef std::map<QuicChromiumClientSession*, IPEndPoint> SessionPeerIPMap;
typedef std::map<Job*, std::unique_ptr<Job>> JobSet;
typedef std::map<QuicServerId, JobSet> JobMap;
typedef std::map<QuicServerId, std::unique_ptr<Job>> JobMap;
typedef std::set<QuicStreamRequest*> RequestSet;
typedef std::map<QuicServerId, RequestSet> ServerIDRequestsMap;
typedef std::map<QuicServerId, std::unique_ptr<CertVerifierJob>>
Expand Down
9 changes: 0 additions & 9 deletions net/quic/chromium/quic_stream_factory_peer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,6 @@ void QuicStreamFactoryPeer::SetYieldAfterDuration(
factory->yield_after_duration_ = yield_after_duration;
}

size_t QuicStreamFactoryPeer::GetNumberOfActiveJobs(
QuicStreamFactory* factory,
const QuicServerId& server_id) {
auto it = factory->active_jobs_.find(server_id);
if (it == factory->active_jobs_.end())
return 0;
return it->second.size();
}

bool QuicStreamFactoryPeer::CryptoConfigCacheIsEmpty(
QuicStreamFactory* factory,
const QuicServerId& quic_server_id) {
Expand Down

0 comments on commit bc11943

Please sign in to comment.