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 <openssl/aead.h> | 7 #include <openssl/aead.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <tuple> | 10 #include <tuple> |
(...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1436 session->connection_id(), "Non-migratable stream"); | 1436 session->connection_id(), "Non-migratable stream"); |
1437 if (force_close) { | 1437 if (force_close) { |
1438 // Close sessions with non-migratable streams. | 1438 // Close sessions with non-migratable streams. |
1439 session->CloseSessionOnError( | 1439 session->CloseSessionOnError( |
1440 ERR_NETWORK_CHANGED, | 1440 ERR_NETWORK_CHANGED, |
1441 QUIC_CONNECTION_MIGRATION_NON_MIGRATABLE_STREAM); | 1441 QUIC_CONNECTION_MIGRATION_NON_MIGRATABLE_STREAM); |
1442 } | 1442 } |
1443 continue; | 1443 continue; |
1444 } | 1444 } |
1445 | 1445 |
1446 MigrateSessionToNetwork(session, new_network, bound_net_log, nullptr); | 1446 MigrateSessionToNewNetwork(session, new_network, bound_net_log, nullptr); |
1447 } | 1447 } |
1448 } | 1448 } |
1449 | 1449 |
1450 void QuicStreamFactory::MaybeMigrateSingleSession( | 1450 void QuicStreamFactory::MaybeMigrateSingleSession( |
1451 QuicChromiumClientSession* session, | 1451 QuicChromiumClientSession* session, |
1452 MigrationCause migration_cause, | 1452 MigrationCause migration_cause, |
1453 scoped_refptr<StringIOBuffer> packet) { | 1453 scoped_refptr<StringIOBuffer> packet) { |
1454 ScopedConnectionMigrationEventLog scoped_event_log( | 1454 ScopedConnectionMigrationEventLog scoped_event_log( |
1455 net_log_, | 1455 net_log_, |
1456 migration_cause == EARLY_MIGRATION ? "EarlyMigration" : "WriteError"); | 1456 migration_cause == EARLY_MIGRATION ? "EarlyMigration" : "WriteError"); |
(...skipping 11 matching lines...) Expand all Loading... |
1468 if (new_network == NetworkChangeNotifier::kInvalidNetworkHandle) { | 1468 if (new_network == NetworkChangeNotifier::kInvalidNetworkHandle) { |
1469 // No alternate network found. | 1469 // No alternate network found. |
1470 // TODO (jri): Add histogram for this failure case. | 1470 // TODO (jri): Add histogram for this failure case. |
1471 scoped_event_log.net_log().AddEvent( | 1471 scoped_event_log.net_log().AddEvent( |
1472 NetLog::TYPE_QUIC_CONNECTION_MIGRATION_FAILURE, | 1472 NetLog::TYPE_QUIC_CONNECTION_MIGRATION_FAILURE, |
1473 base::Bind(&NetLogQuicConnectionMigrationFailureCallback, | 1473 base::Bind(&NetLogQuicConnectionMigrationFailureCallback, |
1474 session->connection_id(), "No new network")); | 1474 session->connection_id(), "No new network")); |
1475 return; | 1475 return; |
1476 } | 1476 } |
1477 OnSessionGoingAway(session); | 1477 OnSessionGoingAway(session); |
1478 MigrateSessionToNetwork(session, new_network, scoped_event_log.net_log(), | 1478 MigrateSessionToNewNetwork(session, new_network, scoped_event_log.net_log(), |
1479 packet); | 1479 packet); |
1480 } | 1480 } |
1481 | 1481 |
1482 void QuicStreamFactory::MigrateSessionToNetwork( | 1482 void QuicStreamFactory::MigrateSessionToNewPeerAddress( |
1483 QuicChromiumClientSession* session, | 1483 QuicChromiumClientSession* session, |
1484 NetworkHandle new_network, | 1484 IPEndPoint peer_address, |
1485 const BoundNetLog& bound_net_log, | 1485 const BoundNetLog& bound_net_log, |
1486 scoped_refptr<StringIOBuffer> packet) { | 1486 scoped_refptr<StringIOBuffer> packet) { |
| 1487 // Specifying kInvalidNetworkHandle for the |network| parameter |
| 1488 // causes the session to use the default network for the new socket. |
| 1489 MigrateSession(session, peer_address, |
| 1490 NetworkChangeNotifier::kInvalidNetworkHandle, bound_net_log, |
| 1491 packet); |
| 1492 } |
| 1493 |
| 1494 void QuicStreamFactory::MigrateSessionToNewNetwork( |
| 1495 QuicChromiumClientSession* session, |
| 1496 NetworkHandle network, |
| 1497 const BoundNetLog& bound_net_log, |
| 1498 scoped_refptr<StringIOBuffer> packet) { |
| 1499 MigrateSession(session, session->connection()->peer_address(), network, |
| 1500 bound_net_log, packet); |
| 1501 } |
| 1502 |
| 1503 void QuicStreamFactory::MigrateSession(QuicChromiumClientSession* session, |
| 1504 IPEndPoint peer_address, |
| 1505 NetworkHandle network, |
| 1506 const BoundNetLog& bound_net_log, |
| 1507 scoped_refptr<StringIOBuffer> packet) { |
1487 // Use OS-specified port for socket (DEFAULT_BIND) instead of | 1508 // Use OS-specified port for socket (DEFAULT_BIND) instead of |
1488 // using the PortSuggester since the connection is being migrated | 1509 // using the PortSuggester since the connection is being migrated |
1489 // and not being newly created. | 1510 // and not being newly created. |
1490 std::unique_ptr<DatagramClientSocket> socket( | 1511 std::unique_ptr<DatagramClientSocket> socket( |
1491 client_socket_factory_->CreateDatagramClientSocket( | 1512 client_socket_factory_->CreateDatagramClientSocket( |
1492 DatagramSocket::DEFAULT_BIND, RandIntCallback(), | 1513 DatagramSocket::DEFAULT_BIND, RandIntCallback(), |
1493 session->net_log().net_log(), session->net_log().source())); | 1514 session->net_log().net_log(), session->net_log().source())); |
1494 QuicConnection* connection = session->connection(); | 1515 if (ConfigureSocket(socket.get(), peer_address, network) != OK) { |
1495 if (ConfigureSocket(socket.get(), connection->peer_address(), new_network) != | |
1496 OK) { | |
1497 session->CloseSessionOnError(ERR_NETWORK_CHANGED, QUIC_INTERNAL_ERROR); | 1516 session->CloseSessionOnError(ERR_NETWORK_CHANGED, QUIC_INTERNAL_ERROR); |
1498 HistogramAndLogMigrationFailure( | 1517 HistogramAndLogMigrationFailure( |
1499 bound_net_log, MIGRATION_STATUS_INTERNAL_ERROR, | 1518 bound_net_log, MIGRATION_STATUS_INTERNAL_ERROR, |
1500 session->connection_id(), "Socket configuration failed"); | 1519 session->connection_id(), "Socket configuration failed"); |
1501 return; | 1520 return; |
1502 } | 1521 } |
1503 std::unique_ptr<QuicChromiumPacketReader> new_reader( | 1522 std::unique_ptr<QuicChromiumPacketReader> new_reader( |
1504 new QuicChromiumPacketReader(socket.get(), clock_.get(), session, | 1523 new QuicChromiumPacketReader(socket.get(), clock_.get(), session, |
1505 yield_after_packets_, yield_after_duration_, | 1524 yield_after_packets_, yield_after_duration_, |
1506 session->net_log())); | 1525 session->net_log())); |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1876 // Since the session was active, there's no longer an | 1895 // Since the session was active, there's no longer an |
1877 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP | 1896 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP |
1878 // job also fails. So to avoid not using QUIC when we otherwise could, we mark | 1897 // job also fails. So to avoid not using QUIC when we otherwise could, we mark |
1879 // it as recently broken, which means that 0-RTT will be disabled but we'll | 1898 // it as recently broken, which means that 0-RTT will be disabled but we'll |
1880 // still race. | 1899 // still race. |
1881 http_server_properties_->MarkAlternativeServiceRecentlyBroken( | 1900 http_server_properties_->MarkAlternativeServiceRecentlyBroken( |
1882 alternative_service); | 1901 alternative_service); |
1883 } | 1902 } |
1884 | 1903 |
1885 } // namespace net | 1904 } // namespace net |
OLD | NEW |