Loading system/gd/hci/hci_layer_test.cc +1 −1 Original line number Diff line number Diff line Loading @@ -175,7 +175,7 @@ class HciTest : public ::testing::Test { } hal = new TestHciHal(); fake_registry_.InjectTestModule(&hal::HciHal::Factory, hal); fake_registry_.StartTestModule<DependsOnHci>(); fake_registry_.Start<DependsOnHci>(&fake_registry_.GetTestThread()); hci = static_cast<HciLayer*>(fake_registry_.GetModuleUnderTest(&HciLayer::Factory)); upper = static_cast<DependsOnHci*>(fake_registry_.GetModuleUnderTest(&DependsOnHci::Factory)); ASSERT(fake_registry_.IsStarted<HciLayer>()); Loading system/gd/module.cc +8 −4 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ Handler* Module::GetHandler() { return handler_; } ModuleRegistry* Module::GetModuleRegistry() { const ModuleRegistry* Module::GetModuleRegistry() { return registry_; } Loading Loading @@ -59,6 +59,11 @@ void ModuleRegistry::Start(ModuleList* modules, Thread* thread) { } } void ModuleRegistry::set_registry_and_handler(Module* instance, Thread* thread) const { instance->registry_ = this; instance->handler_ = new Handler(thread); } Module* ModuleRegistry::Start(const ModuleFactory* module, Thread* thread) { auto started_instance = started_modules_.find(module); if (started_instance != started_modules_.end()) { Loading @@ -66,10 +71,9 @@ Module* ModuleRegistry::Start(const ModuleFactory* module, Thread* thread) { } Module* instance = module->ctor_(); instance->registry_ = this; instance->handler_ = new Handler(thread); instance->ListDependencies(&instance->dependencies_); set_registry_and_handler(instance, thread); instance->ListDependencies(&instance->dependencies_); Start(&instance->dependencies_, thread); instance->Start(); Loading system/gd/module.h +7 −7 Original line number Diff line number Diff line Loading @@ -27,6 +27,8 @@ namespace bluetooth { const std::chrono::milliseconds kModuleStopTimeout = std::chrono::milliseconds(20); class Module; class ModuleRegistry; Loading Loading @@ -76,7 +78,7 @@ class Module { ::bluetooth::os::Handler* GetHandler(); ModuleRegistry* GetModuleRegistry(); const ModuleRegistry* GetModuleRegistry(); template <class T> T* GetDependency() const { Loading @@ -88,7 +90,7 @@ class Module { ::bluetooth::os::Handler* handler_ = nullptr; ModuleList dependencies_; ModuleRegistry* registry_; const ModuleRegistry* registry_; }; class ModuleRegistry { Loading Loading @@ -119,6 +121,8 @@ class ModuleRegistry { protected: Module* Get(const ModuleFactory* module) const; void set_registry_and_handler(Module* instance, ::bluetooth::os::Thread* thread) const; os::Handler* GetModuleHandler(const ModuleFactory* module) const; std::map<const ModuleFactory*, Module*> started_modules_; Loading @@ -130,6 +134,7 @@ class TestModuleRegistry : public ModuleRegistry { void InjectTestModule(const ModuleFactory* module, Module* instance) { start_order_.push_back(module); started_modules_[module] = instance; set_registry_and_handler(instance, &test_thread); } Module* GetModuleUnderTest(const ModuleFactory* module) const { Loading @@ -144,11 +149,6 @@ class TestModuleRegistry : public ModuleRegistry { return test_thread; } template <class T> T* StartTestModule() { return Start<T>(&test_thread); } bool SynchronizeModuleHandler(const ModuleFactory* module, std::chrono::milliseconds timeout) const { std::promise<void> promise; os::Handler* handler = GetTestModuleHandler(module); Loading Loading
system/gd/hci/hci_layer_test.cc +1 −1 Original line number Diff line number Diff line Loading @@ -175,7 +175,7 @@ class HciTest : public ::testing::Test { } hal = new TestHciHal(); fake_registry_.InjectTestModule(&hal::HciHal::Factory, hal); fake_registry_.StartTestModule<DependsOnHci>(); fake_registry_.Start<DependsOnHci>(&fake_registry_.GetTestThread()); hci = static_cast<HciLayer*>(fake_registry_.GetModuleUnderTest(&HciLayer::Factory)); upper = static_cast<DependsOnHci*>(fake_registry_.GetModuleUnderTest(&DependsOnHci::Factory)); ASSERT(fake_registry_.IsStarted<HciLayer>()); Loading
system/gd/module.cc +8 −4 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ Handler* Module::GetHandler() { return handler_; } ModuleRegistry* Module::GetModuleRegistry() { const ModuleRegistry* Module::GetModuleRegistry() { return registry_; } Loading Loading @@ -59,6 +59,11 @@ void ModuleRegistry::Start(ModuleList* modules, Thread* thread) { } } void ModuleRegistry::set_registry_and_handler(Module* instance, Thread* thread) const { instance->registry_ = this; instance->handler_ = new Handler(thread); } Module* ModuleRegistry::Start(const ModuleFactory* module, Thread* thread) { auto started_instance = started_modules_.find(module); if (started_instance != started_modules_.end()) { Loading @@ -66,10 +71,9 @@ Module* ModuleRegistry::Start(const ModuleFactory* module, Thread* thread) { } Module* instance = module->ctor_(); instance->registry_ = this; instance->handler_ = new Handler(thread); instance->ListDependencies(&instance->dependencies_); set_registry_and_handler(instance, thread); instance->ListDependencies(&instance->dependencies_); Start(&instance->dependencies_, thread); instance->Start(); Loading
system/gd/module.h +7 −7 Original line number Diff line number Diff line Loading @@ -27,6 +27,8 @@ namespace bluetooth { const std::chrono::milliseconds kModuleStopTimeout = std::chrono::milliseconds(20); class Module; class ModuleRegistry; Loading Loading @@ -76,7 +78,7 @@ class Module { ::bluetooth::os::Handler* GetHandler(); ModuleRegistry* GetModuleRegistry(); const ModuleRegistry* GetModuleRegistry(); template <class T> T* GetDependency() const { Loading @@ -88,7 +90,7 @@ class Module { ::bluetooth::os::Handler* handler_ = nullptr; ModuleList dependencies_; ModuleRegistry* registry_; const ModuleRegistry* registry_; }; class ModuleRegistry { Loading Loading @@ -119,6 +121,8 @@ class ModuleRegistry { protected: Module* Get(const ModuleFactory* module) const; void set_registry_and_handler(Module* instance, ::bluetooth::os::Thread* thread) const; os::Handler* GetModuleHandler(const ModuleFactory* module) const; std::map<const ModuleFactory*, Module*> started_modules_; Loading @@ -130,6 +134,7 @@ class TestModuleRegistry : public ModuleRegistry { void InjectTestModule(const ModuleFactory* module, Module* instance) { start_order_.push_back(module); started_modules_[module] = instance; set_registry_and_handler(instance, &test_thread); } Module* GetModuleUnderTest(const ModuleFactory* module) const { Loading @@ -144,11 +149,6 @@ class TestModuleRegistry : public ModuleRegistry { return test_thread; } template <class T> T* StartTestModule() { return Start<T>(&test_thread); } bool SynchronizeModuleHandler(const ModuleFactory* module, std::chrono::milliseconds timeout) const { std::promise<void> promise; os::Handler* handler = GetTestModuleHandler(module); Loading