Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Side by Side Diff: net/quic/chromium/quic_stream_factory.cc

Issue 2329853002: Introduces ability for session to wait on a migration trigger for a new (Closed)
Patch Set: comments addressed Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/chromium/quic_stream_factory.h ('k') | net/quic/chromium/quic_stream_factory_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <openssl/aead.h> 7 #include <openssl/aead.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <tuple> 10 #include <tuple>
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 namespace { 66 namespace {
67 67
68 enum CreateSessionFailure { 68 enum CreateSessionFailure {
69 CREATION_ERROR_CONNECTING_SOCKET, 69 CREATION_ERROR_CONNECTING_SOCKET,
70 CREATION_ERROR_SETTING_RECEIVE_BUFFER, 70 CREATION_ERROR_SETTING_RECEIVE_BUFFER,
71 CREATION_ERROR_SETTING_SEND_BUFFER, 71 CREATION_ERROR_SETTING_SEND_BUFFER,
72 CREATION_ERROR_SETTING_DO_NOT_FRAGMENT, 72 CREATION_ERROR_SETTING_DO_NOT_FRAGMENT,
73 CREATION_ERROR_MAX 73 CREATION_ERROR_MAX
74 }; 74 };
75 75
76 enum QuicConnectionMigrationStatus {
77 MIGRATION_STATUS_NO_MIGRATABLE_STREAMS,
78 MIGRATION_STATUS_ALREADY_MIGRATED,
79 MIGRATION_STATUS_INTERNAL_ERROR,
80 MIGRATION_STATUS_TOO_MANY_CHANGES,
81 MIGRATION_STATUS_SUCCESS,
82 MIGRATION_STATUS_NON_MIGRATABLE_STREAM,
83 MIGRATION_STATUS_DISABLED,
84 MIGRATION_STATUS_NO_ALTERNATE_NETWORK,
85 MIGRATION_STATUS_MAX
86 };
87
88 // The maximum receive window sizes for QUIC sessions and streams. 76 // The maximum receive window sizes for QUIC sessions and streams.
89 const int32_t kQuicSessionMaxRecvWindowSize = 15 * 1024 * 1024; // 15 MB 77 const int32_t kQuicSessionMaxRecvWindowSize = 15 * 1024 * 1024; // 15 MB
90 const int32_t kQuicStreamMaxRecvWindowSize = 6 * 1024 * 1024; // 6 MB 78 const int32_t kQuicStreamMaxRecvWindowSize = 6 * 1024 * 1024; // 6 MB
91 79
92 // Set the maximum number of undecryptable packets the connection will store. 80 // Set the maximum number of undecryptable packets the connection will store.
93 const int32_t kMaxUndecryptablePackets = 100; 81 const int32_t kMaxUndecryptablePackets = 100;
94 82
95 std::unique_ptr<base::Value> NetLogQuicConnectionMigrationTriggerCallback( 83 std::unique_ptr<base::Value> NetLogQuicConnectionMigrationTriggerCallback(
96 std::string trigger, 84 std::string trigger,
97 NetLogCaptureMode capture_mode) { 85 NetLogCaptureMode capture_mode) {
(...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 void QuicStreamFactory::OnIPAddressChanged() { 1429 void QuicStreamFactory::OnIPAddressChanged() {
1442 num_timeouts_with_open_streams_ = 0; 1430 num_timeouts_with_open_streams_ = 0;
1443 status_ = OPEN; 1431 status_ = OPEN;
1444 CloseAllSessions(ERR_NETWORK_CHANGED, QUIC_IP_ADDRESS_CHANGED); 1432 CloseAllSessions(ERR_NETWORK_CHANGED, QUIC_IP_ADDRESS_CHANGED);
1445 set_require_confirmation(true); 1433 set_require_confirmation(true);
1446 } 1434 }
1447 1435
1448 void QuicStreamFactory::OnNetworkConnected(NetworkHandle network) { 1436 void QuicStreamFactory::OnNetworkConnected(NetworkHandle network) {
1449 num_timeouts_with_open_streams_ = 0; 1437 num_timeouts_with_open_streams_ = 0;
1450 status_ = OPEN; 1438 status_ = OPEN;
1439 ScopedConnectionMigrationEventLog scoped_event_log(net_log_,
1440 "OnNetworkConnected");
1441 for (auto session : all_sessions_) {
1442 session.first->OnNetworkConnected(network, scoped_event_log.net_log());
1443 }
1451 } 1444 }
1452 1445
1453 void QuicStreamFactory::OnNetworkMadeDefault(NetworkHandle network) { 1446 void QuicStreamFactory::OnNetworkMadeDefault(NetworkHandle network) {
1454 ScopedConnectionMigrationEventLog scoped_event_log(net_log_, 1447 ScopedConnectionMigrationEventLog scoped_event_log(net_log_,
1455 "OnNetworkMadeDefault"); 1448 "OnNetworkMadeDefault");
1456 DCHECK_NE(NetworkChangeNotifier::kInvalidNetworkHandle, network); 1449 DCHECK_NE(NetworkChangeNotifier::kInvalidNetworkHandle, network);
1457 MaybeMigrateOrCloseSessions(network, /*close_if_cannot_migrate=*/false, 1450 MaybeMigrateOrCloseSessions(network, /*close_if_cannot_migrate=*/false,
1458 scoped_event_log.net_log()); 1451 scoped_event_log.net_log());
1459 set_require_confirmation(true); 1452 set_require_confirmation(true);
1460 } 1453 }
(...skipping 24 matching lines...) Expand all
1485 1478
1486 void QuicStreamFactory::MaybeMigrateOrCloseSessions( 1479 void QuicStreamFactory::MaybeMigrateOrCloseSessions(
1487 NetworkHandle new_network, 1480 NetworkHandle new_network,
1488 bool close_if_cannot_migrate, 1481 bool close_if_cannot_migrate,
1489 const BoundNetLog& bound_net_log) { 1482 const BoundNetLog& bound_net_log) {
1490 QuicStreamFactory::SessionIdMap::iterator it = all_sessions_.begin(); 1483 QuicStreamFactory::SessionIdMap::iterator it = all_sessions_.begin();
1491 while (it != all_sessions_.end()) { 1484 while (it != all_sessions_.end()) {
1492 QuicChromiumClientSession* session = it->first; 1485 QuicChromiumClientSession* session = it->first;
1493 ++it; 1486 ++it;
1494 1487
1495 // Migration attempted, but no new network was found. Close session.
1496 if (new_network == NetworkChangeNotifier::kInvalidNetworkHandle) {
1497 HistogramAndLogMigrationFailure(
1498 bound_net_log, MIGRATION_STATUS_NO_ALTERNATE_NETWORK,
1499 session->connection_id(), "No alternate network found");
1500 session->CloseSessionOnError(ERR_NETWORK_CHANGED,
1501 QUIC_CONNECTION_MIGRATION_NO_NEW_NETWORK);
1502 continue;
1503 }
1504
1505 // If session is already bound to |new_network|, move on. 1488 // If session is already bound to |new_network|, move on.
1506 if (session->GetDefaultSocket()->GetBoundNetwork() == new_network) { 1489 if (session->GetDefaultSocket()->GetBoundNetwork() == new_network) {
1507 HistogramAndLogMigrationFailure( 1490 HistogramAndLogMigrationFailure(
1508 bound_net_log, MIGRATION_STATUS_ALREADY_MIGRATED, 1491 bound_net_log, MIGRATION_STATUS_ALREADY_MIGRATED,
1509 session->connection_id(), "Already bound to new network"); 1492 session->connection_id(), "Already bound to new network");
1510 continue; 1493 continue;
1511 } 1494 }
1512 1495
1513 // Close idle sessions. 1496 // Close idle sessions.
1514 if (session->GetNumActiveStreams() == 0) { 1497 if (session->GetNumActiveStreams() == 0) {
(...skipping 26 matching lines...) Expand all
1541 bound_net_log, MIGRATION_STATUS_NON_MIGRATABLE_STREAM, 1524 bound_net_log, MIGRATION_STATUS_NON_MIGRATABLE_STREAM,
1542 session->connection_id(), "Non-migratable stream"); 1525 session->connection_id(), "Non-migratable stream");
1543 if (close_if_cannot_migrate) { 1526 if (close_if_cannot_migrate) {
1544 session->CloseSessionOnError( 1527 session->CloseSessionOnError(
1545 ERR_NETWORK_CHANGED, 1528 ERR_NETWORK_CHANGED,
1546 QUIC_CONNECTION_MIGRATION_NON_MIGRATABLE_STREAM); 1529 QUIC_CONNECTION_MIGRATION_NON_MIGRATABLE_STREAM);
1547 } 1530 }
1548 continue; 1531 continue;
1549 } 1532 }
1550 1533
1534 // No new network was found. Notify session, so it can wait for a
1535 // new network.
1536 if (new_network == NetworkChangeNotifier::kInvalidNetworkHandle) {
1537 session->OnNoNewNetwork();
1538 continue;
1539 }
1540
1551 MigrateSessionToNewNetwork(session, new_network, 1541 MigrateSessionToNewNetwork(session, new_network,
1552 /*close_session_on_error=*/true, bound_net_log); 1542 /*close_session_on_error=*/true, bound_net_log);
1553 } 1543 }
1554 } 1544 }
1555 1545
1556 MigrationResult QuicStreamFactory::MaybeMigrateSingleSession( 1546 MigrationResult QuicStreamFactory::MaybeMigrateSingleSession(
1557 QuicChromiumClientSession* session, 1547 QuicChromiumClientSession* session,
1558 MigrationCause migration_cause) { 1548 MigrationCause migration_cause) {
1559 ScopedConnectionMigrationEventLog scoped_event_log( 1549 ScopedConnectionMigrationEventLog scoped_event_log(
1560 net_log_, 1550 net_log_,
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
1845 socket_performance_watcher = 1835 socket_performance_watcher =
1846 socket_performance_watcher_factory_->CreateSocketPerformanceWatcher( 1836 socket_performance_watcher_factory_->CreateSocketPerformanceWatcher(
1847 SocketPerformanceWatcherFactory::PROTOCOL_QUIC); 1837 SocketPerformanceWatcherFactory::PROTOCOL_QUIC);
1848 } 1838 }
1849 1839
1850 *session = new QuicChromiumClientSession( 1840 *session = new QuicChromiumClientSession(
1851 connection, std::move(socket), this, quic_crypto_client_stream_factory_, 1841 connection, std::move(socket), this, quic_crypto_client_stream_factory_,
1852 clock_.get(), transport_security_state_, std::move(server_info), 1842 clock_.get(), transport_security_state_, std::move(server_info),
1853 server_id, yield_after_packets_, yield_after_duration_, cert_verify_flags, 1843 server_id, yield_after_packets_, yield_after_duration_, cert_verify_flags,
1854 config, &crypto_config_, network_connection_.GetDescription(), 1844 config, &crypto_config_, network_connection_.GetDescription(),
1855 dns_resolution_end_time, &push_promise_index_, 1845 dns_resolution_end_time, &push_promise_index_, task_runner_,
1856 base::ThreadTaskRunnerHandle::Get().get(),
1857 std::move(socket_performance_watcher), net_log.net_log()); 1846 std::move(socket_performance_watcher), net_log.net_log());
1858 1847
1859 all_sessions_[*session] = key; // owning pointer 1848 all_sessions_[*session] = key; // owning pointer
1860 writer->set_delegate(*session); 1849 writer->set_delegate(*session);
1861 1850
1862 (*session)->Initialize(); 1851 (*session)->Initialize();
1863 bool closed_during_initialize = !base::ContainsKey(all_sessions_, *session) || 1852 bool closed_during_initialize = !base::ContainsKey(all_sessions_, *session) ||
1864 !(*session)->connection()->connected(); 1853 !(*session)->connection()->connected();
1865 UMA_HISTOGRAM_BOOLEAN("Net.QuicSession.ClosedDuringInitializeSession", 1854 UMA_HISTOGRAM_BOOLEAN("Net.QuicSession.ClosedDuringInitializeSession",
1866 closed_during_initialize); 1855 closed_during_initialize);
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
2050 // Since the session was active, there's no longer an 2039 // Since the session was active, there's no longer an
2051 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP 2040 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP
2052 // job also fails. So to avoid not using QUIC when we otherwise could, we mark 2041 // job also fails. So to avoid not using QUIC when we otherwise could, we mark
2053 // it as recently broken, which means that 0-RTT will be disabled but we'll 2042 // it as recently broken, which means that 0-RTT will be disabled but we'll
2054 // still race. 2043 // still race.
2055 http_server_properties_->MarkAlternativeServiceRecentlyBroken( 2044 http_server_properties_->MarkAlternativeServiceRecentlyBroken(
2056 alternative_service); 2045 alternative_service);
2057 } 2046 }
2058 2047
2059 } // namespace net 2048 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/chromium/quic_stream_factory.h ('k') | net/quic/chromium/quic_stream_factory_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698