diff options
author | 2025-02-26 11:11:15 -0800 | |
---|---|---|
committer | 2025-02-26 11:11:15 -0800 | |
commit | cbdfceb481608b23233e166458b6fd3663a59cf7 (patch) | |
tree | 5f843b6a0cab06ca5c744d05ce53d6578eecd484 | |
parent | e10e5ee402afdf6ab2ff3eec8458873cddfe5d93 (diff) | |
parent | 43575e0877dfa260aca41b43bee795b7f00fb161 (diff) |
Merge "system/common: Remove location parameter from MessageLoopThread" into main
37 files changed, 153 insertions, 221 deletions
diff --git a/system/audio/asrc/asrc_resampler.cc b/system/audio/asrc/asrc_resampler.cc index 7e44d9ade6..a0dc25995c 100644 --- a/system/audio/asrc/asrc_resampler.cc +++ b/system/audio/asrc/asrc_resampler.cc @@ -170,7 +170,7 @@ public: : state_{.id = StateId::RESET}, reference_timing_{0, 0, 0} { if (com::android::bluetooth::flags::run_clock_recovery_in_worker_thread()) { read_clock_timer_.SchedulePeriodic( - thread->GetWeakPtr(), FROM_HERE, + thread->GetWeakPtr(), base::BindRepeating( [](void*) { bluetooth::shim::GetHciLayer()->EnqueueCommand( @@ -183,7 +183,7 @@ public: std::chrono::milliseconds(100)); } else { read_clock_timer_.SchedulePeriodic( - get_main_thread()->GetWeakPtr(), FROM_HERE, + get_main_thread()->GetWeakPtr(), base::BindRepeating( [](void*) { bluetooth::shim::GetHciLayer()->EnqueueCommand( diff --git a/system/audio_hal_interface/fuzzer/libbt_audio_hal_a2dp_encoding_fuzzer.cpp b/system/audio_hal_interface/fuzzer/libbt_audio_hal_a2dp_encoding_fuzzer.cpp index 64a85ddfe4..da0f17c726 100644 --- a/system/audio_hal_interface/fuzzer/libbt_audio_hal_a2dp_encoding_fuzzer.cpp +++ b/system/audio_hal_interface/fuzzer/libbt_audio_hal_a2dp_encoding_fuzzer.cpp @@ -92,7 +92,7 @@ void A2dpEncodingFuzzer::process(const uint8_t* data, size_t size) { bluetooth::common::MessageLoopThread messageLoopThread(name); messageLoopThread.StartUp(); - messageLoopThread.DoInThread(FROM_HERE, base::BindOnce(&source_init_delayed)); + messageLoopThread.DoInThread(base::BindOnce(&source_init_delayed)); uint16_t delayReport = fdp.ConsumeIntegral<uint16_t>(); bluetooth::audio::a2dp::set_remote_delay(delayReport); diff --git a/system/audio_hal_interface/fuzzer/libbt_audio_hal_le_audio_software_fuzzer.cpp b/system/audio_hal_interface/fuzzer/libbt_audio_hal_le_audio_software_fuzzer.cpp index e382dbeb62..82f8b224a7 100644 --- a/system/audio_hal_interface/fuzzer/libbt_audio_hal_le_audio_software_fuzzer.cpp +++ b/system/audio_hal_interface/fuzzer/libbt_audio_hal_le_audio_software_fuzzer.cpp @@ -51,7 +51,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::BindOnce(&source_init_delayed)); + messageLoopThread.DoInThread(base::BindOnce(&source_init_delayed)); LeAudioClientInterface* interface = LeAudioClientInterface::Get(); diff --git a/system/audio_hal_interface/hidl/client_interface_hidl.cc b/system/audio_hal_interface/hidl/client_interface_hidl.cc index 4bea626d5b..4a633a47f1 100644 --- a/system/audio_hal_interface/hidl/client_interface_hidl.cc +++ b/system/audio_hal_interface/hidl/client_interface_hidl.cc @@ -163,7 +163,6 @@ public: if (bluetooth_audio_clientif_ != nullptr && message_loop_ != nullptr) { // restart the session on the correct thread message_loop_->DoInThread( - FROM_HERE, base::BindOnce(&BluetoothAudioClientInterface::RenewAudioProviderAndSession, base::Unretained(bluetooth_audio_clientif_))); } else { diff --git a/system/bta/hearing_aid/hearing_aid_audio_source.cc b/system/bta/hearing_aid/hearing_aid_audio_source.cc index 1f4c68e516..51714a5f70 100644 --- a/system/bta/hearing_aid/hearing_aid_audio_source.cc +++ b/system/bta/hearing_aid/hearing_aid_audio_source.cc @@ -100,7 +100,7 @@ void start_audio_ticks() { } wakelock_acquire(); - audio_timer.SchedulePeriodic(get_main_thread()->GetWeakPtr(), FROM_HERE, + audio_timer.SchedulePeriodic(get_main_thread()->GetWeakPtr(), base::BindRepeating(&send_audio_data), std::chrono::milliseconds(data_interval_ms)); log::info("running with data interval: {}", data_interval_ms); diff --git a/system/bta/le_audio/audio_hal_client/audio_hal_client_test.cc b/system/bta/le_audio/audio_hal_client/audio_hal_client_test.cc index cabdee4a64..8618670c0e 100644 --- a/system/bta/le_audio/audio_hal_client/audio_hal_client_test.cc +++ b/system/bta/le_audio/audio_hal_client/audio_hal_client_test.cc @@ -55,7 +55,7 @@ using namespace bluetooth; bluetooth::common::MessageLoopThread message_loop_thread("test message loop"); bluetooth::common::MessageLoopThread* get_main_thread() { return &message_loop_thread; } bt_status_t do_in_main_thread(base::OnceClosure task) { - if (!message_loop_thread.DoInThread(FROM_HERE, std::move(task))) { + if (!message_loop_thread.DoInThread(std::move(task))) { log::error("failed to post task to task runner!"); return BT_STATUS_FAIL; } diff --git a/system/bta/le_audio/audio_hal_client/audio_source_hal_client.cc b/system/bta/le_audio/audio_hal_client/audio_source_hal_client.cc index 7ff5196256..33af17284b 100644 --- a/system/bta/le_audio/audio_hal_client/audio_source_hal_client.cc +++ b/system/bta/le_audio/audio_hal_client/audio_source_hal_client.cc @@ -264,7 +264,7 @@ void SourceImpl::StartAudioTicks() { worker_thread_, source_codec_config_.num_channels, source_codec_config_.sample_rate, source_codec_config_.bits_per_sample, source_codec_config_.data_interval_us); audio_timer_.SchedulePeriodic( - worker_thread_->GetWeakPtr(), FROM_HERE, + worker_thread_->GetWeakPtr(), base::BindRepeating(&SourceImpl::SendAudioData, weak_factory_.GetWeakPtr()), std::chrono::microseconds(source_codec_config_.data_interval_us)); } @@ -280,7 +280,7 @@ bool SourceImpl::OnSuspendReq() { if (CodecManager::GetInstance()->GetCodecLocation() == types::CodecLocation::HOST) { if (com::android::bluetooth::flags::run_ble_audio_ticks_in_worker_thread()) { worker_thread_->DoInThread( - FROM_HERE, base::BindOnce(&SourceImpl::StopAudioTicks, weak_factory_.GetWeakPtr())); + base::BindOnce(&SourceImpl::StopAudioTicks, weak_factory_.GetWeakPtr())); } else { StopAudioTicks(); } @@ -382,7 +382,7 @@ void SourceImpl::Stop() { if (CodecManager::GetInstance()->GetCodecLocation() == types::CodecLocation::HOST) { if (com::android::bluetooth::flags::run_ble_audio_ticks_in_worker_thread()) { worker_thread_->DoInThread( - FROM_HERE, base::BindOnce(&SourceImpl::StopAudioTicks, weak_factory_.GetWeakPtr())); + base::BindOnce(&SourceImpl::StopAudioTicks, weak_factory_.GetWeakPtr())); } else { StopAudioTicks(); } @@ -407,7 +407,7 @@ void SourceImpl::ConfirmStreamingRequest() { if (com::android::bluetooth::flags::run_ble_audio_ticks_in_worker_thread()) { worker_thread_->DoInThread( - FROM_HERE, base::BindOnce(&SourceImpl::StartAudioTicks, weak_factory_.GetWeakPtr())); + base::BindOnce(&SourceImpl::StartAudioTicks, weak_factory_.GetWeakPtr())); } else { StartAudioTicks(); } diff --git a/system/bta/le_audio/broadcaster/broadcaster_test.cc b/system/bta/le_audio/broadcaster/broadcaster_test.cc index 44e6bf7815..28bfcfb24c 100644 --- a/system/bta/le_audio/broadcaster/broadcaster_test.cc +++ b/system/bta/le_audio/broadcaster/broadcaster_test.cc @@ -96,13 +96,12 @@ void invoke_switch_buffer_size_cb(bool /*is_low_latency_buffer_size*/) {} bt_status_t do_in_main_thread(base::OnceClosure task) { // Wrap the task with task counter so we could later know if there are // any callbacks scheduled and we should wait before performing some actions - if (!message_loop_thread.DoInThread( - FROM_HERE, base::BindOnce( - [](base::OnceClosure task, std::atomic<int>& num_async_tasks) { - std::move(task).Run(); - num_async_tasks--; - }, - std::move(task), std::ref(num_async_tasks)))) { + if (!message_loop_thread.DoInThread(base::BindOnce( + [](base::OnceClosure task, std::atomic<int>& num_async_tasks) { + std::move(task).Run(); + num_async_tasks--; + }, + std::move(task), std::ref(num_async_tasks)))) { log::error("failed to post task to task runner!"); return BT_STATUS_FAIL; } diff --git a/system/bta/le_audio/le_audio_client_test.cc b/system/bta/le_audio/le_audio_client_test.cc index e681444250..a8fdad50ca 100644 --- a/system/bta/le_audio/le_audio_client_test.cc +++ b/system/bta/le_audio/le_audio_client_test.cc @@ -116,13 +116,12 @@ bluetooth::common::MessageLoopThread* get_main_thread() { return &message_loop_t bt_status_t do_in_main_thread(base::OnceClosure task) { // Wrap the task with task counter so we could later know if there are // any callbacks scheduled and we should wait before performing some actions - if (!message_loop_thread.DoInThread( - FROM_HERE, base::BindOnce( - [](base::OnceClosure task, std::atomic<int>& num_async_tasks) { - std::move(task).Run(); - num_async_tasks--; - }, - std::move(task), std::ref(num_async_tasks)))) { + if (!message_loop_thread.DoInThread(base::BindOnce( + [](base::OnceClosure task, std::atomic<int>& num_async_tasks) { + std::move(task).Run(); + num_async_tasks--; + }, + std::move(task), std::ref(num_async_tasks)))) { bluetooth::log::error("failed to post task to task runner!"); return BT_STATUS_FAIL; } diff --git a/system/btif/src/btif_a2dp_sink.cc b/system/btif/src/btif_a2dp_sink.cc index 0328ba9cbc..e2258d35f2 100644 --- a/system/btif/src/btif_a2dp_sink.cc +++ b/system/btif/src/btif_a2dp_sink.cc @@ -207,8 +207,7 @@ bool btif_a2dp_sink_init() { log::fatal("Failed to increase A2DP decoder thread priority"); #endif } - btif_a2dp_sink_cb.worker_thread.DoInThread(FROM_HERE, - base::BindOnce(btif_a2dp_sink_init_delayed)); + btif_a2dp_sink_cb.worker_thread.DoInThread(base::BindOnce(btif_a2dp_sink_init_delayed)); return true; } @@ -219,8 +218,7 @@ static void btif_a2dp_sink_init_delayed() { bool btif_a2dp_sink_startup() { log::info(""); - btif_a2dp_sink_cb.worker_thread.DoInThread(FROM_HERE, - base::BindOnce(btif_a2dp_sink_startup_delayed)); + btif_a2dp_sink_cb.worker_thread.DoInThread(base::BindOnce(btif_a2dp_sink_startup_delayed)); return true; } @@ -305,9 +303,8 @@ static bool btif_a2dp_sink_initialize_a2dp_control_block(const RawAddress& peer_ bool btif_a2dp_sink_start_session(const RawAddress& peer_address, std::promise<void> peer_ready_promise) { log::info("peer_address={}", peer_address); - if (btif_a2dp_sink_cb.worker_thread.DoInThread( - FROM_HERE, base::BindOnce(btif_a2dp_sink_start_session_delayed, peer_address, - std::move(peer_ready_promise)))) { + if (btif_a2dp_sink_cb.worker_thread.DoInThread(base::BindOnce( + btif_a2dp_sink_start_session_delayed, peer_address, std::move(peer_ready_promise)))) { return true; } else { // cannot set promise but triggers crash @@ -353,8 +350,7 @@ bool btif_a2dp_sink_restart_session(const RawAddress& old_peer_address, bool btif_a2dp_sink_end_session(const RawAddress& peer_address) { log::info("peer_address={}", peer_address); - btif_a2dp_sink_cb.worker_thread.DoInThread(FROM_HERE, - base::BindOnce(btif_a2dp_sink_end_session_delayed)); + btif_a2dp_sink_cb.worker_thread.DoInThread(base::BindOnce(btif_a2dp_sink_end_session_delayed)); return true; } @@ -366,8 +362,7 @@ static void btif_a2dp_sink_end_session_delayed() { void btif_a2dp_sink_shutdown() { log::info(""); - btif_a2dp_sink_cb.worker_thread.DoInThread(FROM_HERE, - base::BindOnce(btif_a2dp_sink_shutdown_delayed)); + btif_a2dp_sink_cb.worker_thread.DoInThread(base::BindOnce(btif_a2dp_sink_shutdown_delayed)); } static void btif_a2dp_sink_shutdown_delayed() { @@ -401,8 +396,7 @@ void btif_a2dp_sink_cleanup() { alarm_free(decode_alarm); // Exit the thread - btif_a2dp_sink_cb.worker_thread.DoInThread(FROM_HERE, - base::BindOnce(btif_a2dp_sink_cleanup_delayed)); + btif_a2dp_sink_cb.worker_thread.DoInThread(base::BindOnce(btif_a2dp_sink_cleanup_delayed)); btif_a2dp_sink_cb.worker_thread.ShutDown(); } @@ -460,15 +454,14 @@ void btif_a2dp_sink_update_decoder(const RawAddress& peer_address, const uint8_t p_buf->hdr.event = BTIF_MEDIA_SINK_DECODER_UPDATE; btif_a2dp_sink_cb.worker_thread.DoInThread( - FROM_HERE, base::BindOnce(btif_a2dp_sink_command_ready, (BT_HDR_RIGID*)p_buf)); + base::BindOnce(btif_a2dp_sink_command_ready, (BT_HDR_RIGID*)p_buf)); } void btif_a2dp_sink_on_idle() { log::info(""); BT_HDR_RIGID* p_buf = reinterpret_cast<BT_HDR_RIGID*>(osi_malloc(sizeof(BT_HDR_RIGID))); p_buf->event = BTIF_MEDIA_SINK_SUSPEND; - btif_a2dp_sink_cb.worker_thread.DoInThread(FROM_HERE, - base::BindOnce(btif_a2dp_sink_command_ready, p_buf)); + btif_a2dp_sink_cb.worker_thread.DoInThread(base::BindOnce(btif_a2dp_sink_command_ready, p_buf)); if (btif_a2dp_sink_state == BTIF_A2DP_SINK_STATE_OFF) { return; @@ -481,8 +474,7 @@ void btif_a2dp_sink_on_stopped(tBTA_AV_SUSPEND* /* p_av_suspend */) { log::info(""); BT_HDR_RIGID* p_buf = reinterpret_cast<BT_HDR_RIGID*>(osi_malloc(sizeof(BT_HDR_RIGID))); p_buf->event = BTIF_MEDIA_SINK_SUSPEND; - btif_a2dp_sink_cb.worker_thread.DoInThread(FROM_HERE, - base::BindOnce(btif_a2dp_sink_command_ready, p_buf)); + btif_a2dp_sink_cb.worker_thread.DoInThread(base::BindOnce(btif_a2dp_sink_command_ready, p_buf)); if (btif_a2dp_sink_state == BTIF_A2DP_SINK_STATE_OFF) { return; @@ -494,8 +486,7 @@ void btif_a2dp_sink_on_suspended(tBTA_AV_SUSPEND* /* p_av_suspend */) { log::info(""); BT_HDR_RIGID* p_buf = reinterpret_cast<BT_HDR_RIGID*>(osi_malloc(sizeof(BT_HDR_RIGID))); p_buf->event = BTIF_MEDIA_SINK_SUSPEND; - btif_a2dp_sink_cb.worker_thread.DoInThread(FROM_HERE, - base::BindOnce(btif_a2dp_sink_command_ready, p_buf)); + btif_a2dp_sink_cb.worker_thread.DoInThread(base::BindOnce(btif_a2dp_sink_command_ready, p_buf)); if (btif_a2dp_sink_state == BTIF_A2DP_SINK_STATE_OFF) { return; @@ -508,8 +499,7 @@ bool btif_a2dp_sink_on_start() { BT_HDR_RIGID* p_buf = reinterpret_cast<BT_HDR_RIGID*>(osi_malloc(sizeof(BT_HDR_RIGID))); p_buf->event = BTIF_MEDIA_SINK_START; - btif_a2dp_sink_cb.worker_thread.DoInThread(FROM_HERE, - base::BindOnce(btif_a2dp_sink_command_ready, p_buf)); + btif_a2dp_sink_cb.worker_thread.DoInThread(base::BindOnce(btif_a2dp_sink_command_ready, p_buf)); return true; } @@ -540,8 +530,7 @@ static void btif_a2dp_sink_audio_handle_stop_decoding() { } static void btif_decode_alarm_cb(void* /* context */) { - btif_a2dp_sink_cb.worker_thread.DoInThread(FROM_HERE, - base::BindOnce(btif_a2dp_sink_avk_handle_timer)); + btif_a2dp_sink_cb.worker_thread.DoInThread(base::BindOnce(btif_a2dp_sink_avk_handle_timer)); } static void btif_a2dp_sink_clear_track_event() { @@ -767,8 +756,7 @@ void btif_a2dp_sink_audio_rx_flush_req() { BT_HDR_RIGID* p_buf = reinterpret_cast<BT_HDR_RIGID*>(osi_malloc(sizeof(BT_HDR_RIGID))); p_buf->event = BTIF_MEDIA_SINK_AUDIO_RX_FLUSH; - btif_a2dp_sink_cb.worker_thread.DoInThread(FROM_HERE, - base::BindOnce(btif_a2dp_sink_command_ready, p_buf)); + btif_a2dp_sink_cb.worker_thread.DoInThread(base::BindOnce(btif_a2dp_sink_command_ready, p_buf)); } void btif_a2dp_sink_debug_dump(int /* fd */) { @@ -782,7 +770,7 @@ void btif_a2dp_sink_set_focus_state_req(btif_a2dp_sink_focus_state_t state) { p_buf->focus_state = state; p_buf->hdr.event = BTIF_MEDIA_SINK_SET_FOCUS_STATE; btif_a2dp_sink_cb.worker_thread.DoInThread( - FROM_HERE, base::BindOnce(btif_a2dp_sink_command_ready, (BT_HDR_RIGID*)p_buf)); + base::BindOnce(btif_a2dp_sink_command_ready, (BT_HDR_RIGID*)p_buf)); } static void btif_a2dp_sink_set_focus_state_event(btif_a2dp_sink_focus_state_t state) { @@ -815,8 +803,7 @@ static void btif_a2dp_sink_clear_track_event_req() { BT_HDR_RIGID* p_buf = reinterpret_cast<BT_HDR_RIGID*>(osi_malloc(sizeof(BT_HDR_RIGID))); p_buf->event = BTIF_MEDIA_SINK_CLEAR_TRACK; - btif_a2dp_sink_cb.worker_thread.DoInThread(FROM_HERE, - base::BindOnce(btif_a2dp_sink_command_ready, p_buf)); + btif_a2dp_sink_cb.worker_thread.DoInThread(base::BindOnce(btif_a2dp_sink_command_ready, p_buf)); } static void btif_a2dp_sink_on_start_event() { diff --git a/system/btif/src/btif_a2dp_source.cc b/system/btif/src/btif_a2dp_source.cc index 70634b9984..25a5fe7093 100644 --- a/system/btif/src/btif_a2dp_source.cc +++ b/system/btif/src/btif_a2dp_source.cc @@ -343,7 +343,7 @@ bool btif_a2dp_source_init(void) { // Start A2DP Source media task btif_a2dp_source_thread.StartUp(); - local_thread()->DoInThread(FROM_HERE, base::BindOnce(&btif_a2dp_source_init_delayed)); + local_thread()->DoInThread(base::BindOnce(&btif_a2dp_source_init_delayed)); return true; } @@ -441,7 +441,7 @@ static bool btif_a2dp_source_startup(void) { btif_a2dp_source_cb.tx_audio_queue = fixed_queue_new(SIZE_MAX); // Schedule the rest of the operations - local_thread()->DoInThread(FROM_HERE, base::BindOnce(&btif_a2dp_source_startup_delayed)); + local_thread()->DoInThread(base::BindOnce(&btif_a2dp_source_startup_delayed)); return true; } @@ -466,9 +466,8 @@ bool btif_a2dp_source_start_session(const RawAddress& peer_address, btif_a2dp_source_audio_tx_flush_req(); - if (local_thread()->DoInThread( - FROM_HERE, base::BindOnce(&btif_a2dp_source_start_session_delayed, peer_address, - std::move(peer_ready_promise)))) { + if (local_thread()->DoInThread(base::BindOnce(&btif_a2dp_source_start_session_delayed, + peer_address, std::move(peer_ready_promise)))) { return true; } else { // cannot set promise but triggers crash @@ -535,9 +534,7 @@ bool btif_a2dp_source_end_session(const RawAddress& peer_address) { btif_a2dp_source_cleanup_codec(); btif_a2dp_source_end_session_delayed(peer_address); } else { - - local_thread()->DoInThread(FROM_HERE, - base::BindOnce(&btif_a2dp_source_end_session_delayed, peer_address)); + local_thread()->DoInThread(base::BindOnce(&btif_a2dp_source_end_session_delayed, peer_address)); btif_a2dp_source_cleanup_codec(); } return true; @@ -565,7 +562,6 @@ void btif_a2dp_source_allow_low_latency_audio(bool allowed) { log::info("allowed={}", allowed); local_thread()->DoInThread( - FROM_HERE, base::BindOnce(bluetooth::audio::a2dp::set_audio_low_latency_mode_allowed, allowed)); } @@ -582,8 +578,8 @@ void btif_a2dp_source_shutdown(std::promise<void> shutdown_complete_promise) { // TODO(b/374166531) Remove the check for get_main_thread. if (local_thread() != get_main_thread()) { - local_thread()->DoInThread(FROM_HERE, base::BindOnce(&btif_a2dp_source_shutdown_delayed, - std::move(shutdown_complete_promise))); + local_thread()->DoInThread(base::BindOnce(&btif_a2dp_source_shutdown_delayed, + std::move(shutdown_complete_promise))); } else { btif_a2dp_source_shutdown_delayed(std::move(shutdown_complete_promise)); } @@ -696,7 +692,7 @@ static void btif_a2dp_source_cleanup_codec() { log::info("state={}", btif_a2dp_source_cb.StateStr()); // Must stop media task first before cleaning up the encoder btif_a2dp_source_stop_audio_req(); - local_thread()->DoInThread(FROM_HERE, base::BindOnce(&btif_a2dp_source_cleanup_codec_delayed)); + local_thread()->DoInThread(base::BindOnce(&btif_a2dp_source_cleanup_codec_delayed)); } static void btif_a2dp_source_cleanup_codec_delayed() { @@ -710,13 +706,13 @@ static void btif_a2dp_source_cleanup_codec_delayed() { void btif_a2dp_source_start_audio_req(void) { log::info("state={}", btif_a2dp_source_cb.StateStr()); - local_thread()->DoInThread(FROM_HERE, base::BindOnce(&btif_a2dp_source_audio_tx_start_event)); + local_thread()->DoInThread(base::BindOnce(&btif_a2dp_source_audio_tx_start_event)); } void btif_a2dp_source_stop_audio_req(void) { log::info("state={}", btif_a2dp_source_cb.StateStr()); - local_thread()->DoInThread(FROM_HERE, base::BindOnce(&btif_a2dp_source_audio_tx_stop_event)); + local_thread()->DoInThread(base::BindOnce(&btif_a2dp_source_audio_tx_stop_event)); } void btif_a2dp_source_encoder_user_config_update_req( @@ -727,7 +723,6 @@ void btif_a2dp_source_encoder_user_config_update_req( btif_a2dp_source_cb.StateStr(), codec_user_preferences.size()); if (!local_thread()->DoInThread( - FROM_HERE, base::BindOnce(&btif_a2dp_source_encoder_user_config_update_event, peer_address, codec_user_preferences, std::move(peer_ready_promise)))) { // cannot set promise but triggers crash @@ -772,8 +767,8 @@ static void btif_a2dp_source_encoder_user_config_update_event( void btif_a2dp_source_feeding_update_req(const btav_a2dp_codec_config_t& codec_audio_config) { log::info("state={}", btif_a2dp_source_cb.StateStr()); - local_thread()->DoInThread(FROM_HERE, base::BindOnce(&btif_a2dp_source_audio_feeding_update_event, - codec_audio_config)); + local_thread()->DoInThread( + base::BindOnce(&btif_a2dp_source_audio_feeding_update_event, codec_audio_config)); } static void btif_a2dp_source_audio_feeding_update_event( @@ -889,7 +884,7 @@ static void btif_a2dp_source_audio_tx_start_event(void) { btif_a2dp_source_cb.tx_flush = false; btif_a2dp_source_cb.sw_audio_is_encoding = true; btif_a2dp_source_cb.media_alarm.SchedulePeriodic( - btif_a2dp_source_thread.GetWeakPtr(), FROM_HERE, + btif_a2dp_source_thread.GetWeakPtr(), base::BindRepeating(&btif_a2dp_source_audio_handle_timer), std::chrono::milliseconds( btif_a2dp_source_cb.encoder_interface->get_encoder_interval_ms())); @@ -1086,7 +1081,7 @@ static void btif_a2dp_source_audio_tx_flush_event(void) { static bool btif_a2dp_source_audio_tx_flush_req(void) { log::info("state={}", btif_a2dp_source_cb.StateStr()); - local_thread()->DoInThread(FROM_HERE, base::BindOnce(&btif_a2dp_source_audio_tx_flush_event)); + local_thread()->DoInThread(base::BindOnce(&btif_a2dp_source_audio_tx_flush_event)); return true; } diff --git a/system/btif/src/btif_jni_task.cc b/system/btif/src/btif_jni_task.cc index 3937dd1591..5eb7dcd50a 100644 --- a/system/btif/src/btif_jni_task.cc +++ b/system/btif/src/btif_jni_task.cc @@ -105,7 +105,7 @@ bt_status_t btif_transfer_context(tBTIF_CBACK* p_cback, uint16_t event, char* p_ * the JNI message loop. **/ bt_status_t do_in_jni_thread(base::OnceClosure task) { - if (!jni_thread.DoInThread(FROM_HERE, std::move(task))) { + if (!jni_thread.DoInThread(std::move(task))) { log::error("Post task to task runner failed!"); return BT_STATUS_JNI_THREAD_ATTACH_ERROR; } diff --git a/system/btif/src/stack_manager.cc b/system/btif/src/stack_manager.cc index 430ed84d23..935dbd7de2 100644 --- a/system/btif/src/stack_manager.cc +++ b/system/btif/src/stack_manager.cc @@ -143,8 +143,8 @@ static void init_stack(bluetooth::core::CoreInterface* interface) { // and do not overlap. std::promise<void> promise; auto future = promise.get_future(); - management_thread.DoInThread(FROM_HERE, base::BindOnce(event_init_stack, std::move(promise), - base::Unretained(interface))); + management_thread.DoInThread( + base::BindOnce(event_init_stack, std::move(promise), base::Unretained(interface))); future.wait(); } @@ -152,11 +152,11 @@ static void start_up_stack_async(bluetooth::core::CoreInterface* interface, ProfileStartCallback startProfiles, ProfileStopCallback stopProfiles) { management_thread.DoInThread( - FROM_HERE, base::BindOnce(event_start_up_stack, interface, startProfiles, stopProfiles)); + base::BindOnce(event_start_up_stack, interface, startProfiles, stopProfiles)); } static void shut_down_stack_async(ProfileStopCallback stopProfiles) { - management_thread.DoInThread(FROM_HERE, base::BindOnce(event_shut_down_stack, stopProfiles)); + management_thread.DoInThread(base::BindOnce(event_shut_down_stack, stopProfiles)); } static void clean_up_stack(ProfileStopCallback stopProfiles) { @@ -165,7 +165,7 @@ static void clean_up_stack(ProfileStopCallback stopProfiles) { std::promise<void> promise; auto future = promise.get_future(); management_thread.DoInThread( - FROM_HERE, base::BindOnce(event_clean_up_stack, std::move(promise), stopProfiles)); + base::BindOnce(event_clean_up_stack, std::move(promise), stopProfiles)); auto status = future.wait_for(std::chrono::milliseconds( bluetooth::os::GetSystemPropertyUint32("bluetooth.cleanup_timeout", @@ -178,12 +178,11 @@ static void clean_up_stack(ProfileStopCallback stopProfiles) { } static void start_up_rust_module_async(std::promise<void> promise) { - management_thread.DoInThread(FROM_HERE, - base::BindOnce(event_start_up_rust_module, std::move(promise))); + management_thread.DoInThread(base::BindOnce(event_start_up_rust_module, std::move(promise))); } static void shut_down_rust_module_async() { - management_thread.DoInThread(FROM_HERE, base::BindOnce(event_shut_down_rust_module)); + management_thread.DoInThread(base::BindOnce(event_shut_down_rust_module)); } static bool get_stack_is_running() { return stack_is_running; } diff --git a/system/btif/test/btif_rc_test.cc b/system/btif/test/btif_rc_test.cc index b537e06e04..64a899baae 100644 --- a/system/btif/test/btif_rc_test.cc +++ b/system/btif/test/btif_rc_test.cc @@ -99,7 +99,7 @@ bool btif_av_both_enable(void) { return true; } static bluetooth::common::MessageLoopThread jni_thread("bt_jni_thread"); bt_status_t do_in_jni_thread(base::OnceClosure task) { - if (!jni_thread.DoInThread(FROM_HERE, std::move(task))) { + if (!jni_thread.DoInThread(std::move(task))) { log::error("Post task to task runner failed!"); return BT_STATUS_JNI_THREAD_ATTACH_ERROR; } diff --git a/system/common/benchmark/thread_performance_benchmark.cc b/system/common/benchmark/thread_performance_benchmark.cc index 3ae5033c69..b2b5e7fe5d 100644 --- a/system/common/benchmark/thread_performance_benchmark.cc +++ b/system/common/benchmark/thread_performance_benchmark.cc @@ -326,8 +326,7 @@ protected: std::future<void> set_up_future = set_up_promise_->get_future(); message_loop_thread_ = new MessageLoopThread("BM_MessageLooopThread thread"); message_loop_thread_->StartUp(); - message_loop_thread_->DoInThread(FROM_HERE, - base::BindOnce(&std::promise<void>::set_value, + message_loop_thread_->DoInThread(base::BindOnce(&std::promise<void>::set_value, base::Unretained(set_up_promise_.get()))); set_up_future.wait(); } @@ -349,8 +348,7 @@ BENCHMARK_F(BM_MessageLooopThread, batch_enque_dequeue)(State& state) { std::future<void> counter_future = g_counter_promise->get_future(); for (int i = 0; i < NUM_MESSAGES_TO_SEND; i++) { fixed_queue_enqueue(bt_msg_queue_, (void*)&g_counter); - message_loop_thread_->DoInThread(FROM_HERE, - base::BindOnce(&callback_batch, bt_msg_queue_, nullptr)); + message_loop_thread_->DoInThread(base::BindOnce(&callback_batch, bt_msg_queue_, nullptr)); } counter_future.wait(); } @@ -361,7 +359,7 @@ BENCHMARK_F(BM_MessageLooopThread, sequential_execution)(State& state) { for (int i = 0; i < NUM_MESSAGES_TO_SEND; i++) { g_counter_promise = std::make_unique<std::promise<void>>(); std::future<void> counter_future = g_counter_promise->get_future(); - message_loop_thread_->DoInThread(FROM_HERE, base::BindOnce(&callback_sequential, nullptr)); + message_loop_thread_->DoInThread(base::BindOnce(&callback_sequential, nullptr)); counter_future.wait(); } } diff --git a/system/common/message_loop_thread.cc b/system/common/message_loop_thread.cc index 1de1ff036e..a6dd211d77 100644 --- a/system/common/message_loop_thread.cc +++ b/system/common/message_loop_thread.cc @@ -70,22 +70,20 @@ void MessageLoopThread::StartUp() { start_up_future.wait(); } -bool MessageLoopThread::DoInThread(const base::Location& from_here, base::OnceClosure task) { - return DoInThreadDelayed(from_here, std::move(task), std::chrono::microseconds(0)); +bool MessageLoopThread::DoInThread(base::OnceClosure task) { + return DoInThreadDelayed(std::move(task), std::chrono::microseconds(0)); } -bool MessageLoopThread::DoInThreadDelayed(const base::Location& from_here, base::OnceClosure task, - std::chrono::microseconds delay) { +bool MessageLoopThread::DoInThreadDelayed(base::OnceClosure task, std::chrono::microseconds delay) { std::lock_guard<std::recursive_mutex> api_lock(api_mutex_); if (message_loop_ == nullptr) { - log::error("message loop is null for thread {}, from {}", *this, from_here.ToString()); + log::error("message loop is null for thread {}", *this); return false; } - if (!message_loop_->task_runner()->PostDelayedTask(from_here, std::move(task), + if (!message_loop_->task_runner()->PostDelayedTask(FROM_HERE, std::move(task), timeDeltaFromMicroseconds(delay))) { - log::error("failed to post task to message loop for thread {}, from {}", *this, - from_here.ToString()); + log::error("failed to post task to message loop for thread {}", *this); return false; } return true; @@ -199,9 +197,7 @@ void MessageLoopThread::Run(std::promise<void> start_up_promise) { } } -void MessageLoopThread::Post(base::OnceClosure closure) { - DoInThread(FROM_HERE, std::move(closure)); -} +void MessageLoopThread::Post(base::OnceClosure closure) { DoInThread(std::move(closure)); } PostableContext* MessageLoopThread::Postable() { return this; } diff --git a/system/common/message_loop_thread.h b/system/common/message_loop_thread.h index 301a4848a7..f51e2c9595 100644 --- a/system/common/message_loop_thread.h +++ b/system/common/message_loop_thread.h @@ -67,12 +67,11 @@ public: /** * Post a task to run on this thread * - * @param from_here location where this task is originated * @param task task created through base::Bind() * @return true if task is successfully scheduled, false if task cannot be * scheduled */ - bool DoInThread(const base::Location& from_here, base::OnceClosure task); + bool DoInThread(base::OnceClosure task); /** * Shutdown the current thread as if it is never started. IsRunning() and @@ -147,26 +146,22 @@ public: * <code> * base::CancelableClosure cancelable_task; * cancelable_task.Reset(base::Bind(...)); // bind the task - * same_thread->DoInThreadDelayed(FROM_HERE, - * cancelable_task.callback(), delay); + * same_thread->DoInThreadDelayed(cancelable_task.callback(), delay); * ... * // Cancel the task closure - * same_thread->DoInThread(FROM_HERE, - * base::Bind(&base::CancelableClosure::Cancel, - * base::Unretained(&cancelable_task))); + * same_thread->DoInThread(base::Bind(&base::CancelableClosure::Cancel, + * base::Unretained(&cancelable_task))); * </code> * * Warning: base::CancelableClosure objects must be created on, posted to, * cancelled on, and destroyed on the same thread. * - * @param from_here location where this task is originated * @param task task created through base::Bind() * @param delay delay for the task to be executed * @return true if task is successfully scheduled, false if task cannot be * scheduled */ - bool DoInThreadDelayed(const base::Location& from_here, base::OnceClosure task, - std::chrono::microseconds delay); + bool DoInThreadDelayed(base::OnceClosure task, std::chrono::microseconds delay); /** * Wrapper around DoInThread without a location. */ diff --git a/system/common/message_loop_thread_unittest.cc b/system/common/message_loop_thread_unittest.cc index 8b6d598aaf..160f61e2c8 100644 --- a/system/common/message_loop_thread_unittest.cc +++ b/system/common/message_loop_thread_unittest.cc @@ -115,7 +115,6 @@ TEST_F(MessageLoopThreadTest, test_do_in_thread_before_start) { std::string name = "test_thread"; MessageLoopThread message_loop_thread(name); ASSERT_FALSE(message_loop_thread.DoInThread( - FROM_HERE, base::BindOnce(&MessageLoopThreadTest::ShouldNotHappen, base::Unretained(this)))); } @@ -125,7 +124,6 @@ TEST_F(MessageLoopThreadTest, test_do_in_thread_after_shutdown) { message_loop_thread.StartUp(); message_loop_thread.ShutDown(); ASSERT_FALSE(message_loop_thread.DoInThread( - FROM_HERE, base::BindOnce(&MessageLoopThreadTest::ShouldNotHappen, base::Unretained(this)))); } @@ -136,9 +134,8 @@ TEST_F(MessageLoopThreadTest, test_name) { ASSERT_GE(message_loop_thread.GetThreadId(), 0); std::promise<std::string> name_promise; std::future<std::string> name_future = name_promise.get_future(); - message_loop_thread.DoInThread( - FROM_HERE, base::BindOnce(&MessageLoopThreadTest::GetName, base::Unretained(this), - std::move(name_promise))); + message_loop_thread.DoInThread(base::BindOnce(&MessageLoopThreadTest::GetName, + base::Unretained(this), std::move(name_promise))); std::string my_name = name_future.get(); ASSERT_EQ(name, my_name); ASSERT_EQ(name, message_loop_thread.GetName()); @@ -152,9 +149,9 @@ TEST_F(MessageLoopThreadTest, test_thread_id) { ASSERT_GE(thread_id, 0); std::promise<base::PlatformThreadId> thread_id_promise; std::future<base::PlatformThreadId> thread_id_future = thread_id_promise.get_future(); - message_loop_thread.DoInThread( - FROM_HERE, base::BindOnce(&MessageLoopThreadTest::GetThreadId, base::Unretained(this), - std::move(thread_id_promise))); + message_loop_thread.DoInThread(base::BindOnce(&MessageLoopThreadTest::GetThreadId, + base::Unretained(this), + std::move(thread_id_promise))); base::PlatformThreadId my_thread_id = thread_id_future.get(); ASSERT_EQ(thread_id, my_thread_id); } @@ -189,19 +186,17 @@ TEST_F(MessageLoopThreadTest, test_set_realtime_priority_success) { std::future<void> execution_future = execution_promise.get_future(); int scheduling_policy = -1; int scheduling_priority = -1; - message_loop_thread.DoInThread( - FROM_HERE, base::BindOnce(&MessageLoopThreadTest::GetSchedulingPolicyAndPriority, - base::Unretained(this), &scheduling_policy, - &scheduling_priority, std::move(execution_promise))); + message_loop_thread.DoInThread(base::BindOnce( + &MessageLoopThreadTest::GetSchedulingPolicyAndPriority, base::Unretained(this), + &scheduling_policy, &scheduling_priority, std::move(execution_promise))); execution_future.wait(); ASSERT_EQ(scheduling_policy, SCHED_FIFO); // Internal implementation verified here ASSERT_EQ(scheduling_priority, 1); std::promise<pid_t> tid_promise; std::future<pid_t> tid_future = tid_promise.get_future(); - message_loop_thread.DoInThread( - FROM_HERE, base::BindOnce(&MessageLoopThreadTest::GetLinuxTid, base::Unretained(this), - std::move(tid_promise))); + message_loop_thread.DoInThread(base::BindOnce(&MessageLoopThreadTest::GetLinuxTid, + base::Unretained(this), std::move(tid_promise))); pid_t linux_tid = tid_future.get(); ASSERT_GT(linux_tid, 0); ASSERT_EQ(sched_getscheduler(linux_tid), SCHED_FIFO); @@ -260,9 +255,9 @@ TEST_F(MessageLoopThreadTest, shut_down_while_in_callback) { std::promise<std::string> name_promise; std::future<std::string> name_future = name_promise.get_future(); uint32_t delay_ms = 5; - message_loop_thread.DoInThread( - FROM_HERE, base::BindOnce(&MessageLoopThreadTest::SleepAndGetName, base::Unretained(this), - std::move(name_promise), delay_ms)); + message_loop_thread.DoInThread(base::BindOnce(&MessageLoopThreadTest::SleepAndGetName, + base::Unretained(this), std::move(name_promise), + delay_ms)); message_loop_thread.ShutDown(); std::string my_name = name_future.get(); ASSERT_EQ(name, my_name); @@ -273,9 +268,8 @@ TEST_F(MessageLoopThreadTest, shut_down_while_in_callback_check_lock) { std::string name = "test_thread"; MessageLoopThread message_loop_thread(name); message_loop_thread.StartUp(); - message_loop_thread.DoInThread( - FROM_HERE, base::BindOnce([](MessageLoopThread* thread) { thread->IsRunning(); }, - &message_loop_thread)); + message_loop_thread.DoInThread(base::BindOnce( + [](MessageLoopThread* thread) { thread->IsRunning(); }, &message_loop_thread)); message_loop_thread.ShutDown(); } diff --git a/system/common/repeating_timer.cc b/system/common/repeating_timer.cc index f1e645182a..98ff8c442a 100644 --- a/system/common/repeating_timer.cc +++ b/system/common/repeating_timer.cc @@ -37,7 +37,7 @@ RepeatingTimer::~RepeatingTimer() { // This runs on user thread bool RepeatingTimer::SchedulePeriodic(const base::WeakPtr<MessageLoopThread>& thread, - const base::Location& from_here, base::RepeatingClosure task, + base::RepeatingClosure task, std::chrono::microseconds period) { if (period < kMinimumPeriod) { log::error("period must be at least {}", kMinimumPeriod.count()); @@ -58,10 +58,9 @@ bool RepeatingTimer::SchedulePeriodic(const base::WeakPtr<MessageLoopThread>& th message_loop_thread_ = thread; period_ = period; uint64_t time_until_next_us = time_next_task_us - clock_tick_us_(); - if (!thread->DoInThreadDelayed(from_here, task_wrapper_.callback(), + if (!thread->DoInThreadDelayed(task_wrapper_.callback(), std::chrono::microseconds(time_until_next_us))) { - log::error("failed to post task to message loop for thread {}, from {}", *thread, - from_here.ToString()); + log::error("failed to post task to message loop for thread {}", *thread); expected_time_next_task_us_ = 0; task_wrapper_.Cancel(); message_loop_thread_ = nullptr; @@ -97,9 +96,8 @@ void RepeatingTimer::CancelHelper(std::promise<void> promise) { CancelClosure(std::move(promise)); return; } - scheduled_thread->DoInThread( - FROM_HERE, base::BindOnce(&RepeatingTimer::CancelClosure, base::Unretained(this), - std::move(promise))); + scheduled_thread->DoInThread(base::BindOnce(&RepeatingTimer::CancelClosure, + base::Unretained(this), std::move(promise))); } // This runs on message loop thread @@ -140,7 +138,7 @@ void RepeatingTimer::RunTask() { // multiple of period remaining_time_us = (remaining_time_us % period_us + period_us) % period_us; } - message_loop_thread_->DoInThreadDelayed(FROM_HERE, task_wrapper_.callback(), + message_loop_thread_->DoInThreadDelayed(task_wrapper_.callback(), std::chrono::microseconds(remaining_time_us)); uint64_t time_before_task_us = clock_tick_us_(); diff --git a/system/common/repeating_timer.h b/system/common/repeating_timer.h index 6c22f0d467..c7d0505e86 100644 --- a/system/common/repeating_timer.h +++ b/system/common/repeating_timer.h @@ -54,13 +54,11 @@ public: * blocks until the previous task is cancelled. * * @param thread thread to run the task - * @param from_here location where this task is originated * @param task task created through base::Bind() * @param period period for the task to be executed * @return true iff task is scheduled successfully */ - bool SchedulePeriodic(const base::WeakPtr<MessageLoopThread>& thread, - const base::Location& from_here, base::RepeatingClosure task, + bool SchedulePeriodic(const base::WeakPtr<MessageLoopThread>& thread, base::RepeatingClosure task, std::chrono::microseconds period); /** diff --git a/system/common/repeating_timer_unittest.cc b/system/common/repeating_timer_unittest.cc index 817f3e9bb0..a8a7a4cd80 100644 --- a/system/common/repeating_timer_unittest.cc +++ b/system/common/repeating_timer_unittest.cc @@ -81,7 +81,7 @@ public: auto future = promise_->get_future(); auto start_time = std::chrono::steady_clock::now(); timer_->SchedulePeriodic( - message_loop_thread.GetWeakPtr(), FROM_HERE, + message_loop_thread.GetWeakPtr(), base::BindRepeating(&RepeatingTimerTest::VerifyDelayTimeAndSleep, base::Unretained(this), start_time, interval_between_tasks_ms, scheduled_tasks, task_length_ms, promise_), @@ -136,7 +136,7 @@ TEST_F(RepeatingTimerTest, periodic_run) { uint32_t delay_ms = 5; int num_tasks = 200; - timer_->SchedulePeriodic(message_loop_thread.GetWeakPtr(), FROM_HERE, + timer_->SchedulePeriodic(message_loop_thread.GetWeakPtr(), base::BindRepeating(&RepeatingTimerTest::IncreaseTaskCounter, base::Unretained(this), num_tasks, promise_), std::chrono::milliseconds(delay_ms)); @@ -152,7 +152,7 @@ TEST_F(RepeatingTimerTest, schedule_periodic_task_zero_interval) { uint32_t interval_ms = 0; ASSERT_FALSE(timer_->SchedulePeriodic( - message_loop_thread.GetWeakPtr(), FROM_HERE, + message_loop_thread.GetWeakPtr(), base::BindRepeating(&RepeatingTimerTest::ShouldNotHappen, base::Unretained(this)), std::chrono::milliseconds(interval_ms))); std::this_thread::sleep_for(std::chrono::milliseconds(delay_error_ms)); @@ -165,7 +165,7 @@ TEST_F(RepeatingTimerTest, periodic_delete_without_cancel) { message_loop_thread.StartUp(); uint32_t delay_ms = 5; timer_->SchedulePeriodic( - message_loop_thread.GetWeakPtr(), FROM_HERE, + message_loop_thread.GetWeakPtr(), base::BindRepeating(&RepeatingTimerTest::ShouldNotHappen, base::Unretained(this)), std::chrono::milliseconds(delay_ms)); delete timer_; @@ -178,7 +178,7 @@ TEST_F(RepeatingTimerTest, cancel_single_task_near_fire_no_race_condition) { MessageLoopThread message_loop_thread(name); message_loop_thread.StartUp(); uint32_t delay_ms = 5; - timer_->SchedulePeriodic(message_loop_thread.GetWeakPtr(), FROM_HERE, base::DoNothing(), + timer_->SchedulePeriodic(message_loop_thread.GetWeakPtr(), base::DoNothing(), std::chrono::milliseconds(delay_ms)); std::this_thread::sleep_for(std::chrono::milliseconds(delay_ms)); timer_->CancelAndWait(); @@ -192,7 +192,7 @@ TEST_F(RepeatingTimerTest, cancel_periodic_task) { int num_tasks = 5; auto future = promise_->get_future(); - timer_->SchedulePeriodic(message_loop_thread.GetWeakPtr(), FROM_HERE, + timer_->SchedulePeriodic(message_loop_thread.GetWeakPtr(), base::BindRepeating(&RepeatingTimerTest::IncreaseTaskCounter, base::Unretained(this), num_tasks, promise_), std::chrono::milliseconds(delay_ms)); @@ -225,7 +225,7 @@ TEST_F(RepeatingTimerTest, message_loop_thread_down_cancel_scheduled_periodic_ta uint32_t delay_ms = 5; int num_tasks = 5; - timer_->SchedulePeriodic(message_loop_thread.GetWeakPtr(), FROM_HERE, + timer_->SchedulePeriodic(message_loop_thread.GetWeakPtr(), base::BindRepeating(&RepeatingTimerTest::IncreaseTaskCounter, base::Unretained(this), num_tasks, promise_), std::chrono::milliseconds(delay_ms)); diff --git a/system/common/test/thread_performance_test.cc b/system/common/test/thread_performance_test.cc index f875cd6aa6..17ca715c4f 100644 --- a/system/common/test/thread_performance_test.cc +++ b/system/common/test/thread_performance_test.cc @@ -261,8 +261,8 @@ protected: std::future<void> set_up_future = set_up_promise_->get_future(); worker_thread_ = new MessageLoopThread("WorkerThreadPerformanceTest thread"); worker_thread_->StartUp(); - worker_thread_->DoInThread(FROM_HERE, base::BindOnce(&std::promise<void>::set_value, - base::Unretained(set_up_promise_.get()))); + worker_thread_->DoInThread(base::BindOnce(&std::promise<void>::set_value, + base::Unretained(set_up_promise_.get()))); set_up_future.wait(); } @@ -285,7 +285,7 @@ TEST_F(WorkerThreadPerformanceTest, worker_thread_speed_test) { for (int i = 0; i < NUM_MESSAGES_TO_SEND; i++) { fixed_queue_enqueue(bt_msg_queue_, (void*)&g_counter); - worker_thread_->DoInThread(FROM_HERE, base::BindOnce(&callback_batch, bt_msg_queue_, nullptr)); + worker_thread_->DoInThread(base::BindOnce(&callback_batch, bt_msg_queue_, nullptr)); } counter_future.wait(); diff --git a/system/osi/src/alarm.cc b/system/osi/src/alarm.cc index fa5072474d..6aaf4354ae 100644 --- a/system/osi/src/alarm.cc +++ b/system/osi/src/alarm.cc @@ -654,7 +654,7 @@ static void callback_dispatch(void* /* context */) { } alarm->closure.i.Reset(Bind(alarm_ready_mloop, alarm)); - get_main_thread()->DoInThread(FROM_HERE, alarm->closure.i.callback()); + get_main_thread()->DoInThread(alarm->closure.i.callback()); } else { fixed_queue_enqueue(alarm->queue, alarm); } diff --git a/system/osi/test/future_test.cc b/system/osi/test/future_test.cc index a3ed620302..4acf389be4 100644 --- a/system/osi/test/future_test.cc +++ b/system/osi/test/future_test.cc @@ -41,7 +41,7 @@ TEST_F(FutureTest, test_future_non_immediate) { MessageLoopThread worker_thread("worker_thread"); worker_thread.StartUp(); - worker_thread.DoInThread(FROM_HERE, base::BindOnce(post_to_future, future)); + worker_thread.DoInThread(base::BindOnce(post_to_future, future)); EXPECT_EQ(pass_back_data0, future_await(future)); diff --git a/system/osi/test/internal/semaphore_test.cc b/system/osi/test/internal/semaphore_test.cc index 612804749f..92c0194976 100644 --- a/system/osi/test/internal/semaphore_test.cc +++ b/system/osi/test/internal/semaphore_test.cc @@ -83,7 +83,7 @@ TEST_F(SemaphoreTest, test_ensure_wait) { EXPECT_FALSE(semaphore_try_wait(semaphore)); SemaphoreTestSequenceHelper sequence_helper = {semaphore, 0}; - thread.DoInThread(FROM_HERE, base::BindOnce(sleep_then_increment_counter, &sequence_helper)); + thread.DoInThread(base::BindOnce(sleep_then_increment_counter, &sequence_helper)); semaphore_wait(semaphore); EXPECT_EQ(sequence_helper.counter, 1) << "semaphore_wait() did not wait for counter to increment"; diff --git a/system/stack/btm/btm_ble.cc b/system/stack/btm/btm_ble.cc index b612b684b3..2251835c7d 100644 --- a/system/stack/btm/btm_ble.cc +++ b/system/stack/btm/btm_ble.cc @@ -182,8 +182,7 @@ void BTM_BleReadPhy(const RawAddress& bd_addr, uint8_t data[len]; uint8_t* pp = data; UINT16_TO_STREAM(pp, handle); - btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_BLE_READ_PHY, data, len, - base::Bind(&read_phy_cb, std::move(cb))); + btu_hcif_send_cmd_with_cb(HCI_BLE_READ_PHY, data, len, base::Bind(&read_phy_cb, std::move(cb))); } void BTM_BleSetPhy(const RawAddress& bd_addr, uint8_t tx_phys, uint8_t rx_phys, @@ -229,6 +228,5 @@ void BTM_BleSetPhy(const RawAddress& bd_addr, uint8_t tx_phys, uint8_t rx_phys, UINT8_TO_STREAM(pp, tx_phys); UINT8_TO_STREAM(pp, rx_phys); UINT16_TO_STREAM(pp, phy_options); - btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_BLE_SET_PHY, data, len, - base::Bind([](uint8_t*, uint16_t) {})); + btu_hcif_send_cmd_with_cb(HCI_BLE_SET_PHY, data, len, base::Bind([](uint8_t*, uint16_t) {})); } diff --git a/system/stack/btm/btm_ble_adv_filter.cc b/system/stack/btm/btm_ble_adv_filter.cc index 73050b5047..7f064132b8 100644 --- a/system/stack/btm/btm_ble_adv_filter.cc +++ b/system/stack/btm/btm_ble_adv_filter.cc @@ -382,7 +382,7 @@ void BTM_BleAdvFilterParamSetup(tBTM_BLE_SCAN_COND_OP action, tBTM_BLE_PF_FILT_I BTM_BLE_ADV_FILT_TRACK_NUM; } - btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_BLE_ADV_FILTER, param, len, + btu_hcif_send_cmd_with_cb(HCI_BLE_ADV_FILTER, param, len, base::Bind(&btm_flt_update_cb, BTM_BLE_META_PF_FEAT_SEL, cb)); } else if (BTM_BLE_SCAN_COND_DELETE == action) { /* select feature based on control block settings */ @@ -391,7 +391,7 @@ void BTM_BleAdvFilterParamSetup(tBTM_BLE_SCAN_COND_OP action, tBTM_BLE_PF_FILT_I /* Filter index */ UINT8_TO_STREAM(p, filt_index); - btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_BLE_ADV_FILTER, param, + btu_hcif_send_cmd_with_cb(HCI_BLE_ADV_FILTER, param, (uint8_t)(BTM_BLE_ADV_FILT_META_HDR_LENGTH), base::Bind(&btm_flt_update_cb, BTM_BLE_META_PF_FEAT_SEL, cb)); @@ -403,7 +403,7 @@ void BTM_BleAdvFilterParamSetup(tBTM_BLE_SCAN_COND_OP action, tBTM_BLE_PF_FILT_I UINT8_TO_STREAM(p, BTM_BLE_META_PF_FEAT_SEL); UINT8_TO_STREAM(p, BTM_BLE_SCAN_COND_CLEAR); - btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_BLE_ADV_FILTER, param, + btu_hcif_send_cmd_with_cb(HCI_BLE_ADV_FILTER, param, (uint8_t)(BTM_BLE_ADV_FILT_META_HDR_LENGTH - 1), base::Bind(&btm_flt_update_cb, BTM_BLE_META_PF_FEAT_SEL, cb)); } diff --git a/system/stack/btu/btu_hcif.cc b/system/stack/btu/btu_hcif.cc index 7d8a0cd618..7a4b6d1256 100644 --- a/system/stack/btu/btu_hcif.cc +++ b/system/stack/btu/btu_hcif.cc @@ -64,7 +64,6 @@ #include "types/raw_address.h" using namespace bluetooth; -using base::Location; using bluetooth::hci::IsoManager; /******************************************************************************/ @@ -574,18 +573,13 @@ using hci_cmd_cb = base::OnceCallback<void(uint8_t* /* return_parameters */, struct cmd_with_cb_data { hci_cmd_cb cb; - base::Location posted_from; }; static void cmd_with_cb_data_init(cmd_with_cb_data* cb_wrapper) { new (&cb_wrapper->cb) hci_cmd_cb; - new (&cb_wrapper->posted_from) Location; } -static void cmd_with_cb_data_cleanup(cmd_with_cb_data* cb_wrapper) { - cb_wrapper->cb.~hci_cmd_cb(); - cb_wrapper->posted_from.~Location(); -} +static void cmd_with_cb_data_cleanup(cmd_with_cb_data* cb_wrapper) { cb_wrapper->cb.~hci_cmd_cb(); } /** * Log command complete events that is not handled individually in this file @@ -646,7 +640,6 @@ static void btu_hcif_command_complete_evt_with_cb_on_task(BT_HDR* event, void* c btu_hcif_log_command_complete_metrics(opcode, stream); cmd_with_cb_data* cb_wrapper = (cmd_with_cb_data*)context; - log::verbose("command complete for: {}", cb_wrapper->posted_from.ToString()); // 2 for event header: event code (1) + parameter length (1) // 3 for command complete header: num_hci_pkt (1) + opcode (2) uint16_t param_len = static_cast<uint16_t>(event->len - 5); @@ -676,7 +669,6 @@ static void btu_hcif_command_status_evt_with_cb_on_task(uint8_t status, BT_HDR* // report command status error cmd_with_cb_data* cb_wrapper = (cmd_with_cb_data*)context; - log::verbose("command status for: {}", cb_wrapper->posted_from.ToString()); std::move(cb_wrapper->cb).Run(&status, sizeof(uint16_t)); cmd_with_cb_data_cleanup(cb_wrapper); osi_free(cb_wrapper); @@ -698,8 +690,8 @@ static void btu_hcif_command_status_evt_with_cb(uint8_t status, BT_HDR* command, /* This function is called to send commands to the Host Controller. |cb| is * called when command status event is called with error code, or when the * command complete event is received. */ -void btu_hcif_send_cmd_with_cb(const base::Location& posted_from, uint16_t opcode, uint8_t* params, - uint8_t params_len, hci_cmd_cb cb) { +void btu_hcif_send_cmd_with_cb(uint16_t opcode, uint8_t* params, uint8_t params_len, + hci_cmd_cb cb) { BT_HDR* p = (BT_HDR*)osi_malloc(HCI_CMD_BUF_SIZE); uint8_t* pp = (uint8_t*)(p + 1); @@ -718,7 +710,6 @@ void btu_hcif_send_cmd_with_cb(const base::Location& posted_from, uint16_t opcod cmd_with_cb_data_init(cb_wrapper); cb_wrapper->cb = std::move(cb); - cb_wrapper->posted_from = posted_from; bluetooth::shim::hci_layer_get_interface()->transmit_command( p, btu_hcif_command_complete_evt_with_cb, btu_hcif_command_status_evt_with_cb, diff --git a/system/stack/btu/main_thread.cc b/system/stack/btu/main_thread.cc index 6223e66716..6364f81e8b 100644 --- a/system/stack/btu/main_thread.cc +++ b/system/stack/btu/main_thread.cc @@ -37,7 +37,7 @@ bluetooth::common::MessageLoopThread* get_main_thread() { return &main_thread; } bluetooth::common::PostableContext* get_main() { return main_thread.Postable(); } bt_status_t do_in_main_thread(base::OnceClosure task) { - if (!main_thread.DoInThread(FROM_HERE, std::move(task))) { + if (!main_thread.DoInThread(std::move(task))) { log::error("failed to post task to task runner!"); return BT_STATUS_JNI_THREAD_ATTACH_ERROR; } @@ -45,7 +45,7 @@ bt_status_t do_in_main_thread(base::OnceClosure task) { } bt_status_t do_in_main_thread_delayed(base::OnceClosure task, std::chrono::microseconds delay) { - if (!main_thread.DoInThreadDelayed(FROM_HERE, std::move(task), delay)) { + if (!main_thread.DoInThreadDelayed(std::move(task), delay)) { log::error("failed to post task to task runner!"); return BT_STATUS_JNI_THREAD_ATTACH_ERROR; } diff --git a/system/stack/connection_manager/connection_manager.cc b/system/stack/connection_manager/connection_manager.cc index 3b13c63adc..ff878d84ac 100644 --- a/system/stack/connection_manager/connection_manager.cc +++ b/system/stack/connection_manager/connection_manager.cc @@ -53,25 +53,20 @@ constexpr char kBtmLogTagTA[] = "TA"; struct closure_data { base::OnceClosure user_task; - base::Location posted_from; }; extern std::string get_client_name(uint8_t gatt_if); static void alarm_closure_cb(void* p) { closure_data* data = (closure_data*)p; - log::verbose("executing timer scheduled at {}", data->posted_from.ToString()); std::move(data->user_task).Run(); delete data; } // Periodic alarms are not supported, because we clean up data in callback -static void alarm_set_closure(const base::Location& posted_from, alarm_t* alarm, - uint64_t interval_ms, base::OnceClosure user_task) { +static void alarm_set_closure(alarm_t* alarm, uint64_t interval_ms, base::OnceClosure user_task) { closure_data* data = new closure_data; - data->posted_from = posted_from; data->user_task = std::move(user_task); - log::verbose("scheduling timer {}", data->posted_from.ToString()); alarm_set_on_mloop(alarm, interval_ms, alarm_closure_cb, data); } @@ -561,7 +556,7 @@ bool direct_connect_add(uint8_t app_id, const RawAddress& address, tBLE_ADDR_TYP // Setup a timer alarm_t* timeout = alarm_new("wl_conn_params_30s"); - alarm_set_closure(FROM_HERE, timeout, DIRECT_CONNECT_TIMEOUT, + alarm_set_closure(timeout, DIRECT_CONNECT_TIMEOUT, base::BindOnce(&wl_direct_connect_timeout_cb, app_id, address)); bgconn_dev[address].doing_direct_conn.emplace(app_id, unique_alarm_ptr(timeout, &alarm_free)); diff --git a/system/stack/hcic/hciblecmds.cc b/system/stack/hcic/hciblecmds.cc index 10d283af90..27be452ce5 100644 --- a/system/stack/hcic/hciblecmds.cc +++ b/system/stack/hcic/hciblecmds.cc @@ -238,7 +238,7 @@ void btsnd_hcic_ble_read_remote_feat(uint16_t handle) { void btsnd_hcic_ble_rand(base::Callback<void(BT_OCTET8)> cb) { btu_hcif_send_cmd_with_cb( - FROM_HERE, HCI_BLE_RAND, nullptr, 0, + HCI_BLE_RAND, nullptr, 0, base::Bind( [](base::Callback<void(BT_OCTET8)> cb, uint8_t* param, uint16_t /* param_len */) { bluetooth::log::assert_that(param[0] == 0, @@ -466,7 +466,7 @@ void btsnd_hcic_set_cig_params(uint8_t cig_id, uint32_t sdu_itv_mtos, uint32_t s UINT8_TO_STREAM(pp, cis_cfg[i].rtn_stom); } - btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_LE_SET_CIG_PARAMS, param, params_len, std::move(cb)); + btu_hcif_send_cmd_with_cb(HCI_LE_SET_CIG_PARAMS, param, params_len, std::move(cb)); } void btsnd_hcic_create_cis(uint8_t num_cis, const EXT_CIS_CREATE_CFG* cis_cfg, @@ -482,7 +482,7 @@ void btsnd_hcic_create_cis(uint8_t num_cis, const EXT_CIS_CREATE_CFG* cis_cfg, UINT16_TO_STREAM(pp, cis_cfg[i].acl_conn_handle); } - btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_LE_CREATE_CIS, param, params_len, std::move(cb)); + btu_hcif_send_cmd_with_cb(HCI_LE_CREATE_CIS, param, params_len, std::move(cb)); } void btsnd_hcic_remove_cig(uint8_t cig_id, base::OnceCallback<void(uint8_t*, uint16_t)> cb) { @@ -492,7 +492,7 @@ void btsnd_hcic_remove_cig(uint8_t cig_id, base::OnceCallback<void(uint8_t*, uin UINT8_TO_STREAM(pp, cig_id); - btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_LE_REMOVE_CIG, param, params_len, std::move(cb)); + btu_hcif_send_cmd_with_cb(HCI_LE_REMOVE_CIG, param, params_len, std::move(cb)); } void btsnd_hcic_req_peer_sca(uint16_t conn_handle) { @@ -578,8 +578,7 @@ void btsnd_hcic_setup_iso_data_path(uint16_t iso_handle, uint8_t data_path_dir, UINT8_TO_STREAM(pp, codec_conf.size()); ARRAY_TO_STREAM(pp, codec_conf.data(), static_cast<int>(codec_conf.size())); - btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_LE_SETUP_ISO_DATA_PATH, param, params_len, - std::move(cb)); + btu_hcif_send_cmd_with_cb(HCI_LE_SETUP_ISO_DATA_PATH, param, params_len, std::move(cb)); } void btsnd_hcic_remove_iso_data_path(uint16_t iso_handle, uint8_t data_path_dir, @@ -591,8 +590,7 @@ void btsnd_hcic_remove_iso_data_path(uint16_t iso_handle, uint8_t data_path_dir, UINT16_TO_STREAM(pp, iso_handle); UINT8_TO_STREAM(pp, data_path_dir); - btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_LE_REMOVE_ISO_DATA_PATH, param, params_len, - std::move(cb)); + btu_hcif_send_cmd_with_cb(HCI_LE_REMOVE_ISO_DATA_PATH, param, params_len, std::move(cb)); } void btsnd_hcic_read_iso_link_quality(uint16_t iso_handle, @@ -603,8 +601,7 @@ void btsnd_hcic_read_iso_link_quality(uint16_t iso_handle, UINT16_TO_STREAM(pp, iso_handle); - btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_LE_READ_ISO_LINK_QUALITY, param, params_len, - std::move(cb)); + btu_hcif_send_cmd_with_cb(HCI_LE_READ_ISO_LINK_QUALITY, param, params_len, std::move(cb)); } void btsnd_hcic_ble_periodic_advertising_create_sync(uint8_t options, uint8_t adv_sid, @@ -632,7 +629,7 @@ void btsnd_hcic_ble_periodic_advertising_create_sync(uint8_t options, uint8_t ad void btsnd_hcic_ble_periodic_advertising_create_sync_cancel( base::OnceCallback<void(uint8_t*, uint16_t)> cb) { - btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_BLE_PERIODIC_ADVERTISING_CREATE_SYNC_CANCEL, nullptr, + btu_hcif_send_cmd_with_cb(HCI_BLE_PERIODIC_ADVERTISING_CREATE_SYNC_CANCEL, nullptr, HCIC_PARAM_SIZE_PERIODIC_ADVERTISING_CREATE_SYNC_CANCEL, std::move(cb)); } @@ -643,7 +640,7 @@ void btsnd_hcic_ble_periodic_advertising_terminate_sync( UINT16_TO_STREAM(pp, sync_handle); - btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_BLE_PERIODIC_ADVERTISING_TERMINATE_SYNC, param, + btu_hcif_send_cmd_with_cb(HCI_BLE_PERIODIC_ADVERTISING_TERMINATE_SYNC, param, HCIC_PARAM_SIZE_PERIODIC_ADVERTISING_TERMINATE_SYNC, std::move(cb)); } @@ -657,7 +654,7 @@ void btsnd_hci_ble_add_device_to_periodic_advertiser_list( BDADDR_TO_STREAM(pp, adv_addr); UINT8_TO_STREAM(pp, adv_sid); - btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_BLE_ADD_DEVICE_TO_PERIODIC_ADVERTISER_LIST, param, + btu_hcif_send_cmd_with_cb(HCI_BLE_ADD_DEVICE_TO_PERIODIC_ADVERTISER_LIST, param, HCIC_PARAM_SIZE_ADD_DEVICE_TO_PERIODIC_ADVERTISER_LIST, std::move(cb)); } @@ -671,13 +668,13 @@ void btsnd_hci_ble_remove_device_from_periodic_advertiser_list( BDADDR_TO_STREAM(pp, adv_addr); UINT8_TO_STREAM(pp, adv_sid); - btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_BLE_REMOVE_DEVICE_FROM_PERIODIC_ADVERTISER_LIST, param, + btu_hcif_send_cmd_with_cb(HCI_BLE_REMOVE_DEVICE_FROM_PERIODIC_ADVERTISER_LIST, param, HCIC_PARAM_SIZE_REMOVE_DEVICE_FROM_PERIODIC_ADVERTISER_LIST, std::move(cb)); } void btsnd_hci_ble_clear_periodic_advertiser_list(base::OnceCallback<void(uint8_t*, uint16_t)> cb) { - btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_BLE_CLEAR_PERIODIC_ADVERTISER_LIST, nullptr, + btu_hcif_send_cmd_with_cb(HCI_BLE_CLEAR_PERIODIC_ADVERTISER_LIST, nullptr, HCIC_PARAM_SIZE_CLEAR_PERIODIC_ADVERTISER_LIST, std::move(cb)); } @@ -689,7 +686,7 @@ void btsnd_hcic_ble_set_periodic_advertising_receive_enable( UINT16_TO_STREAM(pp, sync_handle); UINT8_TO_STREAM(pp, (enable ? 0x01 : 0x00)); - btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_LE_SET_PERIODIC_ADVERTISING_RECEIVE_ENABLE, param, + btu_hcif_send_cmd_with_cb(HCI_LE_SET_PERIODIC_ADVERTISING_RECEIVE_ENABLE, param, HCIC_PARAM_SIZE_SET_PERIODIC_ADVERTISING_RECEIVE_ENABLE, std::move(cb)); } @@ -703,7 +700,7 @@ void btsnd_hcic_ble_periodic_advertising_sync_transfer( UINT16_TO_STREAM(pp, service_data); UINT16_TO_STREAM(pp, sync_handle); - btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_LE_PERIODIC_ADVERTISING_SYNC_TRANSFER, param, + btu_hcif_send_cmd_with_cb(HCI_LE_PERIODIC_ADVERTISING_SYNC_TRANSFER, param, HCIC_PARAM_SIZE_PERIODIC_ADVERTISING_SYNC_TRANSFER, std::move(cb)); } @@ -717,7 +714,7 @@ void btsnd_hcic_ble_periodic_advertising_set_info_transfer( UINT16_TO_STREAM(pp, service_data); UINT8_TO_STREAM(pp, adv_handle); - btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_LE_PERIODIC_ADVERTISING_SET_INFO_TRANSFER, param, + btu_hcif_send_cmd_with_cb(HCI_LE_PERIODIC_ADVERTISING_SET_INFO_TRANSFER, param, HCIC_PARAM_SIZE_PERIODIC_ADVERTISING_SET_INFO_TRANSFER, std::move(cb)); } @@ -733,7 +730,7 @@ void btsnd_hcic_ble_set_periodic_advertising_sync_transfer_params( UINT16_TO_STREAM(pp, sync_timeout); UINT8_TO_STREAM(pp, cte_type); - btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_LE_SET_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAM, param, + btu_hcif_send_cmd_with_cb(HCI_LE_SET_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAM, param, HCIC_PARAM_SIZE_SET_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMS, std::move(cb)); } @@ -750,7 +747,7 @@ void btsnd_hcic_ble_set_default_periodic_advertising_sync_transfer_params( UINT16_TO_STREAM(pp, sync_timeout); UINT8_TO_STREAM(pp, cte_type); - btu_hcif_send_cmd_with_cb( - FROM_HERE, HCI_LE_SET_DEFAULT_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAM, param, - HCIC_PARAM_SIZE_SET_DEFAULT_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMS, std::move(cb)); + btu_hcif_send_cmd_with_cb(HCI_LE_SET_DEFAULT_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAM, param, + HCIC_PARAM_SIZE_SET_DEFAULT_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMS, + std::move(cb)); } diff --git a/system/stack/hcic/hcicmds.cc b/system/stack/hcic/hcicmds.cc index 4183df86c2..257be53656 100644 --- a/system/stack/hcic/hcicmds.cc +++ b/system/stack/hcic/hcicmds.cc @@ -1472,7 +1472,7 @@ void btsnd_hcic_read_encryption_key_size(uint16_t handle, ReadEncKeySizeCb cb) { uint8_t* p = param; UINT16_TO_STREAM(p, handle); - btu_hcif_send_cmd_with_cb(FROM_HERE, HCI_READ_ENCR_KEY_SIZE, param, len, + btu_hcif_send_cmd_with_cb(HCI_READ_ENCR_KEY_SIZE, param, len, base::Bind(&read_encryption_key_size_complete, base::Passed(&cb))); } @@ -1566,7 +1566,7 @@ void btsnd_hcic_vendor_spec_cmd(uint16_t opcode, uint8_t len, uint8_t* p_data, tBTM_VSC_CMPL_CB* p_cmd_cplt_cback) { uint16_t v_opcode = HCI_GRP_VENDOR_SPECIFIC | opcode; - btu_hcif_send_cmd_with_cb(FROM_HERE, v_opcode, p_data, len, + btu_hcif_send_cmd_with_cb(v_opcode, p_data, len, base::BindOnce(&btsnd_hcic_vendor_spec_complete, base::Unretained(p_cmd_cplt_cback), v_opcode)); } diff --git a/system/stack/include/btu_hcif.h b/system/stack/include/btu_hcif.h index 13ee0f1493..0d1bceba63 100644 --- a/system/stack/include/btu_hcif.h +++ b/system/stack/include/btu_hcif.h @@ -27,8 +27,8 @@ *********************************** */ void btu_hcif_send_cmd(uint8_t controller_id, const BT_HDR* p_msg); -void btu_hcif_send_cmd_with_cb(const base::Location& posted_from, uint16_t opcode, uint8_t* params, - uint8_t params_len, base::OnceCallback<void(uint8_t*, uint16_t)> cb); +void btu_hcif_send_cmd_with_cb(uint16_t opcode, uint8_t* params, uint8_t params_len, + base::OnceCallback<void(uint8_t*, uint16_t)> cb); void btu_hci_msg_process(BT_HDR* p_msg); namespace bluetooth::legacy::testing { diff --git a/system/stack/mmc/daemon/service.cc b/system/stack/mmc/daemon/service.cc index d2dee226d2..0ac49a5746 100644 --- a/system/stack/mmc/daemon/service.cc +++ b/system/stack/mmc/daemon/service.cc @@ -286,9 +286,9 @@ bool Service::StartWorkerThread(int fd, struct sockaddr_un addr, log::warn("Failed to enable real time scheduling"); } - if (!thread_pool_.back().first->DoInThread( - FROM_HERE, base::BindOnce(&StartSocketListener, fd, std::move(addr), - std::move(task_ended), std::move(codec_server)))) { + if (!thread_pool_.back().first->DoInThread(base::BindOnce(&StartSocketListener, fd, + std::move(addr), std::move(task_ended), + std::move(codec_server)))) { log::error("Failed to run task"); return false; } diff --git a/system/test/common/main_handler.cc b/system/test/common/main_handler.cc index c6e792c4dc..87e97d9c49 100644 --- a/system/test/common/main_handler.cc +++ b/system/test/common/main_handler.cc @@ -42,13 +42,13 @@ void do_post_on_bt_main(BtMainClosure closure) { closure(); } } // namespace bt_status_t do_in_main_thread(base::OnceClosure task) { - bluetooth::log::assert_that(main_thread.DoInThread(FROM_HERE, std::move(task)), + bluetooth::log::assert_that(main_thread.DoInThread(std::move(task)), "Unable to run on main thread"); return BT_STATUS_SUCCESS; } bt_status_t do_in_main_thread_delayed(base::OnceClosure task, std::chrono::microseconds delay) { - bluetooth::log::assert_that(!main_thread.DoInThreadDelayed(FROM_HERE, std::move(task), delay), + bluetooth::log::assert_that(!main_thread.DoInThreadDelayed(std::move(task), delay), "Unable to run on main thread delayed"); return BT_STATUS_SUCCESS; } diff --git a/system/test/mock/mock_jni_thread.cc b/system/test/mock/mock_jni_thread.cc index eb8b6db093..2a9365b748 100644 --- a/system/test/mock/mock_jni_thread.cc +++ b/system/test/mock/mock_jni_thread.cc @@ -46,8 +46,3 @@ bt_status_t do_in_jni_thread(base::OnceClosure task) { do_in_jni_thread_task_queue.push(std::move(task)); return BT_STATUS_SUCCESS; } -bt_status_t do_in_jni_thread(const base::Location& /* from_here */, base::OnceClosure task) { - inc_func_call_count(__func__); - do_in_jni_thread_task_queue.push(std::move(task)); - return BT_STATUS_SUCCESS; -} diff --git a/system/test/mock/mock_stack_btu_hcif.cc b/system/test/mock/mock_stack_btu_hcif.cc index 0a4da4bc03..1d27c8a0b7 100644 --- a/system/test/mock/mock_stack_btu_hcif.cc +++ b/system/test/mock/mock_stack_btu_hcif.cc @@ -34,9 +34,8 @@ using hci_cmd_cb = base::OnceCallback<void(uint8_t* /* return_parameters */, void btu_hcif_send_cmd(uint8_t /* controller_id */, const BT_HDR* /* p_buf */) { inc_func_call_count(__func__); } -void btu_hcif_send_cmd_with_cb(const base::Location& /* posted_from */, uint16_t /* opcode */, - uint8_t* /* params */, uint8_t /* params_len */, - hci_cmd_cb /* cb */) { +void btu_hcif_send_cmd_with_cb(uint16_t /* opcode */, uint8_t* /* params */, + uint8_t /* params_len */, hci_cmd_cb /* cb */) { inc_func_call_count(__func__); } void btu_hci_msg_process(BT_HDR* /* p_msg */) { inc_func_call_count(__func__); } |