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

Commit 074d0512 authored by Zach Johnson's avatar Zach Johnson
Browse files

don't expose main thread message loop

ensure all calls go through the actual API

(will back message loop thread with rust's tokio runtime if running
with rust, to reduce thread transfer overhead at shim boundary)

Bug: 171749953
Tag: #gd-refactor
Test: gd/cert/run
Change-Id: I4d55a4b35a620d63638004cb0e553bbcc04dd69b
parent ba7a3a1b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ namespace base {
class MessageLoop;
}  // namespace base

base::MessageLoop* get_main_message_loop() { return NULL; }
bluetooth::common::MessageLoopThread* get_main_thread() { return nullptr; }

namespace {
const RawAddress bdaddr1({0x11, 0x22, 0x33, 0x44, 0x55, 0x66});
+1 −1
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ bt_status_t do_in_jni_thread(const base::Location& from_here,
                             base::OnceClosure task) {
  return BT_STATUS_SUCCESS;
}
base::MessageLoop* get_main_message_loop() { return nullptr; }
bluetooth::common::MessageLoopThread* get_main_thread() { return nullptr; }
bool interop_match_addr(const interop_feature_t feature,
                        const RawAddress* addr) {
  return false;
+1 −2
Original line number Diff line number Diff line
@@ -32,8 +32,7 @@ using bluetooth::common::OnceTimer;
using bluetooth::common::RepeatingTimer;
using bluetooth::common::time_get_os_boottime_us;

// fake get_main_message_loop implementation for alarm
base::MessageLoop* get_main_message_loop() { return nullptr; }
bluetooth::common::MessageLoopThread* get_main_thread() { return nullptr; }

namespace {
std::unordered_map<int, int> g_map;
+12 −15
Original line number Diff line number Diff line
@@ -135,19 +135,6 @@ class MessageLoopThread final {
   */
  base::MessageLoop* message_loop() const;

 private:
  /**
   * Static method to run the thread
   *
   * This is used instead of a C++ lambda because of the use of std::shared_ptr
   *
   * @param context needs to be a pointer to an instance of MessageLoopThread
   * @param start_up_promise a std::promise that is used to notify calling
   * thread the completion of message loop start-up
   */
  static void RunThread(MessageLoopThread* context,
                        std::promise<void> start_up_promise);

  /**
   * Post a task to run on this thread after a specified delay. If the task
   * needs to be cancelable before it's run, use base::CancelableClosure type
@@ -176,8 +163,18 @@ class MessageLoopThread final {
  bool DoInThreadDelayed(const base::Location& from_here,
                         base::OnceClosure task, const base::TimeDelta& delay);

  friend class RepeatingTimer;  // allow Timer to use DoInThreadDelayed()
  friend class OnceTimer;       // allow OnceTimer to use DoInThreadDelayed()
 private:
  /**
   * Static method to run the thread
   *
   * This is used instead of a C++ lambda because of the use of std::shared_ptr
   *
   * @param context needs to be a pointer to an instance of MessageLoopThread
   * @param start_up_promise a std::promise that is used to notify calling
   * thread the completion of message loop start-up
   */
  static void RunThread(MessageLoopThread* context,
                        std::promise<void> start_up_promise);

  /**
   * Actual method to run the thread, blocking until ShutDown() is called
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@

const btsnoop_t* btsnoop_get_interface() { return nullptr; }
const packet_fragmenter_t* packet_fragmenter_get_interface() { return nullptr; }
base::MessageLoop* get_main_message_loop() { return nullptr; }
bluetooth::common::MessageLoopThread* get_main_thread() { return nullptr; }

namespace bluetooth {
namespace bqr {
Loading