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

Side by Side Diff: third_party/WebKit/Source/modules/speech/SpeechSynthesis.cpp

Issue 2862963003: Replace ASSERT with DCHECK in modules/ (Closed)
Patch Set: NOTREACHED instead of DCHECK(false) Created 3 years, 7 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 /* 1 /*
2 * Copyright (C) 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2013 Apple 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // That means there will be more than one in the queue. 79 // That means there will be more than one in the queue.
80 return utterance_queue_.size() > 1; 80 return utterance_queue_.size() > 1;
81 } 81 }
82 82
83 bool SpeechSynthesis::paused() const { 83 bool SpeechSynthesis::paused() const {
84 return is_paused_; 84 return is_paused_;
85 } 85 }
86 86
87 void SpeechSynthesis::StartSpeakingImmediately() { 87 void SpeechSynthesis::StartSpeakingImmediately() {
88 SpeechSynthesisUtterance* utterance = CurrentSpeechUtterance(); 88 SpeechSynthesisUtterance* utterance = CurrentSpeechUtterance();
89 ASSERT(utterance); 89 DCHECK(utterance);
90 90
91 utterance->SetStartTime(MonotonicallyIncreasingTime()); 91 utterance->SetStartTime(MonotonicallyIncreasingTime());
92 is_paused_ = false; 92 is_paused_ = false;
93 platform_speech_synthesizer_->Speak(utterance->PlatformUtterance()); 93 platform_speech_synthesizer_->Speak(utterance->PlatformUtterance());
94 } 94 }
95 95
96 void SpeechSynthesis::speak(SpeechSynthesisUtterance* utterance) { 96 void SpeechSynthesis::speak(SpeechSynthesisUtterance* utterance) {
97 ASSERT(utterance); 97 DCHECK(utterance);
98 98
99 utterance_queue_.push_back(utterance); 99 utterance_queue_.push_back(utterance);
100 100
101 // If the queue was empty, speak this immediately. 101 // If the queue was empty, speak this immediately.
102 if (utterance_queue_.size() == 1) 102 if (utterance_queue_.size() == 1)
103 StartSpeakingImmediately(); 103 StartSpeakingImmediately();
104 } 104 }
105 105
106 void SpeechSynthesis::cancel() { 106 void SpeechSynthesis::cancel() {
107 // Remove all the items from the utterance queue. The platform 107 // Remove all the items from the utterance queue. The platform
(...skipping 23 matching lines...) Expand all
131 131
132 double elapsed_time_millis = 132 double elapsed_time_millis =
133 (MonotonicallyIncreasingTime() - utterance->StartTime()) * 1000.0; 133 (MonotonicallyIncreasingTime() - utterance->StartTime()) * 1000.0;
134 utterance->DispatchEvent(SpeechSynthesisEvent::Create( 134 utterance->DispatchEvent(SpeechSynthesisEvent::Create(
135 type, utterance, char_index, elapsed_time_millis, name)); 135 type, utterance, char_index, elapsed_time_millis, name));
136 } 136 }
137 137
138 void SpeechSynthesis::HandleSpeakingCompleted( 138 void SpeechSynthesis::HandleSpeakingCompleted(
139 SpeechSynthesisUtterance* utterance, 139 SpeechSynthesisUtterance* utterance,
140 bool error_occurred) { 140 bool error_occurred) {
141 ASSERT(utterance); 141 DCHECK(utterance);
142 142
143 bool should_start_speaking = false; 143 bool should_start_speaking = false;
144 // If the utterance that completed was the one we're currently speaking, 144 // If the utterance that completed was the one we're currently speaking,
145 // remove it from the queue and start speaking the next one. 145 // remove it from the queue and start speaking the next one.
146 if (utterance == CurrentSpeechUtterance()) { 146 if (utterance == CurrentSpeechUtterance()) {
147 utterance_queue_.pop_front(); 147 utterance_queue_.pop_front();
148 should_start_speaking = !!utterance_queue_.size(); 148 should_start_speaking = !!utterance_queue_.size();
149 } 149 }
150 150
151 // Always fire the event, because the platform may have asynchronously 151 // Always fire the event, because the platform may have asynchronously
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 DEFINE_TRACE(SpeechSynthesis) { 237 DEFINE_TRACE(SpeechSynthesis) {
238 visitor->Trace(platform_speech_synthesizer_); 238 visitor->Trace(platform_speech_synthesizer_);
239 visitor->Trace(voice_list_); 239 visitor->Trace(voice_list_);
240 visitor->Trace(utterance_queue_); 240 visitor->Trace(utterance_queue_);
241 PlatformSpeechSynthesizerClient::Trace(visitor); 241 PlatformSpeechSynthesizerClient::Trace(visitor);
242 ContextClient::Trace(visitor); 242 ContextClient::Trace(visitor);
243 EventTargetWithInlineData::Trace(visitor); 243 EventTargetWithInlineData::Trace(visitor);
244 } 244 }
245 245
246 } // namespace blink 246 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698