Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(766)

Unified Diff: components/test_runner/mock_web_speech_recognizer.cc

Issue 1750213004: Simplify mock web speech recognizer's "onend" handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/speech/scripted/speechrecognition-restart-onend.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/test_runner/mock_web_speech_recognizer.cc
diff --git a/components/test_runner/mock_web_speech_recognizer.cc b/components/test_runner/mock_web_speech_recognizer.cc
index 9504feab97598ea15e17e3312dec5d44961825bd..e80958f8ba4438cd30ef3de9b90a696af1b76ac3 100644
--- a/components/test_runner/mock_web_speech_recognizer.cc
+++ b/components/test_runner/mock_web_speech_recognizer.cc
@@ -111,22 +111,18 @@ class ErrorTask : public MockWebSpeechRecognizer::Task {
// Task for tidying up after recognition task has ended.
class EndedTask : public MockWebSpeechRecognizer::Task {
public:
- EndedTask(MockWebSpeechRecognizer* mock,
- blink::WebSpeechRecognitionHandle handle)
- : MockWebSpeechRecognizer::Task(mock), handle_(handle) {}
+ EndedTask(MockWebSpeechRecognizer* mock)
+ : MockWebSpeechRecognizer::Task(mock) {}
~EndedTask() override {}
void run() override {
- // Reset recognizer's handle if it hasn't been replaced.
- if (recognizer_->Handle() == handle_)
- recognizer_->Handle().reset();
- handle_.reset();
+ blink::WebSpeechRecognitionHandle handle = recognizer_->Handle();
+ recognizer_->Handle().reset();
+ recognizer_->Client()->didEnd(handle);
}
private:
- blink::WebSpeechRecognitionHandle handle_;
-
DISALLOW_COPY_AND_ASSIGN(EndedTask);
};
@@ -175,9 +171,7 @@ void MockWebSpeechRecognizer::start(
new ClientCallTask(this, &blink::WebSpeechRecognizerClient::didEndSound));
task_queue_.push_back(
new ClientCallTask(this, &blink::WebSpeechRecognizerClient::didEndAudio));
- task_queue_.push_back(
- new ClientCallTask(this, &blink::WebSpeechRecognizerClient::didEnd));
- task_queue_.push_back(new EndedTask(this, handle_));
+ task_queue_.push_back(new EndedTask(this));
StartTaskQueue();
}
@@ -200,9 +194,7 @@ void MockWebSpeechRecognizer::abort(
ClearTaskQueue();
was_aborted_ = true;
- task_queue_.push_back(
- new ClientCallTask(this, &blink::WebSpeechRecognizerClient::didEnd));
- task_queue_.push_back(new EndedTask(this, handle_));
+ task_queue_.push_back(new EndedTask(this));
StartTaskQueue();
}
@@ -239,9 +231,7 @@ void MockWebSpeechRecognizer::SetError(const blink::WebString& error,
ClearTaskQueue();
task_queue_.push_back(new ErrorTask(this, code, message));
- task_queue_.push_back(
- new ClientCallTask(this, &blink::WebSpeechRecognizerClient::didEnd));
- task_queue_.push_back(new EndedTask(this, handle_));
+ task_queue_.push_back(new EndedTask(this));
StartTaskQueue();
}
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/speech/scripted/speechrecognition-restart-onend.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698