[bt][hci] Remove dispatcher from SequentialCommandRunner

Remove unused async dispatcher from SequentialCommandRunner.

Bug: 100594
Test: fx test bt-host-hci-tests
Change-Id: I082d3c9d5bdd06c6b58f4b63620d808c3c82be82
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/682672
Commit-Queue: Ben Lawson <benlawson@google.com>
Reviewed-by: Faraaz Sareshwala <fsareshwala@google.com>
diff --git a/pw_bluetooth_sapphire/host/gap/adapter.cc b/pw_bluetooth_sapphire/host/gap/adapter.cc
index c2b6433..8ec3046 100644
--- a/pw_bluetooth_sapphire/host/gap/adapter.cc
+++ b/pw_bluetooth_sapphire/host/gap/adapter.cc
@@ -447,7 +447,7 @@
   ZX_DEBUG_ASSERT(gatt_);
   ZX_DEBUG_ASSERT_MSG(dispatcher_, "must create on a thread with a dispatcher");
 
-  init_seq_runner_ = std::make_unique<hci::SequentialCommandRunner>(dispatcher_, hci_);
+  init_seq_runner_ = std::make_unique<hci::SequentialCommandRunner>(hci_);
 
   auto self = weak_ptr_factory_.GetWeakPtr();
   hci_->SetTransportClosedCallback([self] {
diff --git a/pw_bluetooth_sapphire/host/gap/bredr_connection_manager.cc b/pw_bluetooth_sapphire/host/gap/bredr_connection_manager.cc
index 25a43c7..0cf9334 100644
--- a/pw_bluetooth_sapphire/host/gap/bredr_connection_manager.cc
+++ b/pw_bluetooth_sapphire/host/gap/bredr_connection_manager.cc
@@ -152,7 +152,7 @@
   ZX_DEBUG_ASSERT(l2cap_);
   ZX_DEBUG_ASSERT(dispatcher_);
 
-  hci_cmd_runner_ = std::make_unique<hci::SequentialCommandRunner>(dispatcher_, hci_);
+  hci_cmd_runner_ = std::make_unique<hci::SequentialCommandRunner>(hci_);
 
   // Register event handlers
   AddEventHandler(hci_spec::kAuthenticationCompleteEventCode,
diff --git a/pw_bluetooth_sapphire/host/gap/bredr_interrogator.cc b/pw_bluetooth_sapphire/host/gap/bredr_interrogator.cc
index fedb7f6..4e765f9 100644
--- a/pw_bluetooth_sapphire/host/gap/bredr_interrogator.cc
+++ b/pw_bluetooth_sapphire/host/gap/bredr_interrogator.cc
@@ -4,7 +4,6 @@
 
 #include "bredr_interrogator.h"
 
-#include <lib/async/default.h>
 #include <zircon/assert.h>
 
 #include "src/connectivity/bluetooth/core/bt-host/gap/peer.h"
@@ -19,7 +18,7 @@
       peer_(std::move(peer)),
       peer_id_(peer_->identifier()),
       handle_(handle),
-      cmd_runner_(async_get_default_dispatcher(), hci_),
+      cmd_runner_(hci_),
       weak_ptr_factory_(this) {
   ZX_ASSERT(peer_);
 }
diff --git a/pw_bluetooth_sapphire/host/gap/bredr_interrogator.h b/pw_bluetooth_sapphire/host/gap/bredr_interrogator.h
index 988bf25..79cbcfa 100644
--- a/pw_bluetooth_sapphire/host/gap/bredr_interrogator.h
+++ b/pw_bluetooth_sapphire/host/gap/bredr_interrogator.h
@@ -5,8 +5,6 @@
 #ifndef SRC_CONNECTIVITY_BLUETOOTH_CORE_BT_HOST_GAP_BREDR_INTERROGATOR_H_
 #define SRC_CONNECTIVITY_BLUETOOTH_CORE_BT_HOST_GAP_BREDR_INTERROGATOR_H_
 
-#include <lib/async/cpp/task.h>
-#include <lib/async/dispatcher.h>
 #include <lib/fit/function.h>
 
 #include <memory>
diff --git a/pw_bluetooth_sapphire/host/gap/low_energy_interrogator.cc b/pw_bluetooth_sapphire/host/gap/low_energy_interrogator.cc
index 15a9a66..c02ba16 100644
--- a/pw_bluetooth_sapphire/host/gap/low_energy_interrogator.cc
+++ b/pw_bluetooth_sapphire/host/gap/low_energy_interrogator.cc
@@ -4,8 +4,6 @@
 
 #include "src/connectivity/bluetooth/core/bt-host/gap/low_energy_interrogator.h"
 
-#include <lib/async/default.h>
-
 #include "src/connectivity/bluetooth/core/bt-host/gap/peer.h"
 #include "src/connectivity/bluetooth/core/bt-host/hci-spec/protocol.h"
 #include "src/connectivity/bluetooth/core/bt-host/transport/transport.h"
@@ -19,7 +17,7 @@
       peer_(std::move(peer)),
       peer_id_(peer_->identifier()),
       handle_(handle),
-      cmd_runner_(async_get_default_dispatcher(), hci_),
+      cmd_runner_(hci_),
       weak_ptr_factory_(this) {}
 
 void LowEnergyInterrogator::Start(ResultCallback callback) {
diff --git a/pw_bluetooth_sapphire/host/hci/low_energy_advertiser.cc b/pw_bluetooth_sapphire/host/hci/low_energy_advertiser.cc
index ce3b36a..4b72901 100644
--- a/pw_bluetooth_sapphire/host/hci/low_energy_advertiser.cc
+++ b/pw_bluetooth_sapphire/host/hci/low_energy_advertiser.cc
@@ -4,15 +4,12 @@
 
 #include "low_energy_advertiser.h"
 
-#include "lib/async/default.h"
 #include "src/connectivity/bluetooth/core/bt-host/hci/sequential_command_runner.h"
 
 namespace bt::hci {
 
 LowEnergyAdvertiser::LowEnergyAdvertiser(fxl::WeakPtr<Transport> hci)
-    : hci_(std::move(hci)),
-      hci_cmd_runner_(
-          std::make_unique<SequentialCommandRunner>(async_get_default_dispatcher(), hci_)) {}
+    : hci_(std::move(hci)), hci_cmd_runner_(std::make_unique<SequentialCommandRunner>(hci_)) {}
 
 fitx::result<HostError> LowEnergyAdvertiser::CanStartAdvertising(
     const DeviceAddress& address, const AdvertisingData& data, const AdvertisingData& scan_rsp,
diff --git a/pw_bluetooth_sapphire/host/hci/low_energy_scanner.cc b/pw_bluetooth_sapphire/host/hci/low_energy_scanner.cc
index 2895478..2d258f8 100644
--- a/pw_bluetooth_sapphire/host/hci/low_energy_scanner.cc
+++ b/pw_bluetooth_sapphire/host/hci/low_energy_scanner.cc
@@ -27,7 +27,7 @@
   ZX_DEBUG_ASSERT(transport_);
   ZX_DEBUG_ASSERT(dispatcher_);
 
-  hci_cmd_runner_ = std::make_unique<SequentialCommandRunner>(dispatcher_, transport_);
+  hci_cmd_runner_ = std::make_unique<SequentialCommandRunner>(transport_);
 }
 
 }  // namespace bt::hci
diff --git a/pw_bluetooth_sapphire/host/hci/sequential_command_runner.cc b/pw_bluetooth_sapphire/host/hci/sequential_command_runner.cc
index 4322239..ec09898 100644
--- a/pw_bluetooth_sapphire/host/hci/sequential_command_runner.cc
+++ b/pw_bluetooth_sapphire/host/hci/sequential_command_runner.cc
@@ -10,14 +10,11 @@
 
 namespace bt::hci {
 
-SequentialCommandRunner::SequentialCommandRunner(async_dispatcher_t* dispatcher,
-                                                 fxl::WeakPtr<Transport> transport)
-    : dispatcher_(dispatcher),
-      transport_(std::move(transport)),
+SequentialCommandRunner::SequentialCommandRunner(fxl::WeakPtr<Transport> transport)
+    : transport_(std::move(transport)),
       sequence_number_(0u),
       running_commands_(0u),
       weak_ptr_factory_(this) {
-  ZX_DEBUG_ASSERT(dispatcher_);
   ZX_DEBUG_ASSERT(transport_);
 }
 
diff --git a/pw_bluetooth_sapphire/host/hci/sequential_command_runner.h b/pw_bluetooth_sapphire/host/hci/sequential_command_runner.h
index 6627d3a..bfbb67b 100644
--- a/pw_bluetooth_sapphire/host/hci/sequential_command_runner.h
+++ b/pw_bluetooth_sapphire/host/hci/sequential_command_runner.h
@@ -48,7 +48,7 @@
 // RunCommands will report success.
 class SequentialCommandRunner final {
  public:
-  SequentialCommandRunner(async_dispatcher_t* dispatcher, fxl::WeakPtr<Transport> transport);
+  explicit SequentialCommandRunner(fxl::WeakPtr<Transport> transport);
   ~SequentialCommandRunner() = default;
 
   // Adds a HCI command packet to the queue.
@@ -131,7 +131,6 @@
   void Reset();
   void NotifyStatusAndReset(Result<> status);
 
-  async_dispatcher_t* dispatcher_;
   fxl::WeakPtr<Transport> transport_;
 
   std::queue<QueuedCommand> command_queue_;
diff --git a/pw_bluetooth_sapphire/host/hci/sequential_command_runner_unittest.cc b/pw_bluetooth_sapphire/host/hci/sequential_command_runner_unittest.cc
index b69e5a3..8a3491a 100644
--- a/pw_bluetooth_sapphire/host/hci/sequential_command_runner_unittest.cc
+++ b/pw_bluetooth_sapphire/host/hci/sequential_command_runner_unittest.cc
@@ -89,7 +89,7 @@
   auto cb = [&](const EventPacket& event) { cb_called++; };
 
   // Sequence 1 (test)
-  SequentialCommandRunner cmd_runner(dispatcher(), transport()->WeakPtr());
+  SequentialCommandRunner cmd_runner(transport()->WeakPtr());
   EXPECT_FALSE(cmd_runner.HasQueuedCommands());
 
   cmd_runner.QueueCommand(CommandPacket::New(kTestOpCode), cb);
@@ -220,7 +220,7 @@
   auto cb = [&](const EventPacket& event) { cb_called++; };
 
   // Sequence 1: Sequence will be cancelled after the first command.
-  SequentialCommandRunner cmd_runner(dispatcher(), transport()->WeakPtr());
+  SequentialCommandRunner cmd_runner(transport()->WeakPtr());
   cmd_runner.QueueCommand(CommandPacket::New(kTestOpCode), cb);
   cmd_runner.QueueCommand(CommandPacket::New(kTestOpCode), cb);
   EXPECT_TRUE(cmd_runner.IsReady());
@@ -370,7 +370,7 @@
     status_cb_called++;
   };
 
-  SequentialCommandRunner cmd_runner(dispatcher(), transport()->WeakPtr());
+  SequentialCommandRunner cmd_runner(transport()->WeakPtr());
 
   cmd_runner.QueueCommand(CommandPacket::New(kTestOpCode), cb, /*wait=*/false);
   cmd_runner.QueueCommand(CommandPacket::New(kTestOpCode2), cb, /*wait=*/false);
@@ -462,7 +462,7 @@
   int cb_called = 0;
   auto cb = [&](const EventPacket& event) { cb_called++; };
 
-  SequentialCommandRunner cmd_runner(dispatcher(), transport()->WeakPtr());
+  SequentialCommandRunner cmd_runner(transport()->WeakPtr());
   EXPECT_FALSE(cmd_runner.HasQueuedCommands());
 
   EXPECT_CMD_PACKET_OUT(test_device(), command, &command0_status_event);
@@ -514,7 +514,7 @@
   int cb_called = 0;
   auto cb = [&](const EventPacket& event) { cb_called++; };
 
-  SequentialCommandRunner cmd_runner(dispatcher(), transport()->WeakPtr());
+  SequentialCommandRunner cmd_runner(transport()->WeakPtr());
   EXPECT_FALSE(cmd_runner.HasQueuedCommands());
 
   EXPECT_CMD_PACKET_OUT(test_device(), command, &command0_status_event);
@@ -575,7 +575,7 @@
   int cb_called = 0;
   auto cb = [&](const EventPacket& event) { cb_called++; };
 
-  SequentialCommandRunner cmd_runner(dispatcher(), transport()->WeakPtr());
+  SequentialCommandRunner cmd_runner(transport()->WeakPtr());
   EXPECT_FALSE(cmd_runner.HasQueuedCommands());
 
   EXPECT_CMD_PACKET_OUT(test_device(), command, &command0_status_event);
@@ -621,7 +621,7 @@
       /*conn=*/0x0000, hci_spec::LESupportedFeatures{0});
 
   std::optional<SequentialCommandRunner> cmd_runner;
-  cmd_runner.emplace(dispatcher(), transport()->WeakPtr());
+  cmd_runner.emplace(transport()->WeakPtr());
 
   StartTestDevice();
 
@@ -667,7 +667,7 @@
        SequentialCommandRunnerDestroyedInCancelStatusCallbackDoesNotCrash) {
   StartTestDevice();
   std::optional<SequentialCommandRunner> cmd_runner;
-  cmd_runner.emplace(dispatcher(), transport()->WeakPtr());
+  cmd_runner.emplace(transport()->WeakPtr());
 
   Result<> status = fitx::ok();
   int status_cb_called = 0;
@@ -713,7 +713,7 @@
 
   StartTestDevice();
 
-  SequentialCommandRunner cmd_runner(dispatcher(), transport()->WeakPtr());
+  SequentialCommandRunner cmd_runner(transport()->WeakPtr());
 
   Result<> status = fitx::ok();
   int status_cb_called = 0;