| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/float_util.h" | 8 #include "base/float_util.h" |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 GetPlatformImpl()->StopSpeaking(); | 250 GetPlatformImpl()->StopSpeaking(); |
| 251 } | 251 } |
| 252 | 252 |
| 253 if (current_utterance_) | 253 if (current_utterance_) |
| 254 current_utterance_->set_error(kSpeechInterruptedError); | 254 current_utterance_->set_error(kSpeechInterruptedError); |
| 255 FinishCurrentUtterance(); | 255 FinishCurrentUtterance(); |
| 256 ClearUtteranceQueue(); | 256 ClearUtteranceQueue(); |
| 257 } | 257 } |
| 258 | 258 |
| 259 void ExtensionTtsController::OnSpeechFinished( | 259 void ExtensionTtsController::OnSpeechFinished( |
| 260 int request_id, std::string error_message) { | 260 int request_id, const std::string& error_message) { |
| 261 // We may sometimes receive completion callbacks "late", after we've | 261 // We may sometimes receive completion callbacks "late", after we've |
| 262 // already finished the utterance (for example because another utterance | 262 // already finished the utterance (for example because another utterance |
| 263 // interrupted or we got a call to Stop). It's also possible that a buggy | 263 // interrupted or we got a call to Stop). It's also possible that a buggy |
| 264 // extension has called this more than once. In either case it's safe to | 264 // extension has called this more than once. In either case it's safe to |
| 265 // just ignore this call. | 265 // just ignore this call. |
| 266 if (!current_utterance_ || request_id != current_utterance_->id()) | 266 if (!current_utterance_ || request_id != current_utterance_->id()) |
| 267 return; | 267 return; |
| 268 | 268 |
| 269 current_utterance_->set_error(error_message); | 269 current_utterance_->set_error(error_message); |
| 270 FinishCurrentUtterance(); | 270 FinishCurrentUtterance(); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 int request_id; | 377 int request_id; |
| 378 std::string error_message; | 378 std::string error_message; |
| 379 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &request_id)); | 379 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &request_id)); |
| 380 if (args_->GetSize() >= 2) | 380 if (args_->GetSize() >= 2) |
| 381 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &error_message)); | 381 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &error_message)); |
| 382 ExtensionTtsController::GetInstance()->OnSpeechFinished( | 382 ExtensionTtsController::GetInstance()->OnSpeechFinished( |
| 383 request_id, error_message); | 383 request_id, error_message); |
| 384 | 384 |
| 385 return true; | 385 return true; |
| 386 } | 386 } |
| OLD | NEW |