OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/test_runner/mock_web_speech_recognizer.h" | 5 #include "components/test_runner/mock_web_speech_recognizer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 blink::WebSpeechRecognizerClient* client) { | 176 blink::WebSpeechRecognizerClient* client) { |
177 handle_ = handle; | 177 handle_ = handle; |
178 client_ = client; | 178 client_ = client; |
179 } | 179 } |
180 | 180 |
181 void MockWebSpeechRecognizer::start( | 181 void MockWebSpeechRecognizer::start( |
182 const blink::WebSpeechRecognitionHandle& handle, | 182 const blink::WebSpeechRecognitionHandle& handle, |
183 const blink::WebSpeechRecognitionParams& params, | 183 const blink::WebSpeechRecognitionParams& params, |
184 blink::WebSpeechRecognizerClient* client) { | 184 blink::WebSpeechRecognizerClient* client) { |
185 was_aborted_ = false; | 185 was_aborted_ = false; |
186 if (!client_) { | 186 if (!client_ && !HasPendingNewContextTasks()) { |
187 handle_ = handle; | 187 handle_ = handle; |
188 client_ = client; | 188 client_ = client; |
189 } else { | 189 } else { |
190 task_queue_.push_back(new SwitchClientHandleTask(this, handle, client)); | 190 task_queue_.push_back(new SwitchClientHandleTask(this, handle, client)); |
191 } | 191 } |
192 | 192 |
193 task_queue_.push_back( | 193 task_queue_.push_back( |
194 new ClientCallTask(this, &blink::WebSpeechRecognizerClient::didStart)); | 194 new ClientCallTask(this, &blink::WebSpeechRecognizerClient::didStart)); |
195 task_queue_.push_back(new ClientCallTask( | 195 task_queue_.push_back(new ClientCallTask( |
196 this, &blink::WebSpeechRecognizerClient::didStartAudio)); | 196 this, &blink::WebSpeechRecognizerClient::didStartAudio)); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 delete task; | 311 delete task; |
312 | 312 |
313 if (task_queue_.empty()) { | 313 if (task_queue_.empty()) { |
314 task_queue_running_ = false; | 314 task_queue_running_ = false; |
315 return; | 315 return; |
316 } | 316 } |
317 | 317 |
318 PostRunTaskFromQueue(); | 318 PostRunTaskFromQueue(); |
319 } | 319 } |
320 | 320 |
| 321 bool MockWebSpeechRecognizer::HasPendingNewContextTasks() const { |
| 322 for (const auto& task : task_queue_) { |
| 323 if (task->isNewContextTask()) |
| 324 return true; |
| 325 } |
| 326 return false; |
| 327 } |
| 328 |
321 } // namespace test_runner | 329 } // namespace test_runner |
OLD | NEW |