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

Side by Side Diff: Source/platform/speech/PlatformSpeechSynthesizer.h

Issue 1148383012: Oilpan: prefer eager finalization over prefinalizers. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: expand&improve comments Created 5 years, 6 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
OLDNEW
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 virtual void speakingErrorOccurred(PlatformSpeechSynthesisUtterance*) = 0; 51 virtual void speakingErrorOccurred(PlatformSpeechSynthesisUtterance*) = 0;
52 virtual void boundaryEventOccurred(PlatformSpeechSynthesisUtterance*, Speech Boundary, unsigned charIndex) = 0; 52 virtual void boundaryEventOccurred(PlatformSpeechSynthesisUtterance*, Speech Boundary, unsigned charIndex) = 0;
53 virtual void voicesDidChange() = 0; 53 virtual void voicesDidChange() = 0;
54 54
55 protected: 55 protected:
56 virtual ~PlatformSpeechSynthesizerClient() { } 56 virtual ~PlatformSpeechSynthesizerClient() { }
57 }; 57 };
58 58
59 class PLATFORM_EXPORT PlatformSpeechSynthesizer : public GarbageCollectedFinaliz ed<PlatformSpeechSynthesizer> { 59 class PLATFORM_EXPORT PlatformSpeechSynthesizer : public GarbageCollectedFinaliz ed<PlatformSpeechSynthesizer> {
60 WTF_MAKE_NONCOPYABLE(PlatformSpeechSynthesizer); 60 WTF_MAKE_NONCOPYABLE(PlatformSpeechSynthesizer);
61 USING_PRE_FINALIZER(PlatformSpeechSynthesizer, dispose);
62 public: 61 public:
63 static PlatformSpeechSynthesizer* create(PlatformSpeechSynthesizerClient*); 62 static PlatformSpeechSynthesizer* create(PlatformSpeechSynthesizerClient*);
64 63
65 virtual ~PlatformSpeechSynthesizer(); 64 virtual ~PlatformSpeechSynthesizer();
66 void dispose();
67 65
68 const HeapVector<Member<PlatformSpeechSynthesisVoice>>& voiceList() const { return m_voiceList; } 66 const HeapVector<Member<PlatformSpeechSynthesisVoice>>& voiceList() const { return m_voiceList; }
69 virtual void speak(PlatformSpeechSynthesisUtterance*); 67 virtual void speak(PlatformSpeechSynthesisUtterance*);
70 virtual void pause(); 68 virtual void pause();
71 virtual void resume(); 69 virtual void resume();
72 virtual void cancel(); 70 virtual void cancel();
73 71
74 PlatformSpeechSynthesizerClient* client() const { return m_speechSynthesizer Client; } 72 PlatformSpeechSynthesizerClient* client() const { return m_speechSynthesizer Client; }
75 73
76 void setVoiceList(HeapVector<Member<PlatformSpeechSynthesisVoice>>&); 74 void setVoiceList(HeapVector<Member<PlatformSpeechSynthesisVoice>>&);
77 75
76 // Eager finalization is required to promptly release the owned WebSpeechSyn thesizer.
77 //
78 // If not and delayed until lazily swept, m_webSpeechSynthesizerClient may e nd up
79 // being lazily swept first (i.e., before this PlatformSpeechSynthesizer), l eaving
80 // m_webSpeechSynthesizer with a dangling pointer to a finalized object --
81 // WebSpeechSynthesizer embedder implementations calling notification method s in the
82 // other directions by way of m_webSpeechSynthesizerClient. Eagerly releasin g
83 // WebSpeechSynthesizer prevents such unsafe accesses.
84 EAGERLY_FINALIZE();
78 DECLARE_VIRTUAL_TRACE(); 85 DECLARE_VIRTUAL_TRACE();
79 86
80 protected: 87 protected:
81 explicit PlatformSpeechSynthesizer(PlatformSpeechSynthesizerClient*); 88 explicit PlatformSpeechSynthesizer(PlatformSpeechSynthesizerClient*);
82 89
83 virtual void initializeVoiceList(); 90 virtual void initializeVoiceList();
84 91
85 HeapVector<Member<PlatformSpeechSynthesisVoice>> m_voiceList; 92 HeapVector<Member<PlatformSpeechSynthesisVoice>> m_voiceList;
86 93
87 private: 94 private:
88 Member<PlatformSpeechSynthesizerClient> m_speechSynthesizerClient; 95 Member<PlatformSpeechSynthesizerClient> m_speechSynthesizerClient;
89 96
90 OwnPtr<WebSpeechSynthesizer> m_webSpeechSynthesizer; 97 OwnPtr<WebSpeechSynthesizer> m_webSpeechSynthesizer;
91 Member<WebSpeechSynthesizerClientImpl> m_webSpeechSynthesizerClient; 98 Member<WebSpeechSynthesizerClientImpl> m_webSpeechSynthesizerClient;
92 }; 99 };
93 100
94 } // namespace blink 101 } // namespace blink
95 102
96 #endif // PlatformSpeechSynthesizer_h 103 #endif // PlatformSpeechSynthesizer_h
OLDNEW
« no previous file with comments | « Source/modules/webmidi/MIDIAccessInitializer.cpp ('k') | Source/platform/speech/PlatformSpeechSynthesizer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698