diff --git a/src/converter/converter_test.cc b/src/converter/converter_test.cc index ec651285f..351093a91 100644 --- a/src/converter/converter_test.cc +++ b/src/converter/converter_test.cc @@ -381,7 +381,9 @@ class ConverterTest : public testing::TestWithTempUserProfile { } std::unique_ptr CreateEngineWithMobilePredictor() { - return Engine::CreateMobileEngineHelper().value(); + return Engine::CreateMobileEngine( + std::make_unique()) + .value(); } bool FindCandidateByValue(absl::string_view value, diff --git a/src/engine/engine.cc b/src/engine/engine.cc index 210b419c8..1dc62f589 100644 --- a/src/engine/engine.cc +++ b/src/engine/engine.cc @@ -62,27 +62,23 @@ namespace mozc { absl::StatusOr> Engine::CreateDesktopEngine( std::unique_ptr data_manager) { constexpr bool kIsMobile = false; - - auto modules = std::make_unique(); - absl::Status modules_status = modules->Init(std::move(data_manager)); - if (!modules_status.ok()) { - return modules_status; - } - - return CreateEngine(std::move(modules), kIsMobile); + return CreateEngine(std::move(data_manager), kIsMobile); } absl::StatusOr> Engine::CreateMobileEngine( std::unique_ptr data_manager) { constexpr bool kIsMobile = true; + return CreateEngine(std::move(data_manager), kIsMobile); +} +absl::StatusOr> Engine::CreateEngine( + std::unique_ptr data_manager, bool is_mobile) { auto modules = std::make_unique(); absl::Status modules_status = modules->Init(std::move(data_manager)); if (!modules_status.ok()) { return modules_status; } - - return CreateEngine(std::move(modules), kIsMobile); + return CreateEngine(std::move(modules), is_mobile); } absl::StatusOr> Engine::CreateEngine( diff --git a/src/engine/engine.h b/src/engine/engine.h index 3a59d368a..49cc0d5bc 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -64,24 +64,14 @@ class Engine : public EngineInterface { static absl::StatusOr> CreateDesktopEngine( std::unique_ptr data_manager); - // Helper function for the above factory, where data manager is instantiated - // by a default constructor. Intended to be used for OssDataManager etc. - template - static absl::StatusOr> CreateDesktopEngineHelper() { - return CreateDesktopEngine(std::make_unique()); - } - // Creates an instance with mobile configuration from a data manager. The // ownership of data manager is passed to the engine instance. static absl::StatusOr> CreateMobileEngine( std::unique_ptr data_manager); - // Helper function for the above factory, where data manager is instantiated - // by a default constructor. Intended to be used for OssDataManager etc. - template - static absl::StatusOr> CreateMobileEngineHelper() { - return CreateMobileEngine(std::make_unique()); - } + // Creates an instance from a data manager and is_mobile flag. + static absl::StatusOr> CreateEngine( + std::unique_ptr data_manager, bool is_mobile); // Creates an instance with the given modules and is_mobile flag. static absl::StatusOr> CreateEngine( diff --git a/src/engine/mock_data_engine_factory.cc b/src/engine/mock_data_engine_factory.cc index 8e885d22a..b233b5892 100644 --- a/src/engine/mock_data_engine_factory.cc +++ b/src/engine/mock_data_engine_factory.cc @@ -38,7 +38,8 @@ namespace mozc { absl::StatusOr> MockDataEngineFactory::Create() { - return Engine::CreateDesktopEngineHelper(); + return Engine::CreateDesktopEngine( + std::make_unique()); } } // namespace mozc diff --git a/src/engine/oss_engine_factory.h b/src/engine/oss_engine_factory.h index 36263343d..ba6aa24cb 100644 --- a/src/engine/oss_engine_factory.h +++ b/src/engine/oss_engine_factory.h @@ -44,9 +44,9 @@ class OssEngineFactory { public: static absl::StatusOr> Create() { #ifdef __ANDROID__ - return Engine::CreateMobileEngineHelper(); + return Engine::CreateMobileEngine(std::make_unique()); #else // __ANDROID__ - return Engine::CreateDesktopEngineHelper(); + return Engine::CreateDesktopEngine(std::make_unique()); #endif // __ANDROID__ } };