Commit 8e8bb6ea authored by evliu's avatar evliu Committed by Commit Bot

Check SODA paths before launching service

This CL moves the code checking the SODA paths to before the service
is launched.

Bug: 1121384
Change-Id: I70e1caf6086dce94a25c425a2959381293545bec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2429745Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Commit-Queue: Evan Liu <evliu@google.com>
Cr-Commit-Position: refs/heads/master@{#810434}
parent d9d6db5a
...@@ -64,22 +64,19 @@ void SpeechRecognitionService::LaunchIfNotRunning() { ...@@ -64,22 +64,19 @@ void SpeechRecognitionService::LaunchIfNotRunning() {
PrefService* prefs = user_prefs::UserPrefs::Get(context_); PrefService* prefs = user_prefs::UserPrefs::Get(context_);
DCHECK(prefs); DCHECK(prefs);
if (enable_soda_) { auto binary_path = prefs->GetFilePath(prefs::kSodaBinaryPath);
content::ServiceProcessHost::Launch( auto config_path = SpeechRecognitionService::GetSodaConfigPath(prefs);
speech_recognition_service_.BindNewPipeAndPassReceiver(), if (enable_soda_ && (binary_path.empty() || config_path.empty())) {
content::ServiceProcessHost::Options() LOG(ERROR) << "Unable to find SODA files on the device.";
.WithDisplayName( return;
IDS_UTILITY_PROCESS_SPEECH_RECOGNITION_SERVICE_NAME)
.Pass());
} else {
content::ServiceProcessHost::Launch(
speech_recognition_service_.BindNewPipeAndPassReceiver(),
content::ServiceProcessHost::Options()
.WithDisplayName(
IDS_UTILITY_PROCESS_SPEECH_RECOGNITION_SERVICE_NAME)
.Pass());
} }
content::ServiceProcessHost::Launch(
speech_recognition_service_.BindNewPipeAndPassReceiver(),
content::ServiceProcessHost::Options()
.WithDisplayName(IDS_UTILITY_PROCESS_SPEECH_RECOGNITION_SERVICE_NAME)
.Pass());
// Ensure that if the interface is ever disconnected (e.g. the service // Ensure that if the interface is ever disconnected (e.g. the service
// process crashes) or goes idle for a short period of time -- meaning there // process crashes) or goes idle for a short period of time -- meaning there
// are no in-flight messages and no other interfaces bound through this // are no in-flight messages and no other interfaces bound through this
...@@ -90,15 +87,8 @@ void SpeechRecognitionService::LaunchIfNotRunning() { ...@@ -90,15 +87,8 @@ void SpeechRecognitionService::LaunchIfNotRunning() {
speech_recognition_service_client_.reset(); speech_recognition_service_client_.reset();
if (enable_soda_) { if (enable_soda_)
auto binary_path = prefs->GetFilePath(prefs::kSodaBinaryPath);
auto config_path = SpeechRecognitionService::GetSodaConfigPath(prefs);
if (binary_path.empty() || config_path.empty()) {
LOG(ERROR) << "Unable to find SODA files on the device.";
return;
}
speech_recognition_service_->SetSodaPath(binary_path, config_path); speech_recognition_service_->SetSodaPath(binary_path, config_path);
}
speech_recognition_service_->BindSpeechRecognitionServiceClient( speech_recognition_service_->BindSpeechRecognitionServiceClient(
speech_recognition_service_client_.BindNewPipeAndPassRemote()); speech_recognition_service_client_.BindNewPipeAndPassRemote());
......
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