Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 22cf6d97 authored by Wei-Luan Wang's avatar Wei-Luan Wang Committed by Jakub Pawłowski
Browse files

Migrate base::Bind to base::BindOnce for DoInThread

base::Bind and base::Callback are deprecated. Migrate the usages to
proper replacements.

The second argument of |DoInThread| is a base::OnceCallback so it's safe
to construct the callback using base::BindOnce.

Bug: 272116782
Test: m .
Flag: EXEMPT mechanical refactor
Change-Id: Ibc4f114a153d9d24e9246e7bd56f32b2bb059d99
parent c723c4a8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ void A2dpEncodingFuzzer::process(const uint8_t* data, size_t size) {
  std::string name = fdp.ConsumeRandomLengthString(kRandomStringLength);
  bluetooth::common::MessageLoopThread messageLoopThread(name);
  messageLoopThread.StartUp();
  messageLoopThread.DoInThread(FROM_HERE, base::Bind(&source_init_delayed));
  messageLoopThread.DoInThread(FROM_HERE, base::BindOnce(&source_init_delayed));

  uint16_t delayReport = fdp.ConsumeIntegral<uint16_t>();
  bluetooth::audio::a2dp::set_remote_delay(delayReport);
+1 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
  std::string name = fdp.ConsumeRandomLengthString(kRandomStringLength);
  bluetooth::common::MessageLoopThread messageLoopThread(name);
  messageLoopThread.StartUp();
  messageLoopThread.DoInThread(FROM_HERE, base::Bind(&source_init_delayed));
  messageLoopThread.DoInThread(FROM_HERE, base::BindOnce(&source_init_delayed));

  uint16_t delay = fdp.ConsumeIntegral<uint16_t>();
  bluetooth::audio::hearing_aid::set_remote_delay(delay);
+1 −1
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
  std::string name = fdp.ConsumeRandomLengthString(kRandomStringLength);
  bluetooth::common::MessageLoopThread messageLoopThread(name);
  messageLoopThread.StartUp();
  messageLoopThread.DoInThread(FROM_HERE, base::Bind(&source_init_delayed));
  messageLoopThread.DoInThread(FROM_HERE, base::BindOnce(&source_init_delayed));

  LeAudioClientInterface* interface = LeAudioClientInterface::Get();

+11 −11
Original line number Diff line number Diff line
@@ -335,7 +335,7 @@ bool btif_a2dp_source_init(void) {
  // Start A2DP Source media task
  btif_a2dp_source_thread.StartUp();
  btif_a2dp_source_thread.DoInThread(
      FROM_HERE, base::Bind(&btif_a2dp_source_init_delayed));
      FROM_HERE, base::BindOnce(&btif_a2dp_source_init_delayed));
  return true;
}

@@ -358,7 +358,7 @@ bool btif_a2dp_source_startup(void) {

  // Schedule the rest of the operations
  btif_a2dp_source_thread.DoInThread(
      FROM_HERE, base::Bind(&btif_a2dp_source_startup_delayed));
      FROM_HERE, base::BindOnce(&btif_a2dp_source_startup_delayed));

  return true;
}
@@ -460,7 +460,7 @@ bool btif_a2dp_source_end_session(const RawAddress& peer_address) {
           btif_a2dp_source_cb.StateStr().c_str());
  btif_a2dp_source_thread.DoInThread(
      FROM_HERE,
      base::Bind(&btif_a2dp_source_end_session_delayed, peer_address));
      base::BindOnce(&btif_a2dp_source_end_session_delayed, peer_address));
  btif_a2dp_source_cleanup_codec();
  return true;
}
@@ -531,7 +531,7 @@ void btif_a2dp_source_cleanup(void) {
  btif_a2dp_source_shutdown(std::move(shutdown_complete_promise));

  btif_a2dp_source_thread.DoInThread(
      FROM_HERE, base::Bind(&btif_a2dp_source_cleanup_delayed));
      FROM_HERE, base::BindOnce(&btif_a2dp_source_cleanup_delayed));

  // Exit the thread
  btif_a2dp_source_thread.ShutDown();
