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 "content/shell/test_runner/mock_web_speech_recognizer.h" | 5 #include "content/shell/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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 } // namespace | 153 } // namespace |
154 | 154 |
155 MockWebSpeechRecognizer::MockWebSpeechRecognizer() | 155 MockWebSpeechRecognizer::MockWebSpeechRecognizer() |
156 : client_(nullptr), | 156 : client_(nullptr), |
157 was_aborted_(false), | 157 was_aborted_(false), |
158 task_queue_running_(false), | 158 task_queue_running_(false), |
159 delegate_(0), | 159 delegate_(0), |
160 weak_factory_(this) {} | 160 weak_factory_(this) {} |
161 | 161 |
162 MockWebSpeechRecognizer::~MockWebSpeechRecognizer() { | 162 MockWebSpeechRecognizer::~MockWebSpeechRecognizer() { |
163 ClearTaskQueue(); | 163 SetDelegate(nullptr); |
164 } | 164 } |
165 | 165 |
166 bool MockWebSpeechRecognizer::Task::isNewContextTask() const { | 166 bool MockWebSpeechRecognizer::Task::isNewContextTask() const { |
167 return false; | 167 return false; |
168 } | 168 } |
169 | 169 |
170 void MockWebSpeechRecognizer::SetDelegate(WebTestDelegate* delegate) { | 170 void MockWebSpeechRecognizer::SetDelegate(WebTestDelegate* delegate) { |
171 delegate_ = delegate; | 171 delegate_ = delegate; |
| 172 // No delegate to forward to, clear out pending tasks. |
| 173 if (!delegate_) |
| 174 ClearTaskQueue(); |
172 } | 175 } |
173 | 176 |
174 void MockWebSpeechRecognizer::SetClientContext( | 177 void MockWebSpeechRecognizer::SetClientContext( |
175 const blink::WebSpeechRecognitionHandle& handle, | 178 const blink::WebSpeechRecognitionHandle& handle, |
176 blink::WebSpeechRecognizerClient* client) { | 179 blink::WebSpeechRecognizerClient* client) { |
177 handle_ = handle; | 180 handle_ = handle; |
178 client_ = client; | 181 client_ = client; |
179 } | 182 } |
180 | 183 |
181 void MockWebSpeechRecognizer::start( | 184 void MockWebSpeechRecognizer::start( |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 | 323 |
321 bool MockWebSpeechRecognizer::HasPendingNewContextTasks() const { | 324 bool MockWebSpeechRecognizer::HasPendingNewContextTasks() const { |
322 for (auto* task : task_queue_) { | 325 for (auto* task : task_queue_) { |
323 if (task->isNewContextTask()) | 326 if (task->isNewContextTask()) |
324 return true; | 327 return true; |
325 } | 328 } |
326 return false; | 329 return false; |
327 } | 330 } |
328 | 331 |
329 } // namespace test_runner | 332 } // namespace test_runner |
OLD | NEW |