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

Unified Diff: Source/modules/speech/SpeechRecognition.cpp

Issue 1002453004: Merge 190993 "Detach SpeechRecognitionController upon page detach." (Closed) Base URL: svn://svn.chromium.org/blink/branches/chromium/2272/
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/speech/SpeechRecognition.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/speech/SpeechRecognition.cpp
===================================================================
--- Source/modules/speech/SpeechRecognition.cpp (revision 191726)
+++ Source/modules/speech/SpeechRecognition.cpp (working copy)
@@ -40,7 +40,10 @@
SpeechRecognition* SpeechRecognition::create(ExecutionContext* context)
{
- SpeechRecognition* speechRecognition = new SpeechRecognition(context);
+ ASSERT(context && context->isDocument());
+ Document* document = toDocument(context);
+ ASSERT(document);
+ SpeechRecognition* speechRecognition = new SpeechRecognition(document->page(), context);
speechRecognition->suspendIfNeeded();
return speechRecognition;
}
@@ -47,7 +50,9 @@
void SpeechRecognition::start(ExceptionState& exceptionState)
{
- ASSERT(m_controller);
+ if (!m_controller)
+ return;
+
if (m_started) {
exceptionState.throwDOMException(InvalidStateError, "recognition has already started.");
return;
@@ -60,7 +65,9 @@
void SpeechRecognition::stopFunction()
{
- ASSERT(m_controller);
+ if (!m_controller)
+ return;
+
if (m_started && !m_stopping) {
m_stopping = true;
m_controller->stop(this);
@@ -69,7 +76,9 @@
void SpeechRecognition::abort()
{
- ASSERT(m_controller);
+ if (!m_controller)
+ return;
+
if (m_started && !m_stopping) {
m_stopping = true;
m_controller->abort(this);
@@ -166,26 +175,19 @@
return m_started;
}
-SpeechRecognition::SpeechRecognition(ExecutionContext* context)
- : ActiveDOMObject(context)
+SpeechRecognition::SpeechRecognition(Page* page, ExecutionContext* context)
+ : PageLifecycleObserver(page)
+ , ActiveDOMObject(context)
, m_grammars(SpeechGrammarList::create()) // FIXME: The spec is not clear on the default value for the grammars attribute.
, m_audioTrack(nullptr)
, m_continuous(false)
, m_interimResults(false)
, m_maxAlternatives(1)
- , m_controller(nullptr)
+ , m_controller(SpeechRecognitionController::from(page))
, m_stoppedByActiveDOMObject(false)
, m_started(false)
, m_stopping(false)
{
- Document* document = toDocument(executionContext());
-
- Page* page = document->page();
- ASSERT(page);
-
- m_controller = SpeechRecognitionController::from(page);
- ASSERT(m_controller);
-
// FIXME: Need to hook up with Page to get notified when the visibility changes.
}
@@ -193,6 +195,12 @@
{
}
+void SpeechRecognition::contextDestroyed()
+{
+ m_controller = nullptr;
+ PageLifecycleObserver::contextDestroyed();
+}
+
void SpeechRecognition::trace(Visitor* visitor)
{
visitor->trace(m_grammars);
@@ -202,6 +210,7 @@
#endif
visitor->trace(m_finalResults);
RefCountedGarbageCollectedEventTargetWithInlineData<SpeechRecognition>::trace(visitor);
+ PageLifecycleObserver::trace(visitor);
ActiveDOMObject::trace(visitor);
}
« 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