Commit a5f063ff authored by Etienne Bergeron's avatar Etienne Bergeron Committed by Commit Bot

Avoid loading TTS library when not used

This CL fix a startup regression due to loading the voices DLLs early
after startup.

On startup, there a call to TtsControllerImpl::VoicesChanged(...).
The call check whether or not the TTS platform is loaded (TtsPlatformLoading(...)).
Unfortunately, this is accessing the singleton and creating it. The creation
triggers the DLL loading.


Bug: 869399
Change-Id: I639cec62ee176c36aee888413a1a91d893d165b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2505575Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: Etienne Bergeron <etienneb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822723}
parent 68f76f13
......@@ -307,7 +307,7 @@ bool TtsControllerImpl::IsSpeaking() {
}
void TtsControllerImpl::VoicesChanged() {
if (TtsPlatformLoading())
if (!voices_changed_delegates_.might_have_observers() || TtsPlatformLoading())
return;
// Existence of platform tts indicates explicit requests to tts. Since
......
......@@ -139,6 +139,11 @@ class MockTtsControllerDelegate : public TtsControllerDelegate {
};
#endif
class MockVoicesChangedDelegate : public VoicesChangedDelegate {
public:
void OnVoicesChanged() override {}
};
class TestTtsControllerImpl : public TtsControllerImpl {
public:
TestTtsControllerImpl() = default;
......@@ -170,6 +175,12 @@ class TtsControllerTest : public testing::Test {
#if defined(OS_CHROMEOS)
controller()->SetTtsControllerDelegateForTesting(&delegate_);
#endif
controller()->AddVoicesChangedDelegate(&voices_changed_);
}
void TearDown() override {
if (controller())
controller()->RemoveVoicesChangedDelegate(&voices_changed_);
}
MockTtsPlatformImpl* platform_impl() { return platform_impl_.get(); }
......@@ -216,6 +227,7 @@ class TtsControllerTest : public testing::Test {
#if defined(OS_CHROMEOS)
MockTtsControllerDelegate delegate_;
#endif
MockVoicesChangedDelegate voices_changed_;
};
TEST_F(TtsControllerTest, TestTtsControllerShutdown) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment