Rename methods in QuicConnectionMigrationManager for readability. Callback methods like FinishFoo() are renamed to ContinueFoo() if Foo() is async or DoneWithFoo() if it merely does clean up.

Also refactor error handling of FinishTryMigrateBackToDefaultNetwork().

PiperOrigin-RevId: 852791120
diff --git a/quiche/quic/core/http/quic_connection_migration_manager.cc b/quiche/quic/core/http/quic_connection_migration_manager.cc
index 9ea5cf1..ea1a7ac 100644
--- a/quiche/quic/core/http/quic_connection_migration_manager.cc
+++ b/quiche/quic/core/http/quic_connection_migration_manager.cc
@@ -278,7 +278,7 @@
     }
     // `wait_for_new_network_` is true, there was no working network previously.
     // `network` is now the only possible candidate, migrate immediately.
-    MigrateNetworkImmediately(network);
+    StartMigrateNetworkImmediately(network);
   } else {
     // The connection is path degrading.
     QUICHE_DCHECK(connection_->IsPathDegrading());
@@ -359,10 +359,10 @@
   }
   // Current network is being disconnected, migrate immediately to the
   // alternative network.
-  MigrateNetworkImmediately(new_network);
+  StartMigrateNetworkImmediately(new_network);
 }
 
-void QuicConnectionMigrationManager::MigrateNetworkImmediately(
+void QuicConnectionMigrationManager::StartMigrateNetworkImmediately(
     QuicNetworkHandle network) {
   // There is no choice but to migrate to |network|. If any error encountered,
   // close the session. When migration succeeds:
@@ -402,7 +402,7 @@
   Migrate(network, connection_->peer_address(),
           /*close_session_on_error=*/true,
           [this](QuicNetworkHandle network, MigrationResult result) {
-            FinishMigrateNetworkImmediately(network, result);
+            DoneWithMigrateNetworkImmediately(network, result);
           });
 }
 
@@ -418,8 +418,9 @@
 void QuicConnectionMigrationManager::
     PathContextCreationResultDelegateForImmediateMigration::OnCreationSucceeded(
         std::unique_ptr<QuicClientPathValidationContext> context) {
-  migration_manager_->FinishMigrate(std::move(context), close_session_on_error_,
-                                    std::move(migration_callback_));
+  migration_manager_->ContinueMigrating(std::move(context),
+                                        close_session_on_error_,
+                                        std::move(migration_callback_));
 }
 
 void QuicConnectionMigrationManager::
@@ -450,8 +451,8 @@
 void QuicConnectionMigrationManager::
     PathContextCreationResultDelegateForProbing::OnCreationSucceeded(
         std::unique_ptr<QuicClientPathValidationContext> context) {
-  migration_manager_->FinishStartProbing(std::move(probing_callback_),
-                                         std::move(context));
+  migration_manager_->ContinueProbing(std::move(probing_callback_),
+                                      std::move(context));
 }
 
 void QuicConnectionMigrationManager::
@@ -510,7 +511,7 @@
           this, close_session_on_error, std::move(migration_callback)));
 }
 
