Chromium Code Reviews| 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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 void OnIOComplete(int rv); | 338 void OnIOComplete(int rv); |
| 339 | 339 |
| 340 void RunAuxilaryJob(); | 340 void RunAuxilaryJob(); |
| 341 | 341 |
| 342 void Cancel(); | 342 void Cancel(); |
| 343 | 343 |
| 344 void CancelWaitForDataReadyCallback(); | 344 void CancelWaitForDataReadyCallback(); |
| 345 | 345 |
| 346 const QuicSessionKey& key() const { return key_; } | 346 const QuicSessionKey& key() const { return key_; } |
| 347 | 347 |
| 348 const NetLogWithSource& net_log() const { return net_log_; } | |
| 349 | |
| 348 base::WeakPtr<Job> GetWeakPtr() { return weak_factory_.GetWeakPtr(); } | 350 base::WeakPtr<Job> GetWeakPtr() { return weak_factory_.GetWeakPtr(); } |
| 349 | 351 |
| 350 private: | 352 private: |
| 351 enum IoState { | 353 enum IoState { |
| 352 STATE_NONE, | 354 STATE_NONE, |
| 353 STATE_RESOLVE_HOST, | 355 STATE_RESOLVE_HOST, |
| 354 STATE_RESOLVE_HOST_COMPLETE, | 356 STATE_RESOLVE_HOST_COMPLETE, |
| 355 STATE_LOAD_SERVER_INFO, | 357 STATE_LOAD_SERVER_INFO, |
| 356 STATE_LOAD_SERVER_INFO_COMPLETE, | 358 STATE_LOAD_SERVER_INFO_COMPLETE, |
| 357 STATE_CONNECT, | 359 STATE_CONNECT, |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 999 if (!active_sessions_.empty()) { | 1001 if (!active_sessions_.empty()) { |
| 1000 SessionMap::iterator it = active_sessions_.find(server_id); | 1002 SessionMap::iterator it = active_sessions_.find(server_id); |
| 1001 if (it != active_sessions_.end()) { | 1003 if (it != active_sessions_.end()) { |
| 1002 QuicChromiumClientSession* session = it->second; | 1004 QuicChromiumClientSession* session = it->second; |
| 1003 request->SetSession(session); | 1005 request->SetSession(session); |
| 1004 return OK; | 1006 return OK; |
| 1005 } | 1007 } |
| 1006 } | 1008 } |
| 1007 | 1009 |
| 1008 // Associate with active job to |server_id| if such exists. | 1010 // Associate with active job to |server_id| if such exists. |
| 1009 if (HasActiveJob(server_id)) { | 1011 auto itr = active_jobs_.find(server_id); |
| 1012 if (itr != active_jobs_.end()) { | |
| 1013 const JobSet* job_set = &itr->second; | |
| 1014 // TODO(zhongyi): figure out how to link the NetLogs if there are more than | |
| 1015 // one jobs serving the same server id, i.e., auxiliary job is also | |
|
xunjieli
2017/04/11 00:32:02
nit: s/one jobs/one job.
Remove comma after "i.e."
Zhongyi Shi
2017/04/11 00:54:33
Done.
| |
| 1016 // created. | |
| 1017 if (job_set->size() == 1) { | |
| 1018 const NetLogWithSource& job_net_log = job_set->begin()->first->net_log(); | |
| 1019 job_net_log.AddEvent( | |
| 1020 NetLogEventType::QUIC_STREAM_FACTORY_JOB_BOUND_TO_HTTP_STREAM_JOB, | |
| 1021 net_log.source().ToEventParametersCallback()); | |
| 1022 net_log.AddEvent( | |
| 1023 NetLogEventType::HTTP_STREAM_JOB_BOUND_TO_QUIC_STREAM_FACTORY_JOB, | |
| 1024 job_net_log.source().ToEventParametersCallback()); | |
| 1025 } | |
| 1010 job_requests_map_[server_id].insert(request); | 1026 job_requests_map_[server_id].insert(request); |
| 1011 return ERR_IO_PENDING; | 1027 return ERR_IO_PENDING; |
| 1012 } | 1028 } |
| 1013 | 1029 |
| 1014 // Pool to active session to |destination| if possible. | 1030 // Pool to active session to |destination| if possible. |
| 1015 if (!active_sessions_.empty() && !disable_connection_pooling_) { | 1031 if (!active_sessions_.empty() && !disable_connection_pooling_) { |
| 1016 for (const auto& key_value : active_sessions_) { | 1032 for (const auto& key_value : active_sessions_) { |
| 1017 QuicChromiumClientSession* session = key_value.second; | 1033 QuicChromiumClientSession* session = key_value.second; |
| 1018 if (destination.Equals(all_sessions_[session].destination()) && | 1034 if (destination.Equals(all_sessions_[session].destination()) && |
| 1019 session->CanPool(server_id.host(), server_id.privacy_mode())) { | 1035 session->CanPool(server_id.host(), server_id.privacy_mode())) { |
| (...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1927 // Since the session was active, there's no longer an | 1943 // Since the session was active, there's no longer an |
| 1928 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP | 1944 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP |
| 1929 // job also fails. So to avoid not using QUIC when we otherwise could, we mark | 1945 // job also fails. So to avoid not using QUIC when we otherwise could, we mark |
| 1930 // it as recently broken, which means that 0-RTT will be disabled but we'll | 1946 // it as recently broken, which means that 0-RTT will be disabled but we'll |
| 1931 // still race. | 1947 // still race. |
| 1932 http_server_properties_->MarkAlternativeServiceRecentlyBroken( | 1948 http_server_properties_->MarkAlternativeServiceRecentlyBroken( |
| 1933 alternative_service); | 1949 alternative_service); |
| 1934 } | 1950 } |
| 1935 | 1951 |
| 1936 } // namespace net | 1952 } // namespace net |
| OLD | NEW |