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

Side by Side Diff: content/shell/renderer/test_runner/mock_web_speech_recognizer.cc

Issue 583113002: Abstract class WebTestDelegate to chromium c++ style. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update test_runner Created 6 years, 3 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 unified diff | Download patch
OLDNEW
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/renderer/test_runner/mock_web_speech_recognizer.h" 5 #include "content/shell/renderer/test_runner/mock_web_speech_recognizer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/shell/renderer/test_runner/WebTestDelegate.h" 8 #include "content/shell/renderer/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"
11 11
12 namespace content { 12 namespace content {
13 13
14 namespace { 14 namespace {
15 15
16 // Task class for calling a client function that does not take any parameters. 16 // Task class for calling a client function that does not take any parameters.
17 typedef void (blink::WebSpeechRecognizerClient::*ClientFunctionPointer)( 17 typedef void (blink::WebSpeechRecognizerClient::*ClientFunctionPointer)(
18 const blink::WebSpeechRecognitionHandle&); 18 const blink::WebSpeechRecognitionHandle&);
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 ClearTaskQueue(); 212 ClearTaskQueue();
213 task_queue_.push_back(new ErrorTask(this, code, message)); 213 task_queue_.push_back(new ErrorTask(this, code, message));
214 task_queue_.push_back( 214 task_queue_.push_back(
215 new ClientCallTask(this, &blink::WebSpeechRecognizerClient::didEnd)); 215 new ClientCallTask(this, &blink::WebSpeechRecognizerClient::didEnd));
216 StartTaskQueue(); 216 StartTaskQueue();
217 } 217 }
218 218
219 void MockWebSpeechRecognizer::StartTaskQueue() { 219 void MockWebSpeechRecognizer::StartTaskQueue() {
220 if (task_queue_running_) 220 if (task_queue_running_)
221 return; 221 return;
222 delegate_->postTask(new StepTask(this)); 222 delegate_->PostTask(new StepTask(this));
223 task_queue_running_ = true; 223 task_queue_running_ = true;
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 void MockWebSpeechRecognizer::StepTask::RunIfValid() { 234 void MockWebSpeechRecognizer::StepTask::RunIfValid() {
235 if (object_->task_queue_.empty()) { 235 if (object_->task_queue_.empty()) {
236 object_->task_queue_running_ = false; 236 object_->task_queue_running_ = false;
237 return; 237 return;
238 } 238 }
239 239
240 Task* task = object_->task_queue_.front(); 240 Task* task = object_->task_queue_.front();
241 object_->task_queue_.pop_front(); 241 object_->task_queue_.pop_front();
242 task->run(); 242 task->run();
243 delete task; 243 delete task;
244 244
245 if (object_->task_queue_.empty()) { 245 if (object_->task_queue_.empty()) {
246 object_->task_queue_running_ = false; 246 object_->task_queue_running_ = false;
247 return; 247 return;
248 } 248 }
249 249
250 object_->delegate_->postTask(new StepTask(object_)); 250 object_->delegate_->PostTask(new StepTask(object_));
251 } 251 }
252 252
253 } // namespace content 253 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698