-void QuicConnectionMigrationManager::FinishMigrateNetworkImmediately(
+void QuicConnectionMigrationManager::DoneWithMigrateNetworkImmediately(
     QuicNetworkHandle network, MigrationResult result) {
   pending_migrate_network_immediately_ = false;
   if (result == MigrationResult::FAILURE) {
@@ -527,7 +528,7 @@
       QuicTimeDelta::FromSeconds(kMinRetryTimeForDefaultNetworkSecs));
 }
 
-void QuicConnectionMigrationManager::FinishMigrate(
+void QuicConnectionMigrationManager::ContinueMigrating(
     std::unique_ptr<QuicClientPathValidationContext> path_context,
     bool close_session_on_error, MigrationCallback callback) {
   // Migrate to the new socket.
@@ -703,14 +704,14 @@
   Migrate(new_network, connection_->peer_address(),
           /*close_session_on_error=*/false,
           [this](QuicNetworkHandle new_network, MigrationResult rv) {
-            FinishMigrateSessionOnWriteError(new_network, rv);
+            DoneWithMigratingSessionOnWriteError(new_network, rv);
           });
   if (debug_visitor_) {
     debug_visitor_->OnConnectionMigrationStarted();
   }
 }
 
-void QuicConnectionMigrationManager::FinishMigrateSessionOnWriteError(
+void QuicConnectionMigrationManager::DoneWithMigratingSessionOnWriteError(
     QuicNetworkHandle new_network, MigrationResult result) {
   pending_migrate_session_on_write_error_ = false;
   if (result == MigrationResult::FAILURE) {
@@ -891,15 +892,13 @@
         retry_migrate_back_count_);
   }
   if (!path_context_factory_) {
-    FinishTryMigrateBackToDefaultNetwork(
-        next_try_timeout, ProbingResult::DISABLED_WITH_IDLE_SESSION);
+    StopMigratingBackToDefaultNetwork();
     return;
   }
   if (MaybeCloseIdleSession(
           /*has_write_error=*/false,
           ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET)) {
-    FinishTryMigrateBackToDefaultNetwork(
-        next_try_timeout, ProbingResult::DISABLED_WITH_IDLE_SESSION);
+    StopMigratingBackToDefaultNetwork();
     return;
   }
   if (migration_disabled_) {
@@ -909,8 +908,7 @@
     OnMigrationFailure(
         QuicConnectionMigrationStatus::MIGRATION_STATUS_DISABLED_BY_CONFIG,
         "Migration disabled by config");
-    FinishTryMigrateBackToDefaultNetwork(next_try_timeout,
-                                         ProbingResult::DISABLED_BY_CONFIG);
+    StopMigratingBackToDefaultNetwork();
     return;
   }
   // Start probe default network immediately, if this observer is probing
@@ -919,23 +917,22 @@
   // immediately.
   StartProbing(
       [this, next_try_timeout](ProbingResult rv) {
-        FinishTryMigrateBackToDefaultNetwork(next_try_timeout, rv);
+        if (rv != ProbingResult::PENDING) {
+          StopMigratingBackToDefaultNetwork();
+          return;
+        }
+        ++retry_migrate_back_count_;
+        migrate_back_to_default_timer_->Set(clock_->ApproximateNow() +
+                                            next_try_timeout);
       },
       default_network_, connection_->peer_address());
 }
 
-void QuicConnectionMigrationManager::FinishTryMigrateBackToDefaultNetwork(
-    QuicTimeDelta next_try_timeout, ProbingResult result) {
-  if (result != ProbingResult::PENDING) {
-    // Session is not allowed to migrate, mark session as going away, cancel
-    // migrate back to default timer.
-    session_->StartDraining();
-    CancelMigrateBackToDefaultNetworkTimer();
-    return;
-  }
-  ++retry_migrate_back_count_;
-  migrate_back_to_default_timer_->Set(clock_->ApproximateNow() +
-                                      next_try_timeout);
+void QuicConnectionMigrationManager::StopMigratingBackToDefaultNetwork() {
+  // Session is not allowed to migrate, mark session as going away, cancel
+  // migrate back to default timer.
+  session_->StartDraining();
+  CancelMigrateBackToDefaultNetworkTimer();
 }
 
 void QuicConnectionMigrationManager::StartProbing(
@@ -959,7 +956,7 @@
           this, std::move(probing_callback)));
 }
 
-void QuicConnectionMigrationManager::FinishStartProbing(
+void QuicConnectionMigrationManager::ContinueProbing(
     StartProbingCallback probing_callback,
     std::unique_ptr<QuicClientPathValidationContext> path_context) {
   session_->PrepareForProbingOnPath(*path_context);
diff --git a/quiche/quic/core/http/quic_connection_migration_manager.h b/quiche/quic/core/http/quic_connection_migration_manager.h
index 4a29328..cba7b0b 100644
--- a/quiche/quic/core/http/quic_connection_migration_manager.h
+++ b/quiche/quic/core/http/quic_connection_migration_manager.h
@@ -309,10 +309,10 @@
   //    default network;
   //  - If now on the default network, cancel timer to migrate back to default
   //    network.
-  void MigrateNetworkImmediately(QuicNetworkHandle network);
+  void StartMigrateNetworkImmediately(QuicNetworkHandle network);
 
-  void FinishMigrateNetworkImmediately(QuicNetworkHandle network,
-                                       MigrationResult result);
+  void DoneWithMigrateNetworkImmediately(QuicNetworkHandle network,
+                                         MigrationResult result);
 
   // Migrates session over to use |peer_address| and |network|.
   // If |network| is kInvalidNetworkHandle, default network is used. If
@@ -322,7 +322,7 @@
                bool close_session_on_error,
                MigrationCallback migration_callback);
   // Helper to finish session migration once the |path_context| is provided.
-  void FinishMigrate(
+  void ContinueMigrating(
       std::unique_ptr<QuicClientPathValidationContext> path_context,
       bool close_session_on_error, MigrationCallback callback);
 
@@ -331,22 +331,21 @@
 
   void TryMigrateBackToDefaultNetwork(QuicTimeDelta next_try_timeout);
 
-  void FinishTryMigrateBackToDefaultNetwork(QuicTimeDelta next_try_timeout,
-                                            ProbingResult result);
+  void StopMigratingBackToDefaultNetwork();
 
   // Migration might happen asynchronously (async socket creation or no new
   // network).
   void StartMigrateSessionOnWriteError(QuicPacketWriter* writer);
 
-  void FinishMigrateSessionOnWriteError(QuicNetworkHandle new_network,
-                                        MigrationResult result);
+  void DoneWithMigratingSessionOnWriteError(QuicNetworkHandle new_network,
+                                            MigrationResult result);
 
   void MaybeProbeAndMigrateToAlternateNetworkOnPathDegrading();
 
   void StartProbing(StartProbingCallback probing_callback,
                     QuicNetworkHandle network,
                     const QuicSocketAddress& peer_address);
-  void FinishStartProbing(
+  void ContinueProbing(
       StartProbingCallback probing_callback,
       std::unique_ptr<QuicClientPathValidationContext> path_context);