@@ -567,7 +567,7 @@ static void btif_a2dp_source_setup_codec(const RawAddress& peer_address) {
  btif_a2dp_source_audio_tx_flush_req();
  btif_a2dp_source_thread.DoInThread(
      FROM_HERE,
      base::Bind(&btif_a2dp_source_setup_codec_delayed, peer_address));
      base::BindOnce(&btif_a2dp_source_setup_codec_delayed, peer_address));
}

static void btif_a2dp_source_setup_codec_delayed(
@@ -614,7 +614,7 @@ static void btif_a2dp_source_cleanup_codec() {
  // Must stop media task first before cleaning up the encoder
  btif_a2dp_source_stop_audio_req();
  btif_a2dp_source_thread.DoInThread(
      FROM_HERE, base::Bind(&btif_a2dp_source_cleanup_codec_delayed));
      FROM_HERE, base::BindOnce(&btif_a2dp_source_cleanup_codec_delayed));
}

static void btif_a2dp_source_cleanup_codec_delayed() {
@@ -629,14 +629,14 @@ void btif_a2dp_source_start_audio_req(void) {
  LOG_INFO("%s: state=%s", __func__, btif_a2dp_source_cb.StateStr().c_str());

  btif_a2dp_source_thread.DoInThread(
      FROM_HERE, base::Bind(&btif_a2dp_source_audio_tx_start_event));
      FROM_HERE, base::BindOnce(&btif_a2dp_source_audio_tx_start_event));
}

void btif_a2dp_source_stop_audio_req(void) {
  LOG_INFO("%s: state=%s", __func__, btif_a2dp_source_cb.StateStr().c_str());

  btif_a2dp_source_thread.DoInThread(
      FROM_HERE, base::Bind(&btif_a2dp_source_audio_tx_stop_event));
      FROM_HERE, base::BindOnce(&btif_a2dp_source_audio_tx_stop_event));
}

void btif_a2dp_source_encoder_user_config_update_req(
@@ -702,7 +702,7 @@ void btif_a2dp_source_feeding_update_req(
    const btav_a2dp_codec_config_t& codec_audio_config) {
  LOG_INFO("%s: state=%s", __func__, btif_a2dp_source_cb.StateStr().c_str());
  btif_a2dp_source_thread.DoInThread(
      FROM_HERE, base::Bind(&btif_a2dp_source_audio_feeding_update_event,
      FROM_HERE, base::BindOnce(&btif_a2dp_source_audio_feeding_update_event,
                                codec_audio_config));
}

@@ -1080,7 +1080,7 @@ static bool btif_a2dp_source_audio_tx_flush_req(void) {
  LOG_INFO("%s: state=%s", __func__, btif_a2dp_source_cb.StateStr().c_str());

  btif_a2dp_source_thread.DoInThread(
      FROM_HERE, base::Bind(&btif_a2dp_source_audio_tx_flush_event));
      FROM_HERE, base::BindOnce(&btif_a2dp_source_audio_tx_flush_event));
  return true;
}

+4 −4
Original line number Diff line number Diff line
@@ -163,13 +163,13 @@ static void start_up_stack_async(bluetooth::core::CoreInterface* interface,
                                 ProfileStartCallback startProfiles,
                                 ProfileStopCallback stopProfiles) {
  management_thread.DoInThread(
      FROM_HERE,
      base::Bind(event_start_up_stack, interface, startProfiles, stopProfiles));
      FROM_HERE, base::BindOnce(event_start_up_stack, interface, startProfiles,
                                stopProfiles));
}

static void shut_down_stack_async(ProfileStopCallback stopProfiles) {
  management_thread.DoInThread(FROM_HERE,
                               base::Bind(event_shut_down_stack, stopProfiles));
  management_thread.DoInThread(
      FROM_HERE, base::BindOnce(event_shut_down_stack, stopProfiles));
}

static void clean_up_stack(ProfileStopCallback stopProfiles) {
Loading