[dds] Extract sending debugger URIs into a method that can be called by other adapters

Flutter needs to send Debugger URIs to the client in some cases where we're not connected ourselves (profile mode, where the IDE wants a VM Service for DevTools, but is not debugging).

Change-Id: I901ca02be7c0bfff5130f2e41b83923b1d518e76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249300
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
diff --git a/pkg/dds/lib/src/dap/adapters/dart.dart b/pkg/dds/lib/src/dap/adapters/dart.dart
index bf7cf96..b028eb1 100644
--- a/pkg/dds/lib/src/dap/adapters/dart.dart
+++ b/pkg/dds/lib/src/dap/adapters/dart.dart
@@ -580,15 +580,8 @@
     final vmService = await _vmServiceConnectUri(uri.toString());
     logger?.call('Connected to debugger at $uri!');
 
-    // Send a custom event with the VM Service URI as the editor might want to
-    // know about this (for example so it can connect an embedded DevTools to
-    // this app).
-    sendEvent(
-      RawEventBody({
-        'vmServiceUri': uri.toString(),
-      }),
-      eventType: 'dart.debuggerUris',
-    );
+    // Send debugger URI to the client.
+    sendDebuggerUris(uri);
 
     this.vmService = vmService;
 
@@ -631,6 +624,18 @@
     _debuggerInitializedCompleter.complete();
   }
 
+  void sendDebuggerUris(Uri uri) {
+    // Send a custom event with the VM Service URI as the editor might want to
+    // know about this (for example so it can connect an embedded DevTools to
+    // this app).
+    sendEvent(
+      RawEventBody({
+        'vmServiceUri': uri.toString(),
+      }),
+      eventType: 'dart.debuggerUris',
+    );
+  }
+
   /// Process any existing isolates that may have been created before the
   /// streams above were set up.
   Future<void> _configureExistingIsolates(