| 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/quic_stream_factory.h" | 5 #include "net/quic/quic_stream_factory.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/cpu.h" | 9 #include "base/cpu.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/message_loop/message_loop_proxy.h" | |
| 12 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
| 13 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 14 #include "base/metrics/sparse_histogram.h" | 13 #include "base/metrics/sparse_histogram.h" |
| 15 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
| 16 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 17 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 18 #include "base/values.h" | 17 #include "base/values.h" |
| 19 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
| 20 #include "net/cert/cert_verifier.h" | 19 #include "net/cert/cert_verifier.h" |
| 21 #include "net/dns/host_resolver.h" | 20 #include "net/dns/host_resolver.h" |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 | 636 |
| 638 if (HasActiveJob(server_id)) { | 637 if (HasActiveJob(server_id)) { |
| 639 active_requests_[request] = server_id; | 638 active_requests_[request] = server_id; |
| 640 job_requests_map_[server_id].insert(request); | 639 job_requests_map_[server_id].insert(request); |
| 641 return ERR_IO_PENDING; | 640 return ERR_IO_PENDING; |
| 642 } | 641 } |
| 643 | 642 |
| 644 // TODO(rtenneti): |task_runner_| is used by the Job. Initialize task_runner_ | 643 // TODO(rtenneti): |task_runner_| is used by the Job. Initialize task_runner_ |
| 645 // in the constructor after WebRequestActionWithThreadsTest.* tests are fixed. | 644 // in the constructor after WebRequestActionWithThreadsTest.* tests are fixed. |
| 646 if (!task_runner_) | 645 if (!task_runner_) |
| 647 task_runner_ = base::MessageLoop::current()->message_loop_proxy().get(); | 646 task_runner_ = base::MessageLoop::current()->task_runner().get(); |
| 648 | 647 |
| 649 QuicServerInfo* quic_server_info = nullptr; | 648 QuicServerInfo* quic_server_info = nullptr; |
| 650 if (quic_server_info_factory_) { | 649 if (quic_server_info_factory_) { |
| 651 bool load_from_disk_cache = !disable_disk_cache_; | 650 bool load_from_disk_cache = !disable_disk_cache_; |
| 652 if (http_server_properties_) { | 651 if (http_server_properties_) { |
| 653 const AlternativeServiceMap& alternative_service_map = | 652 const AlternativeServiceMap& alternative_service_map = |
| 654 http_server_properties_->alternative_service_map(); | 653 http_server_properties_->alternative_service_map(); |
| 655 AlternativeServiceMap::const_iterator it = | 654 AlternativeServiceMap::const_iterator it = |
| 656 alternative_service_map.Peek(server_id.host_port_pair()); | 655 alternative_service_map.Peek(server_id.host_port_pair()); |
| 657 if (it == alternative_service_map.end() || | 656 if (it == alternative_service_map.end() || |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 if (http_server_properties_->GetSupportsQuic(&last_address) && | 1036 if (http_server_properties_->GetSupportsQuic(&last_address) && |
| 1038 last_address == local_address_.address()) { | 1037 last_address == local_address_.address()) { |
| 1039 require_confirmation_ = false; | 1038 require_confirmation_ = false; |
| 1040 } | 1039 } |
| 1041 } | 1040 } |
| 1042 | 1041 |
| 1043 DefaultPacketWriterFactory packet_writer_factory(socket.get()); | 1042 DefaultPacketWriterFactory packet_writer_factory(socket.get()); |
| 1044 | 1043 |
| 1045 if (!helper_.get()) { | 1044 if (!helper_.get()) { |
| 1046 helper_.reset(new QuicConnectionHelper( | 1045 helper_.reset(new QuicConnectionHelper( |
| 1047 base::MessageLoop::current()->message_loop_proxy().get(), | 1046 base::MessageLoop::current()->task_runner().get(), clock_.get(), |
| 1048 clock_.get(), random_generator_)); | 1047 random_generator_)); |
| 1049 } | 1048 } |
| 1050 | 1049 |
| 1051 QuicConnection* connection = new QuicConnection( | 1050 QuicConnection* connection = new QuicConnection( |
| 1052 connection_id, addr, helper_.get(), packet_writer_factory, | 1051 connection_id, addr, helper_.get(), packet_writer_factory, |
| 1053 true /* owns_writer */, Perspective::IS_CLIENT, server_id.is_https(), | 1052 true /* owns_writer */, Perspective::IS_CLIENT, server_id.is_https(), |
| 1054 supported_versions_); | 1053 supported_versions_); |
| 1055 connection->set_max_packet_length(max_packet_length_); | 1054 connection->set_max_packet_length(max_packet_length_); |
| 1056 | 1055 |
| 1057 InitializeCachedStateInCryptoConfig(server_id, server_info); | 1056 InitializeCachedStateInCryptoConfig(server_id, server_info); |
| 1058 | 1057 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1071 // information and/or inform the disk cache that we have reused | 1070 // information and/or inform the disk cache that we have reused |
| 1072 // |server_info|. | 1071 // |server_info|. |
| 1073 server_info.reset(quic_server_info_factory_->GetForServer(server_id)); | 1072 server_info.reset(quic_server_info_factory_->GetForServer(server_id)); |
| 1074 server_info->Start(); | 1073 server_info->Start(); |
| 1075 } | 1074 } |
| 1076 | 1075 |
| 1077 *session = new QuicClientSession( | 1076 *session = new QuicClientSession( |
| 1078 connection, socket.Pass(), this, transport_security_state_, | 1077 connection, socket.Pass(), this, transport_security_state_, |
| 1079 server_info.Pass(), config, network_connection_.GetDescription(), | 1078 server_info.Pass(), config, network_connection_.GetDescription(), |
| 1080 dns_resolution_end_time, | 1079 dns_resolution_end_time, |
| 1081 base::MessageLoop::current()->message_loop_proxy().get(), | 1080 base::MessageLoop::current()->task_runner().get(), net_log.net_log()); |
| 1082 net_log.net_log()); | |
| 1083 | 1081 |
| 1084 all_sessions_[*session] = server_id; // owning pointer | 1082 all_sessions_[*session] = server_id; // owning pointer |
| 1085 | 1083 |
| 1086 (*session)->InitializeSession(server_id, &crypto_config_, | 1084 (*session)->InitializeSession(server_id, &crypto_config_, |
| 1087 quic_crypto_client_stream_factory_); | 1085 quic_crypto_client_stream_factory_); |
| 1088 bool closed_during_initialize = | 1086 bool closed_during_initialize = |
| 1089 !ContainsKey(all_sessions_, *session) || | 1087 !ContainsKey(all_sessions_, *session) || |
| 1090 !(*session)->connection()->connected(); | 1088 !(*session)->connection()->connected(); |
| 1091 UMA_HISTOGRAM_BOOLEAN("Net.QuicSession.ClosedDuringInitializeSession", | 1089 UMA_HISTOGRAM_BOOLEAN("Net.QuicSession.ClosedDuringInitializeSession", |
| 1092 closed_during_initialize); | 1090 closed_during_initialize); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1223 // Since the session was active, there's no longer an | 1221 // Since the session was active, there's no longer an |
| 1224 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP | 1222 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP |
| 1225 // job also fails. So to avoid not using QUIC when we otherwise could, we mark | 1223 // job also fails. So to avoid not using QUIC when we otherwise could, we mark |
| 1226 // it as recently broken, which means that 0-RTT will be disabled but we'll | 1224 // it as recently broken, which means that 0-RTT will be disabled but we'll |
| 1227 // still race. | 1225 // still race. |
| 1228 http_server_properties_->MarkAlternativeServiceRecentlyBroken( | 1226 http_server_properties_->MarkAlternativeServiceRecentlyBroken( |
| 1229 alternative_service); | 1227 alternative_service); |
| 1230 } | 1228 } |
| 1231 | 1229 |
| 1232 } // namespace net | 1230 } // namespace net |
| OLD | NEW |