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 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 if (HasActiveJob(server_id)) { |
| 1012 if (active_jobs_[server_id].size() == 1) { | |
|
eroman
2017/04/10 21:55:07
nit: There are 3 instances of active_jobs_[server
Zhongyi Shi
2017/04/10 23:50:49
Yeah, we could reduce the 2 lookups to 1. However,
xunjieli
2017/04/10 23:56:24
I agreed with Eric. I landed a CL last week to red
Zhongyi Shi
2017/04/11 00:27:04
Done.
| |
| 1013 const NetLogWithSource& job_net_log = | |
| 1014 active_jobs_[server_id].begin()->first->net_log(); | |
| 1015 job_net_log.AddEvent( | |
| 1016 NetLogEventType::QUIC_STREAM_FACTORY_JOB_BOUND_TO_HTTP_STREAM_JOB, | |
| 1017 net_log.source().ToEventParametersCallback()); | |
| 1018 net_log.AddEvent( | |
| 1019 NetLogEventType::HTTP_STREAM_JOB_BOUND_TO_QUIC_STREAM_FACTORY_JOB, | |
| 1020 job_net_log.source().ToEventParametersCallback()); | |
| 1021 } | |
| 1010 job_requests_map_[server_id].insert(request); | 1022 job_requests_map_[server_id].insert(request); |
| 1011 return ERR_IO_PENDING; | 1023 return ERR_IO_PENDING; |
| 1012 } | 1024 } |
| 1013 | 1025 |
| 1014 // Pool to active session to |destination| if possible. | 1026 // Pool to active session to |destination| if possible. |
| 1015 if (!active_sessions_.empty() && !disable_connection_pooling_) { | 1027 if (!active_sessions_.empty() && !disable_connection_pooling_) { |
| 1016 for (const auto& key_value : active_sessions_) { | 1028 for (const auto& key_value : active_sessions_) { |
| 1017 QuicChromiumClientSession* session = key_value.second; | 1029 QuicChromiumClientSession* session = key_value.second; |
| 1018 if (destination.Equals(all_sessions_[session].destination()) && | 1030 if (destination.Equals(all_sessions_[session].destination()) && |
| 1019 session->CanPool(server_id.host(), server_id.privacy_mode())) { | 1031 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 | 1939 // Since the session was active, there's no longer an |
| 1928 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP | 1940 // 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 | 1941 // 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 | 1942 // it as recently broken, which means that 0-RTT will be disabled but we'll |
| 1931 // still race. | 1943 // still race. |
| 1932 http_server_properties_->MarkAlternativeServiceRecentlyBroken( | 1944 http_server_properties_->MarkAlternativeServiceRecentlyBroken( |
| 1933 alternative_service); | 1945 alternative_service); |
| 1934 } | 1946 } |
| 1935 | 1947 |
| 1936 } // namespace net | 1948 } // namespace net |
| OLD | NEW |