| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "components/test_runner/web_test_delegate.h" | 8 #include "components/test_runner/web_test_delegate.h" |
| 9 #include "third_party/WebKit/public/web/WebSpeechRecognitionResult.h" | 9 #include "third_party/WebKit/public/web/WebSpeechRecognitionResult.h" |
| 10 #include "third_party/WebKit/public/web/WebSpeechRecognizerClient.h" | 10 #include "third_party/WebKit/public/web/WebSpeechRecognizerClient.h" |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 } | 224 } |
| 225 | 225 |
| 226 void MockWebSpeechRecognizer::ClearTaskQueue() { | 226 void MockWebSpeechRecognizer::ClearTaskQueue() { |
| 227 while (!task_queue_.empty()) { | 227 while (!task_queue_.empty()) { |
| 228 delete task_queue_.front(); | 228 delete task_queue_.front(); |
| 229 task_queue_.pop_front(); | 229 task_queue_.pop_front(); |
| 230 } | 230 } |
| 231 task_queue_running_ = false; | 231 task_queue_running_ = false; |
| 232 } | 232 } |
| 233 | 233 |
| 234 MockWebSpeechRecognizer::StepTask::StepTask(MockWebSpeechRecognizer* object) |
| 235 : WebMethodTask<MockWebSpeechRecognizer>(object) {} |
| 236 |
| 234 void MockWebSpeechRecognizer::StepTask::RunIfValid() { | 237 void MockWebSpeechRecognizer::StepTask::RunIfValid() { |
| 235 if (object_->task_queue_.empty()) { | 238 if (object_->task_queue_.empty()) { |
| 236 object_->task_queue_running_ = false; | 239 object_->task_queue_running_ = false; |
| 237 return; | 240 return; |
| 238 } | 241 } |
| 239 | 242 |
| 240 Task* task = object_->task_queue_.front(); | 243 Task* task = object_->task_queue_.front(); |
| 241 object_->task_queue_.pop_front(); | 244 object_->task_queue_.pop_front(); |
| 242 task->run(); | 245 task->run(); |
| 243 delete task; | 246 delete task; |
| 244 | 247 |
| 245 if (object_->task_queue_.empty()) { | 248 if (object_->task_queue_.empty()) { |
| 246 object_->task_queue_running_ = false; | 249 object_->task_queue_running_ = false; |
| 247 return; | 250 return; |
| 248 } | 251 } |
| 249 | 252 |
| 250 object_->delegate_->PostTask(new StepTask(object_)); | 253 object_->delegate_->PostTask(new StepTask(object_)); |
| 251 } | 254 } |
| 252 | 255 |
| 253 } // namespace test_runner | 256 } // namespace test_runner |
| OLD | NEW |