Commit 1a148103 authored by Adithya Srinivasan's avatar Adithya Srinivasan Committed by Commit Bot

Add connection error handler for SpeechRecognitionSessionClient

Bug: 865571
Change-Id: I722a58f53bbeee0236e6fb64b8f7eb9956526c3c
Reviewed-on: https://chromium-review.googlesource.com/1147485Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Adithya Srinivasan <adithyas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577520}
parent c50c83b1
......@@ -201,7 +201,11 @@ SpeechRecognitionSession::SpeechRecognitionSession(
: session_id_(SpeechRecognitionManager::kSessionIDInvalid),
client_(std::move(client_ptr_info)),
stopped_(false),
weak_factory_(this) {}
weak_factory_(this) {
client_.set_connection_error_handler(
base::BindOnce(&SpeechRecognitionSession::ConnectionErrorHandler,
base::Unretained(this)));
}
SpeechRecognitionSession::~SpeechRecognitionSession() {
// If a connection error happens and the session hasn't been stopped yet,
......@@ -273,4 +277,9 @@ void SpeechRecognitionSession::OnAudioLevelsChange(int session_id,
void SpeechRecognitionSession::OnEnvironmentEstimationComplete(int session_id) {
}
void SpeechRecognitionSession::ConnectionErrorHandler() {
if (!stopped_)
Abort();
}
} // namespace content
......@@ -109,6 +109,8 @@ class SpeechRecognitionSession : public blink::mojom::SpeechRecognitionSession,
float noise_volume) override;
private:
void ConnectionErrorHandler();
int session_id_;
blink::mojom::SpeechRecognitionSessionClientPtr client_;
bool stopped_;
......
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