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

Side by Side Diff: chrome/renderer/tts_dispatcher.cc

Issue 14813033: Don't forget to call RemoveObserver when TtsDispatcher is destroyed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/tts_dispatcher.h" 5 #include "chrome/renderer/tts_dispatcher.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/common/tts_messages.h" 9 #include "chrome/common/tts_messages.h"
10 #include "chrome/common/tts_utterance_request.h" 10 #include "chrome/common/tts_utterance_request.h"
(...skipping 12 matching lines...) Expand all
23 using WebKit::WebVector; 23 using WebKit::WebVector;
24 24
25 int TtsDispatcher::next_utterance_id_ = 1; 25 int TtsDispatcher::next_utterance_id_ = 1;
26 26
27 TtsDispatcher::TtsDispatcher(WebSpeechSynthesizerClient* client) 27 TtsDispatcher::TtsDispatcher(WebSpeechSynthesizerClient* client)
28 : synthesizer_client_(client) { 28 : synthesizer_client_(client) {
29 RenderThread::Get()->AddObserver(this); 29 RenderThread::Get()->AddObserver(this);
30 } 30 }
31 31
32 TtsDispatcher::~TtsDispatcher() { 32 TtsDispatcher::~TtsDispatcher() {
33 RenderThread::Get()->RemoveObserver(this);
33 } 34 }
34 35
35 bool TtsDispatcher::OnControlMessageReceived(const IPC::Message& message) { 36 bool TtsDispatcher::OnControlMessageReceived(const IPC::Message& message) {
36 bool handled = true; 37 bool handled = true;
37 IPC_BEGIN_MESSAGE_MAP(TtsDispatcher, message) 38 IPC_BEGIN_MESSAGE_MAP(TtsDispatcher, message)
38 IPC_MESSAGE_HANDLER(TtsMsg_SetVoiceList, OnSetVoiceList) 39 IPC_MESSAGE_HANDLER(TtsMsg_SetVoiceList, OnSetVoiceList)
39 IPC_MESSAGE_HANDLER(TtsMsg_DidStartSpeaking, OnDidStartSpeaking) 40 IPC_MESSAGE_HANDLER(TtsMsg_DidStartSpeaking, OnDidStartSpeaking)
40 IPC_MESSAGE_HANDLER(TtsMsg_DidFinishSpeaking, OnDidFinishSpeaking) 41 IPC_MESSAGE_HANDLER(TtsMsg_DidFinishSpeaking, OnDidFinishSpeaking)
41 IPC_MESSAGE_HANDLER(TtsMsg_DidPauseSpeaking, OnDidPauseSpeaking) 42 IPC_MESSAGE_HANDLER(TtsMsg_DidPauseSpeaking, OnDidPauseSpeaking)
42 IPC_MESSAGE_HANDLER(TtsMsg_DidResumeSpeaking, OnDidResumeSpeaking) 43 IPC_MESSAGE_HANDLER(TtsMsg_DidResumeSpeaking, OnDidResumeSpeaking)
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 void TtsDispatcher::OnSpeakingErrorOccurred(int utterance_id, 190 void TtsDispatcher::OnSpeakingErrorOccurred(int utterance_id,
190 const std::string& error_message) { 191 const std::string& error_message) {
191 WebSpeechSynthesisUtterance utterance = FindUtterance(utterance_id); 192 WebSpeechSynthesisUtterance utterance = FindUtterance(utterance_id);
192 if (utterance.isNull()) 193 if (utterance.isNull())
193 return; 194 return;
194 195
195 // The web speech API doesn't support an error message. 196 // The web speech API doesn't support an error message.
196 synthesizer_client_->speakingErrorOccurred(utterance); 197 synthesizer_client_->speakingErrorOccurred(utterance);
197 utterance_id_map_.erase(utterance_id); 198 utterance_id_map_.erase(utterance_id);
198 } 199 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698