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

Side by Side Diff: Source/modules/speech/SpeechRecognition.cpp

Issue 208273002: Remove usage of {,un}setPendingActivity from SpeechRecognition (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « Source/modules/speech/SpeechRecognition.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google 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 * * Redistributions of source code must retain the above copyright 7 * * 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 * * Redistributions in binary form must reproduce the above copyright 9 * * 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 } 45 }
46 46
47 void SpeechRecognition::start(ExceptionState& exceptionState) 47 void SpeechRecognition::start(ExceptionState& exceptionState)
48 { 48 {
49 ASSERT(m_controller); 49 ASSERT(m_controller);
50 if (m_started) { 50 if (m_started) {
51 exceptionState.throwDOMException(InvalidStateError, "recognition has alr eady started."); 51 exceptionState.throwDOMException(InvalidStateError, "recognition has alr eady started.");
52 return; 52 return;
53 } 53 }
54 54
55 setPendingActivity(this);
56 m_finalResults.clear(); 55 m_finalResults.clear();
57 m_controller->start(this, m_grammars.get(), m_lang, m_continuous, m_interimR esults, m_maxAlternatives); 56 m_controller->start(this, m_grammars.get(), m_lang, m_continuous, m_interimR esults, m_maxAlternatives);
58 m_started = true; 57 m_started = true;
59 } 58 }
60 59
61 void SpeechRecognition::stopFunction() 60 void SpeechRecognition::stopFunction()
62 { 61 {
63 ASSERT(m_controller); 62 ASSERT(m_controller);
64 if (m_started && !m_stopping) { 63 if (m_started && !m_stopping) {
65 m_stopping = true; 64 m_stopping = true;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 120 }
122 121
123 void SpeechRecognition::didReceiveNoMatch(PassRefPtrWillBeRawPtr<SpeechRecogniti onResult> result) 122 void SpeechRecognition::didReceiveNoMatch(PassRefPtrWillBeRawPtr<SpeechRecogniti onResult> result)
124 { 123 {
125 dispatchEvent(SpeechRecognitionEvent::createNoMatch(result)); 124 dispatchEvent(SpeechRecognitionEvent::createNoMatch(result));
126 } 125 }
127 126
128 void SpeechRecognition::didReceiveError(PassRefPtr<SpeechRecognitionError> error ) 127 void SpeechRecognition::didReceiveError(PassRefPtr<SpeechRecognitionError> error )
129 { 128 {
130 dispatchEvent(error); 129 dispatchEvent(error);
131 m_started = false; 130 m_started = false;
haraken 2014/03/21 14:34:15 Before this CL, we didn't unset pending activity w
132 } 131 }
133 132
134 void SpeechRecognition::didStart() 133 void SpeechRecognition::didStart()
135 { 134 {
136 dispatchEvent(Event::create(EventTypeNames::start)); 135 dispatchEvent(Event::create(EventTypeNames::start));
137 } 136 }
138 137
139 void SpeechRecognition::didEnd() 138 void SpeechRecognition::didEnd()
140 { 139 {
141 m_started = false; 140 m_started = false;
142 m_stopping = false; 141 m_stopping = false;
143 if (!m_stoppedByActiveDOMObject) 142 if (!m_stoppedByActiveDOMObject)
144 dispatchEvent(Event::create(EventTypeNames::end)); 143 dispatchEvent(Event::create(EventTypeNames::end));
145 unsetPendingActivity(this);
146 } 144 }
147 145
148 const AtomicString& SpeechRecognition::interfaceName() const 146 const AtomicString& SpeechRecognition::interfaceName() const
149 { 147 {
150 return EventTargetNames::SpeechRecognition; 148 return EventTargetNames::SpeechRecognition;
151 } 149 }
152 150
153 ExecutionContext* SpeechRecognition::executionContext() const 151 ExecutionContext* SpeechRecognition::executionContext() const
154 { 152 {
155 return ActiveDOMObject::executionContext(); 153 return ActiveDOMObject::executionContext();
156 } 154 }
157 155
158 void SpeechRecognition::stop() 156 void SpeechRecognition::stop()
159 { 157 {
160 m_stoppedByActiveDOMObject = true; 158 m_stoppedByActiveDOMObject = true;
161 if (hasPendingActivity()) 159 if (hasPendingActivity())
162 abort(); 160 abort();
163 } 161 }
164 162
163 bool SpeechRecognition::hasPendingActivity() const
164 {
165 return m_started;
166 }
167
165 SpeechRecognition::SpeechRecognition(ExecutionContext* context) 168 SpeechRecognition::SpeechRecognition(ExecutionContext* context)
166 : ActiveDOMObject(context) 169 : ActiveDOMObject(context)
167 , m_grammars(SpeechGrammarList::create()) // FIXME: The spec is not clear on the default value for the grammars attribute. 170 , m_grammars(SpeechGrammarList::create()) // FIXME: The spec is not clear on the default value for the grammars attribute.
168 , m_continuous(false) 171 , m_continuous(false)
169 , m_interimResults(false) 172 , m_interimResults(false)
170 , m_maxAlternatives(1) 173 , m_maxAlternatives(1)
171 , m_controller(0) 174 , m_controller(0)
172 , m_stoppedByActiveDOMObject(false) 175 , m_stoppedByActiveDOMObject(false)
173 , m_started(false) 176 , m_started(false)
174 , m_stopping(false) 177 , m_stopping(false)
(...skipping 14 matching lines...) Expand all
189 { 192 {
190 } 193 }
191 194
192 void SpeechRecognition::trace(Visitor* visitor) 195 void SpeechRecognition::trace(Visitor* visitor)
193 { 196 {
194 visitor->trace(m_grammars); 197 visitor->trace(m_grammars);
195 visitor->trace(m_finalResults); 198 visitor->trace(m_finalResults);
196 } 199 }
197 200
198 } // namespace WebCore 201 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/speech/SpeechRecognition.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698