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

Unified Diff: net/quic/chromium/quic_stream_factory.cc

Issue 2258893004: Changes connection migration code to migrate on NetworkMadeDefault (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments addressed. Created 4 years, 4 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/chromium/quic_stream_factory.cc
diff --git a/net/quic/chromium/quic_stream_factory.cc b/net/quic/chromium/quic_stream_factory.cc
index 944a27f256aecaa422cbc8c0e49e9f0d26c2488e..da68c24fb41e41bb9147ca829fbc96e048b8670b 100644
--- a/net/quic/chromium/quic_stream_factory.cc
+++ b/net/quic/chromium/quic_stream_factory.cc
@@ -1454,24 +1454,26 @@ void QuicStreamFactory::OnNetworkConnected(NetworkHandle network) {
status_ = OPEN;
}
-void QuicStreamFactory::OnNetworkMadeDefault(NetworkHandle network) {}
+void QuicStreamFactory::OnNetworkMadeDefault(NetworkHandle network) {
+ ScopedConnectionMigrationEventLog scoped_event_log(net_log_,
+ "OnNetworkMadeDefault");
+ DCHECK_NE(NetworkChangeNotifier::kInvalidNetworkHandle, network);
+ MaybeMigrateOrCloseSessions(network, /*close_if_cannot_migrate=*/false,
+ scoped_event_log.net_log());
+ set_require_confirmation(true);
+}
void QuicStreamFactory::OnNetworkDisconnected(NetworkHandle network) {
ScopedConnectionMigrationEventLog scoped_event_log(net_log_,
"OnNetworkDisconnected");
- MaybeMigrateOrCloseSessions(network, /*force_close=*/true,
+ NetworkHandle new_network = FindAlternateNetwork(network);
+ MaybeMigrateOrCloseSessions(new_network, /*close_if_cannot_migrate=*/true,
scoped_event_log.net_log());
- set_require_confirmation(true);
}
// This method is expected to only be called when migrating from Cellular to
-// WiFi on Android.
-void QuicStreamFactory::OnNetworkSoonToDisconnect(NetworkHandle network) {
- ScopedConnectionMigrationEventLog scoped_event_log(
- net_log_, "OnNetworkSoonToDisconnect");
- MaybeMigrateOrCloseSessions(network, /*force_close=*/false,
- scoped_event_log.net_log());
-}
+// WiFi on Android, and should always be preceded by OnNetworkMadeDefault().
+void QuicStreamFactory::OnNetworkSoonToDisconnect(NetworkHandle network) {}
NetworkHandle QuicStreamFactory::FindAlternateNetwork(
NetworkHandle old_network) {
@@ -1486,26 +1488,34 @@ NetworkHandle QuicStreamFactory::FindAlternateNetwork(
}
void QuicStreamFactory::MaybeMigrateOrCloseSessions(
- NetworkHandle network,
- bool force_close,
+ NetworkHandle new_network,
+ bool close_if_cannot_migrate,
const BoundNetLog& bound_net_log) {
- DCHECK_NE(NetworkChangeNotifier::kInvalidNetworkHandle, network);
- NetworkHandle new_network = FindAlternateNetwork(network);
-
QuicStreamFactory::SessionIdMap::iterator it = all_sessions_.begin();
while (it != all_sessions_.end()) {
QuicChromiumClientSession* session = it->first;
++it;
- if (session->GetDefaultSocket()->GetBoundNetwork() != network) {
- // If session is not bound to |network|, move on.
+ // Migration attempted, but no new network was found. Close session.
+ if (new_network == NetworkChangeNotifier::kInvalidNetworkHandle) {
+ HistogramAndLogMigrationFailure(
+ bound_net_log, MIGRATION_STATUS_NO_ALTERNATE_NETWORK,
+ session->connection_id(), "No alternate network found");
+ session->CloseSessionOnError(ERR_NETWORK_CHANGED,
+ QUIC_CONNECTION_MIGRATION_NO_NEW_NETWORK);
+ continue;
+ }
+
+ // If session is already bound to |new_network|, move on.
+ if (session->GetDefaultSocket()->GetBoundNetwork() == new_network) {
HistogramAndLogMigrationFailure(
bound_net_log, MIGRATION_STATUS_ALREADY_MIGRATED,
- session->connection_id(), "Not bound to network");
+ session->connection_id(), "Already bound to new network");
continue;
}
+
+ // Close idle sessions.
if (session->GetNumActiveStreams() == 0) {
- // Close idle sessions.
HistogramAndLogMigrationFailure(
bound_net_log, MIGRATION_STATUS_NO_MIGRATABLE_STREAMS,
session->connection_id(), "No active sessions");
@@ -1513,42 +1523,28 @@ void QuicStreamFactory::MaybeMigrateOrCloseSessions(
ERR_NETWORK_CHANGED, QUIC_CONNECTION_MIGRATION_NO_MIGRATABLE_STREAMS);
continue;
}
+
// If session has active streams, mark it as going away.
OnSessionGoingAway(session);
- if (new_network == NetworkChangeNotifier::kInvalidNetworkHandle) {
- // No new network was found.
- // TODO (jri): Add histogram for this failure case.
- bound_net_log.AddEvent(
- NetLog::TYPE_QUIC_CONNECTION_MIGRATION_FAILURE,
- base::Bind(&NetLogQuicConnectionMigrationFailureCallback,
- session->connection_id(), "No new network"));
- if (force_close) {
- session->CloseSessionOnError(ERR_NETWORK_CHANGED,
- QUIC_CONNECTION_MIGRATION_NO_NEW_NETWORK);
- }
- continue;
- }
+ // Do not migrate sessions where connection migration is disabled.
if (session->config()->DisableConnectionMigration()) {
- // Do not migrate sessions where connection migration is disabled by
- // config.
HistogramAndLogMigrationFailure(bound_net_log, MIGRATION_STATUS_DISABLED,
session->connection_id(),
"Migration disabled");
- if (force_close) {
- // Close sessions where connection migration is disabled.
+ if (close_if_cannot_migrate) {
session->CloseSessionOnError(ERR_NETWORK_CHANGED,
QUIC_IP_ADDRESS_CHANGED);
}
continue;
}
+
+ // Do not migrate sessions with non-migratable streams.
if (session->HasNonMigratableStreams()) {
- // Do not migrate sessions with non-migratable streams.
HistogramAndLogMigrationFailure(
bound_net_log, MIGRATION_STATUS_NON_MIGRATABLE_STREAM,
session->connection_id(), "Non-migratable stream");
- if (force_close) {
- // Close sessions with non-migratable streams.
+ if (close_if_cannot_migrate) {
session->CloseSessionOnError(
ERR_NETWORK_CHANGED,
QUIC_CONNECTION_MIGRATION_NON_MIGRATABLE_STREAM);
« 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