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

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

Issue 960223002: Detach SpeechRecognitionController upon page detach. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Adjust assert and allow repeated observer detaches Created 5 years, 10 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
Index: Source/modules/speech/SpeechRecognitionController.cpp
diff --git a/Source/modules/speech/SpeechRecognitionController.cpp b/Source/modules/speech/SpeechRecognitionController.cpp
index da0b9df469adc681ead27e1d29eeac50a137b43e..e8295803dcc9f58ba1a603d267155be3a854fe6e 100644
--- a/Source/modules/speech/SpeechRecognitionController.cpp
+++ b/Source/modules/speech/SpeechRecognitionController.cpp
@@ -33,8 +33,9 @@ const char* SpeechRecognitionController::supplementName()
return "SpeechRecognitionController";
}
-SpeechRecognitionController::SpeechRecognitionController(PassOwnPtr<SpeechRecognitionClient> client)
- : m_client(client)
+SpeechRecognitionController::SpeechRecognitionController(Page* page, PassOwnPtr<SpeechRecognitionClient> client)
+ : PageLifecycleObserver(page)
+ , m_client(client)
{
}
@@ -43,14 +44,49 @@ SpeechRecognitionController::~SpeechRecognitionController()
// FIXME: Call m_client->pageDestroyed(); once we have implemented a client.
}
-PassOwnPtrWillBeRawPtr<SpeechRecognitionController> SpeechRecognitionController::create(PassOwnPtr<SpeechRecognitionClient> client)
+DEFINE_TRACE(SpeechRecognitionController)
{
- return adoptPtrWillBeNoop(new SpeechRecognitionController(client));
+ WillBeHeapSupplement<Page>::trace(visitor);
+ PageLifecycleObserver::trace(visitor);
+}
+
+PassOwnPtrWillBeRawPtr<SpeechRecognitionController> SpeechRecognitionController::create(Page* page, PassOwnPtr<SpeechRecognitionClient> client)
+{
+return adoptPtrWillBeNoop(new SpeechRecognitionController(page, client));
+}
+
+SpeechRecognitionController* SpeechRecognitionController::from(Page* page)
+{
+ return static_cast<SpeechRecognitionController*>(WillBeHeapSupplement<Page>::from(page, supplementName()));
}
void provideSpeechRecognitionTo(Page& page, PassOwnPtr<SpeechRecognitionClient> client)
{
- SpeechRecognitionController::provideTo(page, SpeechRecognitionController::supplementName(), SpeechRecognitionController::create(client));
+ SpeechRecognitionController::provideTo(page, SpeechRecognitionController::supplementName(), SpeechRecognitionController::create(&page, client));
+}
+
+void SpeechRecognitionController::start(SpeechRecognition* recognition, const SpeechGrammarList* grammars, const String& lang, bool continuous, bool interimResults, unsigned long maxAlternatives, MediaStreamTrack* audioTrack)
+{
+ if (!page())
+ return;
+
+ m_client->start(recognition, grammars, lang, continuous, interimResults, maxAlternatives, audioTrack);
+}
+
+void SpeechRecognitionController::stop(SpeechRecognition* recognition)
+{
+ if (!page())
+ return;
+
+ m_client->stop(recognition);
+}
+
+void SpeechRecognitionController::abort(SpeechRecognition* recognition)
+{
+ if (!page())
+ return;
+
+ m_client->abort(recognition);
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698