Commit d29f3d1d authored by Abigail Klein's avatar Abigail Klein Committed by Chromium LUCI CQ

[Live Caption] Fix a crash caused by the SODAInstaller notifying an

observer.

This CL does two things:
1. Do not notify SODAInstallerObservers when the component has not been
updated. The crash was initiated when the component updater sent a
status update saying that the SODA component was up-to-date, which
occurred while SODA was running and not when it was installing. These
up-to-date messages should not be relayed to the SODAInstallerObservers.

2. Remove the CaptionsHandler from the SODAInstaller observer list when
the CaptionsHandler is destructed. The crash occurred because the
CaptionsHandler had not properly removed itself as an observer. Before
this CL, the CaptionsHandler removed itself when javascript was
disallowed, which was assumed to occur when the CaptionsHandler was
destructed. On testing, it turns out that this is not the case, so this
CL ensures that the CaptionsHandler is removed as an observer on
destruction.

Bug: 1055150, 1155625
Change-Id: Icb2073a1380f1d1cefc25690d84aa840804ff29c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2575005Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Abigail Klein <abigailbklein@google.com>
Cr-Commit-Position: refs/heads/master@{#834027}
parent 88b825e1
...@@ -108,13 +108,13 @@ void SODAInstallerImpl::OnEvent(Events event, const std::string& id) { ...@@ -108,13 +108,13 @@ void SODAInstallerImpl::OnEvent(Events event, const std::string& id) {
} }
} break; } break;
case Events::COMPONENT_UPDATED: case Events::COMPONENT_UPDATED:
case Events::COMPONENT_NOT_UPDATED:
NotifyOnSODAInstalled(); NotifyOnSODAInstalled();
break; break;
case Events::COMPONENT_UPDATE_ERROR: case Events::COMPONENT_UPDATE_ERROR:
NotifyOnSODAError(); NotifyOnSODAError();
break; break;
case Events::COMPONENT_CHECKING_FOR_UPDATES: case Events::COMPONENT_CHECKING_FOR_UPDATES:
case Events::COMPONENT_NOT_UPDATED:
// Do nothing. // Do nothing.
break; break;
} }
......
...@@ -23,7 +23,9 @@ namespace settings { ...@@ -23,7 +23,9 @@ namespace settings {
CaptionsHandler::CaptionsHandler(PrefService* prefs) : prefs_(prefs) {} CaptionsHandler::CaptionsHandler(PrefService* prefs) : prefs_(prefs) {}
CaptionsHandler::~CaptionsHandler() = default; CaptionsHandler::~CaptionsHandler() {
speech::SODAInstaller::GetInstance()->RemoveObserver(this);
}
void CaptionsHandler::RegisterMessages() { void CaptionsHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback( web_ui()->RegisterMessageCallback(
......
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