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_chromium_client_session.h" | 5 #include "net/quic/chromium/quic_chromium_client_session.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
13 #include "base/metrics/sparse_histogram.h" | 13 #include "base/metrics/sparse_histogram.h" |
14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
17 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
18 #include "base/values.h" | 18 #include "base/values.h" |
19 #include "net/base/io_buffer.h" | 19 #include "net/base/io_buffer.h" |
20 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
21 #include "net/base/network_activity_monitor.h" | 21 #include "net/base/network_activity_monitor.h" |
22 #include "net/http/http_log_util.h" | 22 #include "net/http/http_log_util.h" |
23 #include "net/http/transport_security_state.h" | 23 #include "net/http/transport_security_state.h" |
| 24 #include "net/log/net_log_event_type.h" |
| 25 #include "net/log/net_log_source_type.h" |
24 #include "net/quic/chromium/crypto/proof_verifier_chromium.h" | 26 #include "net/quic/chromium/crypto/proof_verifier_chromium.h" |
25 #include "net/quic/chromium/quic_chromium_connection_helper.h" | 27 #include "net/quic/chromium/quic_chromium_connection_helper.h" |
26 #include "net/quic/chromium/quic_chromium_packet_writer.h" | 28 #include "net/quic/chromium/quic_chromium_packet_writer.h" |
27 #include "net/quic/chromium/quic_stream_factory.h" | 29 #include "net/quic/chromium/quic_stream_factory.h" |
28 #include "net/quic/core/crypto/quic_server_info.h" | 30 #include "net/quic/core/crypto/quic_server_info.h" |
29 #include "net/quic/core/quic_client_promised_info.h" | 31 #include "net/quic/core/quic_client_promised_info.h" |
30 #include "net/quic/core/quic_crypto_client_stream_factory.h" | 32 #include "net/quic/core/quic_crypto_client_stream_factory.h" |
31 #include "net/spdy/spdy_session.h" | 33 #include "net/spdy/spdy_session.h" |
32 #include "net/ssl/channel_id_service.h" | 34 #include "net/ssl/channel_id_service.h" |
33 #include "net/ssl/ssl_connection_status_flags.h" | 35 #include "net/ssl/ssl_connection_status_flags.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 NetLog* net_log) | 220 NetLog* net_log) |
219 : QuicClientSessionBase(connection, push_promise_index, config), | 221 : QuicClientSessionBase(connection, push_promise_index, config), |
220 server_id_(server_id), | 222 server_id_(server_id), |
221 require_confirmation_(false), | 223 require_confirmation_(false), |
222 stream_factory_(stream_factory), | 224 stream_factory_(stream_factory), |
223 transport_security_state_(transport_security_state), | 225 transport_security_state_(transport_security_state), |
224 server_info_(std::move(server_info)), | 226 server_info_(std::move(server_info)), |
225 pkp_bypassed_(false), | 227 pkp_bypassed_(false), |
226 num_total_streams_(0), | 228 num_total_streams_(0), |
227 task_runner_(task_runner), | 229 task_runner_(task_runner), |
228 net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_QUIC_SESSION)), | 230 net_log_(BoundNetLog::Make(net_log, NetLogSourceType::QUIC_SESSION)), |
229 dns_resolution_end_time_(dns_resolution_end_time), | 231 dns_resolution_end_time_(dns_resolution_end_time), |
230 logger_(new QuicConnectionLogger(this, | 232 logger_(new QuicConnectionLogger(this, |
231 connection_description, | 233 connection_description, |
232 std::move(socket_performance_watcher), | 234 std::move(socket_performance_watcher), |
233 net_log_)), | 235 net_log_)), |
234 going_away_(false), | 236 going_away_(false), |
235 port_migration_detected_(false), | 237 port_migration_detected_(false), |
236 disabled_reason_(QUIC_DISABLED_NOT), | 238 disabled_reason_(QUIC_DISABLED_NOT), |
237 token_binding_signatures_(kTokenBindingSignatureMapSize), | 239 token_binding_signatures_(kTokenBindingSignatureMapSize), |
238 streams_pushed_count_(0), | 240 streams_pushed_count_(0), |
239 streams_pushed_and_claimed_count_(0), | 241 streams_pushed_and_claimed_count_(0), |
240 error_code_from_rewrite_(OK), | 242 error_code_from_rewrite_(OK), |
241 use_error_code_from_rewrite_(false), | 243 use_error_code_from_rewrite_(false), |
242 weak_factory_(this) { | 244 weak_factory_(this) { |
243 sockets_.push_back(std::move(socket)); | 245 sockets_.push_back(std::move(socket)); |
244 packet_readers_.push_back(base::WrapUnique(new QuicChromiumPacketReader( | 246 packet_readers_.push_back(base::WrapUnique(new QuicChromiumPacketReader( |
245 sockets_.back().get(), clock, this, yield_after_packets, | 247 sockets_.back().get(), clock, this, yield_after_packets, |
246 yield_after_duration, net_log_))); | 248 yield_after_duration, net_log_))); |
247 crypto_stream_.reset( | 249 crypto_stream_.reset( |
248 crypto_client_stream_factory->CreateQuicCryptoClientStream( | 250 crypto_client_stream_factory->CreateQuicCryptoClientStream( |
249 server_id, this, base::WrapUnique(new ProofVerifyContextChromium( | 251 server_id, this, base::WrapUnique(new ProofVerifyContextChromium( |
250 cert_verify_flags, net_log_)), | 252 cert_verify_flags, net_log_)), |
251 crypto_config)); | 253 crypto_config)); |
252 connection->set_debug_visitor(logger_.get()); | 254 connection->set_debug_visitor(logger_.get()); |
253 connection->set_creator_debug_delegate(logger_.get()); | 255 connection->set_creator_debug_delegate(logger_.get()); |
254 net_log_.BeginEvent(NetLog::TYPE_QUIC_SESSION, | 256 net_log_.BeginEvent(NetLogEventType::QUIC_SESSION, |
255 base::Bind(NetLogQuicClientSessionCallback, &server_id, | 257 base::Bind(NetLogQuicClientSessionCallback, &server_id, |
256 cert_verify_flags, require_confirmation_)); | 258 cert_verify_flags, require_confirmation_)); |
257 IPEndPoint address; | 259 IPEndPoint address; |
258 if (socket && socket->GetLocalAddress(&address) == OK && | 260 if (socket && socket->GetLocalAddress(&address) == OK && |
259 address.GetFamily() == ADDRESS_FAMILY_IPV6) { | 261 address.GetFamily() == ADDRESS_FAMILY_IPV6) { |
260 connection->SetMaxPacketLength(connection->max_packet_length() - | 262 connection->SetMaxPacketLength(connection->max_packet_length() - |
261 kAdditionalOverheadForIPv6); | 263 kAdditionalOverheadForIPv6); |
262 } | 264 } |
263 } | 265 } |
264 | 266 |
265 QuicChromiumClientSession::~QuicChromiumClientSession() { | 267 QuicChromiumClientSession::~QuicChromiumClientSession() { |
266 if (!dynamic_streams().empty()) | 268 if (!dynamic_streams().empty()) |
267 RecordUnexpectedOpenStreams(DESTRUCTOR); | 269 RecordUnexpectedOpenStreams(DESTRUCTOR); |
268 if (!observers_.empty()) | 270 if (!observers_.empty()) |
269 RecordUnexpectedObservers(DESTRUCTOR); | 271 RecordUnexpectedObservers(DESTRUCTOR); |
270 if (!going_away_) | 272 if (!going_away_) |
271 RecordUnexpectedNotGoingAway(DESTRUCTOR); | 273 RecordUnexpectedNotGoingAway(DESTRUCTOR); |
272 | 274 |
273 while (!dynamic_streams().empty() || !observers_.empty() || | 275 while (!dynamic_streams().empty() || !observers_.empty() || |
274 !stream_requests_.empty()) { | 276 !stream_requests_.empty()) { |
275 // The session must be closed before it is destroyed. | 277 // The session must be closed before it is destroyed. |
276 DCHECK(dynamic_streams().empty()); | 278 DCHECK(dynamic_streams().empty()); |
277 CloseAllStreams(ERR_UNEXPECTED); | 279 CloseAllStreams(ERR_UNEXPECTED); |
278 DCHECK(observers_.empty()); | 280 DCHECK(observers_.empty()); |
279 CloseAllObservers(ERR_UNEXPECTED); | 281 CloseAllObservers(ERR_UNEXPECTED); |
280 | 282 |
281 connection()->set_debug_visitor(nullptr); | 283 connection()->set_debug_visitor(nullptr); |
282 net_log_.EndEvent(NetLog::TYPE_QUIC_SESSION); | 284 net_log_.EndEvent(NetLogEventType::QUIC_SESSION); |
283 | 285 |
284 while (!stream_requests_.empty()) { | 286 while (!stream_requests_.empty()) { |
285 StreamRequest* request = stream_requests_.front(); | 287 StreamRequest* request = stream_requests_.front(); |
286 stream_requests_.pop_front(); | 288 stream_requests_.pop_front(); |
287 request->OnRequestCompleteFailure(ERR_ABORTED); | 289 request->OnRequestCompleteFailure(ERR_ABORTED); |
288 } | 290 } |
289 } | 291 } |
290 | 292 |
291 if (connection()->connected()) { | 293 if (connection()->connected()) { |
292 // Ensure that the connection is closed by the time the session is | 294 // Ensure that the connection is closed by the time the session is |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 } | 1033 } |
1032 | 1034 |
1033 void QuicChromiumClientSession::CloseSessionOnErrorInner( | 1035 void QuicChromiumClientSession::CloseSessionOnErrorInner( |
1034 int net_error, | 1036 int net_error, |
1035 QuicErrorCode quic_error) { | 1037 QuicErrorCode quic_error) { |
1036 if (!callback_.is_null()) { | 1038 if (!callback_.is_null()) { |
1037 base::ResetAndReturn(&callback_).Run(net_error); | 1039 base::ResetAndReturn(&callback_).Run(net_error); |
1038 } | 1040 } |
1039 CloseAllStreams(net_error); | 1041 CloseAllStreams(net_error); |
1040 CloseAllObservers(net_error); | 1042 CloseAllObservers(net_error); |
1041 net_log_.AddEvent(NetLog::TYPE_QUIC_SESSION_CLOSE_ON_ERROR, | 1043 net_log_.AddEvent(NetLogEventType::QUIC_SESSION_CLOSE_ON_ERROR, |
1042 NetLog::IntCallback("net_error", net_error)); | 1044 NetLog::IntCallback("net_error", net_error)); |
1043 | 1045 |
1044 if (connection()->connected()) | 1046 if (connection()->connected()) |
1045 connection()->CloseConnection(quic_error, "net error", | 1047 connection()->CloseConnection(quic_error, "net error", |
1046 ConnectionCloseBehavior::SILENT_CLOSE); | 1048 ConnectionCloseBehavior::SILENT_CLOSE); |
1047 DCHECK(!connection()->connected()); | 1049 DCHECK(!connection()->connected()); |
1048 } | 1050 } |
1049 | 1051 |
1050 void QuicChromiumClientSession::CloseAllStreams(int net_error) { | 1052 void QuicChromiumClientSession::CloseAllStreams(int net_error) { |
1051 while (!dynamic_streams().empty()) { | 1053 while (!dynamic_streams().empty()) { |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1214 if (!static_cast<QuicChromiumClientStream*>(stream.second)->can_migrate()) | 1216 if (!static_cast<QuicChromiumClientStream*>(stream.second)->can_migrate()) |
1215 return true; | 1217 return true; |
1216 } | 1218 } |
1217 return false; | 1219 return false; |
1218 } | 1220 } |
1219 | 1221 |
1220 void QuicChromiumClientSession::HandlePromised(QuicStreamId id, | 1222 void QuicChromiumClientSession::HandlePromised(QuicStreamId id, |
1221 QuicStreamId promised_id, | 1223 QuicStreamId promised_id, |
1222 const SpdyHeaderBlock& headers) { | 1224 const SpdyHeaderBlock& headers) { |
1223 QuicClientSessionBase::HandlePromised(id, promised_id, headers); | 1225 QuicClientSessionBase::HandlePromised(id, promised_id, headers); |
1224 net_log_.AddEvent(NetLog::TYPE_QUIC_SESSION_PUSH_PROMISE_RECEIVED, | 1226 net_log_.AddEvent(NetLogEventType::QUIC_SESSION_PUSH_PROMISE_RECEIVED, |
1225 base::Bind(&NetLogQuicPushPromiseReceivedCallback, &headers, | 1227 base::Bind(&NetLogQuicPushPromiseReceivedCallback, &headers, |
1226 id, promised_id)); | 1228 id, promised_id)); |
1227 } | 1229 } |
1228 | 1230 |
1229 void QuicChromiumClientSession::DeletePromised( | 1231 void QuicChromiumClientSession::DeletePromised( |
1230 QuicClientPromisedInfo* promised) { | 1232 QuicClientPromisedInfo* promised) { |
1231 if (IsOpenStream(promised->id())) | 1233 if (IsOpenStream(promised->id())) |
1232 streams_pushed_and_claimed_count_++; | 1234 streams_pushed_and_claimed_count_++; |
1233 QuicClientSessionBase::DeletePromised(promised); | 1235 QuicClientSessionBase::DeletePromised(promised); |
1234 } | 1236 } |
1235 | 1237 |
1236 } // namespace net | 1238 } // namespace net |
OLD | NEW |