| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2013 Apple Computer, Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 speaking_error_occurred_timer_( | 44 speaking_error_occurred_timer_( |
| 45 this, | 45 this, |
| 46 &PlatformSpeechSynthesizerMock::SpeakingErrorOccurred), | 46 &PlatformSpeechSynthesizerMock::SpeakingErrorOccurred), |
| 47 speaking_finished_timer_( | 47 speaking_finished_timer_( |
| 48 this, | 48 this, |
| 49 &PlatformSpeechSynthesizerMock::SpeakingFinished) {} | 49 &PlatformSpeechSynthesizerMock::SpeakingFinished) {} |
| 50 | 50 |
| 51 PlatformSpeechSynthesizerMock::~PlatformSpeechSynthesizerMock() {} | 51 PlatformSpeechSynthesizerMock::~PlatformSpeechSynthesizerMock() {} |
| 52 | 52 |
| 53 void PlatformSpeechSynthesizerMock::SpeakingErrorOccurred(TimerBase*) { | 53 void PlatformSpeechSynthesizerMock::SpeakingErrorOccurred(TimerBase*) { |
| 54 ASSERT(current_utterance_); | 54 DCHECK(current_utterance_); |
| 55 | 55 |
| 56 Client()->SpeakingErrorOccurred(current_utterance_); | 56 Client()->SpeakingErrorOccurred(current_utterance_); |
| 57 SpeakNext(); | 57 SpeakNext(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void PlatformSpeechSynthesizerMock::SpeakingFinished(TimerBase*) { | 60 void PlatformSpeechSynthesizerMock::SpeakingFinished(TimerBase*) { |
| 61 ASSERT(current_utterance_); | 61 DCHECK(current_utterance_); |
| 62 Client()->DidFinishSpeaking(current_utterance_); | 62 Client()->DidFinishSpeaking(current_utterance_); |
| 63 SpeakNext(); | 63 SpeakNext(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 void PlatformSpeechSynthesizerMock::SpeakNext() { | 66 void PlatformSpeechSynthesizerMock::SpeakNext() { |
| 67 if (speaking_error_occurred_timer_.IsActive()) | 67 if (speaking_error_occurred_timer_.IsActive()) |
| 68 return; | 68 return; |
| 69 | 69 |
| 70 if (queued_utterances_.IsEmpty()) { | 70 if (queued_utterances_.IsEmpty()) { |
| 71 current_utterance_ = nullptr; | 71 current_utterance_ = nullptr; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 92 PlatformSpeechSynthesisUtterance* utterance) { | 92 PlatformSpeechSynthesisUtterance* utterance) { |
| 93 if (!current_utterance_) { | 93 if (!current_utterance_) { |
| 94 current_utterance_ = utterance; | 94 current_utterance_ = utterance; |
| 95 SpeakNow(); | 95 SpeakNow(); |
| 96 return; | 96 return; |
| 97 } | 97 } |
| 98 queued_utterances_.push_back(utterance); | 98 queued_utterances_.push_back(utterance); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void PlatformSpeechSynthesizerMock::SpeakNow() { | 101 void PlatformSpeechSynthesizerMock::SpeakNow() { |
| 102 ASSERT(current_utterance_); | 102 DCHECK(current_utterance_); |
| 103 Client()->DidStartSpeaking(current_utterance_); | 103 Client()->DidStartSpeaking(current_utterance_); |
| 104 | 104 |
| 105 // Fire a fake word and then sentence boundary event. | 105 // Fire a fake word and then sentence boundary event. |
| 106 Client()->BoundaryEventOccurred(current_utterance_, kSpeechWordBoundary, 0); | 106 Client()->BoundaryEventOccurred(current_utterance_, kSpeechWordBoundary, 0); |
| 107 Client()->BoundaryEventOccurred(current_utterance_, kSpeechSentenceBoundary, | 107 Client()->BoundaryEventOccurred(current_utterance_, kSpeechSentenceBoundary, |
| 108 current_utterance_->GetText().length()); | 108 current_utterance_->GetText().length()); |
| 109 | 109 |
| 110 // Give the fake speech job some time so that pause and other functions have | 110 // Give the fake speech job some time so that pause and other functions have |
| 111 // time to be called. | 111 // time to be called. |
| 112 speaking_finished_timer_.StartOneShot(.1, BLINK_FROM_HERE); | 112 speaking_finished_timer_.StartOneShot(.1, BLINK_FROM_HERE); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 137 Client()->DidResumeSpeaking(current_utterance_); | 137 Client()->DidResumeSpeaking(current_utterance_); |
| 138 } | 138 } |
| 139 | 139 |
| 140 DEFINE_TRACE(PlatformSpeechSynthesizerMock) { | 140 DEFINE_TRACE(PlatformSpeechSynthesizerMock) { |
| 141 visitor->Trace(current_utterance_); | 141 visitor->Trace(current_utterance_); |
| 142 visitor->Trace(queued_utterances_); | 142 visitor->Trace(queued_utterances_); |
| 143 PlatformSpeechSynthesizer::Trace(visitor); | 143 PlatformSpeechSynthesizer::Trace(visitor); |
| 144 } | 144 } |
| 145 | 145 |
| 146 } // namespace blink | 146 } // namespace blink |
| OLD | NEW |