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/quic/chromium/quic_stream_factory.h" | 5 #include "net/quic/chromium/quic_stream_factory.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <tuple> | 8 #include <tuple> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1141 JobSet* jobs = &(active_jobs_[server_id]); | 1141 JobSet* jobs = &(active_jobs_[server_id]); |
1142 if (jobs->size() > 1) { | 1142 if (jobs->size() > 1) { |
1143 // If there is another pending job, then we can delete this job and let | 1143 // If there is another pending job, then we can delete this job and let |
1144 // the other job handle the request. | 1144 // the other job handle the request. |
1145 job->Cancel(); | 1145 job->Cancel(); |
1146 jobs->erase(job); | 1146 jobs->erase(job); |
1147 return; | 1147 return; |
1148 } | 1148 } |
1149 } | 1149 } |
1150 | 1150 |
1151 ServerIDRequestsMap::iterator requests_iter = | |
1152 job_requests_map_.find(server_id); | |
1153 DCHECK(requests_iter != job_requests_map_.end()); | |
1151 if (rv == OK) { | 1154 if (rv == OK) { |
1152 if (!always_require_handshake_confirmation_) | 1155 if (!always_require_handshake_confirmation_) |
1153 set_require_confirmation(false); | 1156 set_require_confirmation(false); |
1154 | 1157 |
1155 if (!job_requests_map_[server_id].empty()) { | 1158 if (!requests_iter->second.empty()) { |
1156 SessionMap::iterator session_it = active_sessions_.find(server_id); | 1159 SessionMap::iterator session_it = active_sessions_.find(server_id); |
1157 DCHECK(session_it != active_sessions_.end()); | 1160 DCHECK(session_it != active_sessions_.end()); |
1158 QuicChromiumClientSession* session = session_it->second; | 1161 QuicChromiumClientSession* session = session_it->second; |
1159 for (QuicStreamRequest* request : job_requests_map_[server_id]) { | 1162 for (QuicStreamRequest* request : requests_iter->second) { |
1160 DCHECK(request->server_id() == server_id); | 1163 DCHECK(request->server_id() == server_id); |
1161 // Do not notify |request| yet. | 1164 // Do not notify |request| yet. |
1162 request->SetSession(session); | 1165 request->SetSession(session); |
1163 } | 1166 } |
1164 } | 1167 } |
1165 } | 1168 } |
1166 | 1169 |
1167 while (!job_requests_map_[server_id].empty()) { | 1170 // It's okay not to erase |request| from |requests_iter->second| because we |
Ryan Hamilton
2017/04/04 20:03:24
nit: avoid first person in comments. How 'bout som
xunjieli
2017/04/04 21:25:23
Done.
| |
1168 RequestSet::iterator it = job_requests_map_[server_id].begin(); | 1171 // will erase the entire RequestSet from |job_requests_map_|. |
1169 QuicStreamRequest* request = *it; | 1172 for (auto* request : requests_iter->second) { |
1170 job_requests_map_[server_id].erase(it); | |
1171 // Even though we're invoking callbacks here, we don't need to worry | 1173 // Even though we're invoking callbacks here, we don't need to worry |
1172 // about |this| being deleted, because the factory is owned by the | 1174 // about |this| being deleted, because the factory is owned by the |
1173 // profile which can not be deleted via callbacks. | 1175 // profile which can not be deleted via callbacks. |
1174 request->OnRequestComplete(rv); | 1176 request->OnRequestComplete(rv); |
1175 } | 1177 } |
1176 | 1178 |
1177 for (auto& other_job : active_jobs_[server_id]) { | 1179 for (auto& other_job : active_jobs_[server_id]) { |
1178 if (other_job.first != job) | 1180 if (other_job.first != job) |
1179 other_job.first->Cancel(); | 1181 other_job.first->Cancel(); |
1180 } | 1182 } |
1181 | 1183 |
1182 active_jobs_[server_id].clear(); | 1184 active_jobs_[server_id].clear(); |
1183 active_jobs_.erase(server_id); | 1185 active_jobs_.erase(server_id); |
1184 job_requests_map_.erase(server_id); | 1186 job_requests_map_.erase(requests_iter); |
1185 } | 1187 } |
1186 | 1188 |
1187 void QuicStreamFactory::OnCertVerifyJobComplete(CertVerifierJob* job, int rv) { | 1189 void QuicStreamFactory::OnCertVerifyJobComplete(CertVerifierJob* job, int rv) { |
1188 active_cert_verifier_jobs_.erase(job->server_id()); | 1190 active_cert_verifier_jobs_.erase(job->server_id()); |
1189 } | 1191 } |
1190 | 1192 |
1191 std::unique_ptr<QuicHttpStream> QuicStreamFactory::CreateFromSession( | 1193 std::unique_ptr<QuicHttpStream> QuicStreamFactory::CreateFromSession( |
1192 QuicChromiumClientSession* session) { | 1194 QuicChromiumClientSession* session) { |
1193 return std::unique_ptr<QuicHttpStream>( | 1195 return std::unique_ptr<QuicHttpStream>( |
1194 new QuicHttpStream(session->GetWeakPtr(), http_server_properties_)); | 1196 new QuicHttpStream(session->GetWeakPtr(), http_server_properties_)); |
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1985 void QuicStreamFactory::OpenFactory() { | 1987 void QuicStreamFactory::OpenFactory() { |
1986 status_ = OPEN; | 1988 status_ = OPEN; |
1987 } | 1989 } |
1988 | 1990 |
1989 void QuicStreamFactory::MaybeClearConsecutiveDisabledCount() { | 1991 void QuicStreamFactory::MaybeClearConsecutiveDisabledCount() { |
1990 if (status_ == OPEN) | 1992 if (status_ == OPEN) |
1991 consecutive_disabled_count_ = 0; | 1993 consecutive_disabled_count_ = 0; |
1992 } | 1994 } |
1993 | 1995 |
1994 } // namespace net | 1996 } // namespace net |
OLD | NEW |