In QuicConnection, add DCHECKS before using path_validator_.

PiperOrigin-RevId: 353679800
Change-Id: I184282e2eb677bd9e0d1037fb2ee500eafbbf866
diff --git a/quic/core/quic_connection.cc b/quic/core/quic_connection.cc
index aae0c57..2a4a482 100644
--- a/quic/core/quic_connection.cc
+++ b/quic/core/quic_connection.cc
@@ -4194,7 +4194,9 @@
   // Cancel the alarms so they don't trigger any action now that the
   // connection is closed.
   CancelAllAlarms();
-  CancelPathValidation();
+  if (use_path_validator_) {
+    CancelPathValidation();
+  }
 }
 
 void QuicConnection::CancelAllAlarms() {
@@ -5679,6 +5681,7 @@
 void QuicConnection::ValidatePath(
     std::unique_ptr<QuicPathValidationContext> context,
     std::unique_ptr<QuicPathValidator::ResultDelegate> result_delegate) {
+  DCHECK(use_path_validator_);
   if (perspective_ == Perspective::IS_CLIENT &&
       !IsDefaultPath(context->self_address(), context->peer_address())) {
     most_recent_alternative_path_ =
@@ -5744,14 +5747,17 @@
 }
 
 bool QuicConnection::HasPendingPathValidation() const {
+  DCHECK(use_path_validator_);
   return path_validator_.HasPendingPathValidation();
 }
 
 QuicPathValidationContext* QuicConnection::GetPathValidationContext() const {
+  DCHECK(use_path_validator_);
   return path_validator_.GetContext();
 }
 
 void QuicConnection::CancelPathValidation() {
+  DCHECK(use_path_validator_);
   path_validator_.CancelPathValidation();
 }