OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2013 Apple Computer, 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 30 matching lines...) Expand all Loading... | |
41 PlatformSpeechSynthesizer* synthesizer = new PlatformSpeechSynthesizer(clien t); | 41 PlatformSpeechSynthesizer* synthesizer = new PlatformSpeechSynthesizer(clien t); |
42 synthesizer->initializeVoiceList(); | 42 synthesizer->initializeVoiceList(); |
43 return synthesizer; | 43 return synthesizer; |
44 } | 44 } |
45 | 45 |
46 PlatformSpeechSynthesizer::PlatformSpeechSynthesizer(PlatformSpeechSynthesizerCl ient* client) | 46 PlatformSpeechSynthesizer::PlatformSpeechSynthesizer(PlatformSpeechSynthesizerCl ient* client) |
47 : m_speechSynthesizerClient(client) | 47 : m_speechSynthesizerClient(client) |
48 { | 48 { |
49 m_webSpeechSynthesizerClient = new WebSpeechSynthesizerClientImpl(this, clie nt); | 49 m_webSpeechSynthesizerClient = new WebSpeechSynthesizerClientImpl(this, clie nt); |
50 m_webSpeechSynthesizer = adoptPtr(Platform::current()->createSpeechSynthesiz er(m_webSpeechSynthesizerClient)); | 50 m_webSpeechSynthesizer = adoptPtr(Platform::current()->createSpeechSynthesiz er(m_webSpeechSynthesizerClient)); |
51 ThreadState::current()->registerPreFinalizer(*this); | |
52 } | 51 } |
53 | 52 |
54 PlatformSpeechSynthesizer::~PlatformSpeechSynthesizer() | 53 PlatformSpeechSynthesizer::~PlatformSpeechSynthesizer() |
55 { | 54 { |
56 } | 55 } |
57 | 56 |
58 // Since the m_webSpeechSynthesizer (i.e., TtsDispatcher in the chrome side) | |
59 // holds a raw pointer back to the m_webSpeechSynthesizerClient, we need to | |
60 // make sure that the raw pointer is cleared before the sweeping starts. | |
61 // Otherwise, m_webSpeechSynthesizerClient might end up being lazily swept | |
62 // before this PlatformSpeechSynthesizer object is, leaving | |
63 // m_sweepSpeechSynthesizer with a dangling pointer to a freed object. | |
haraken
2015/06/04 01:02:31
I'd keep this comment on EAGERLY_FINALIZE(). Havin
| |
64 void PlatformSpeechSynthesizer::dispose() | |
65 { | |
66 m_webSpeechSynthesizer.clear(); | |
67 } | |
68 | |
69 void PlatformSpeechSynthesizer::speak(PlatformSpeechSynthesisUtterance* utteranc e) | 57 void PlatformSpeechSynthesizer::speak(PlatformSpeechSynthesisUtterance* utteranc e) |
70 { | 58 { |
71 if (m_webSpeechSynthesizer && m_webSpeechSynthesizerClient) | 59 if (m_webSpeechSynthesizer && m_webSpeechSynthesizerClient) |
72 m_webSpeechSynthesizer->speak(WebSpeechSynthesisUtterance(utterance)); | 60 m_webSpeechSynthesizer->speak(WebSpeechSynthesisUtterance(utterance)); |
73 } | 61 } |
74 | 62 |
75 void PlatformSpeechSynthesizer::pause() | 63 void PlatformSpeechSynthesizer::pause() |
76 { | 64 { |
77 if (m_webSpeechSynthesizer.get()) | 65 if (m_webSpeechSynthesizer.get()) |
78 m_webSpeechSynthesizer->pause(); | 66 m_webSpeechSynthesizer->pause(); |
(...skipping 23 matching lines...) Expand all Loading... | |
102 } | 90 } |
103 | 91 |
104 DEFINE_TRACE(PlatformSpeechSynthesizer) | 92 DEFINE_TRACE(PlatformSpeechSynthesizer) |
105 { | 93 { |
106 visitor->trace(m_speechSynthesizerClient); | 94 visitor->trace(m_speechSynthesizerClient); |
107 visitor->trace(m_voiceList); | 95 visitor->trace(m_voiceList); |
108 visitor->trace(m_webSpeechSynthesizerClient); | 96 visitor->trace(m_webSpeechSynthesizerClient); |
109 } | 97 } |
110 | 98 |
111 } // namespace blink | 99 } // namespace blink |
OLD | NEW |