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

Side by Side Diff: Source/modules/speech/SpeechRecognition.h

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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google 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 * * Redistributions of source code must retain the above copyright 7 * * 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 * * Redistributions in binary form must reproduce the above copyright 9 * * 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
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #ifndef SpeechRecognition_h 26 #ifndef SpeechRecognition_h
27 #define SpeechRecognition_h 27 #define SpeechRecognition_h
28 28
29 #include "core/dom/ActiveDOMObject.h" 29 #include "core/dom/ActiveDOMObject.h"
30 #include "core/page/PageLifecycleObserver.h"
30 #include "modules/EventTargetModules.h" 31 #include "modules/EventTargetModules.h"
31 #include "modules/speech/SpeechGrammarList.h" 32 #include "modules/speech/SpeechGrammarList.h"
32 #include "modules/speech/SpeechRecognitionResult.h" 33 #include "modules/speech/SpeechRecognitionResult.h"
33 #include "platform/heap/Handle.h" 34 #include "platform/heap/Handle.h"
35 #include "public/platform/WebPrivatePtr.h"
34 #include "wtf/Compiler.h" 36 #include "wtf/Compiler.h"
35 #include "wtf/text/WTFString.h" 37 #include "wtf/text/WTFString.h"
36 38
37 namespace blink { 39 namespace blink {
38 40
39 class ExceptionState; 41 class ExceptionState;
40 class ExecutionContext; 42 class ExecutionContext;
41 class MediaStreamTrack; 43 class MediaStreamTrack;
42 class SpeechRecognitionController; 44 class SpeechRecognitionController;
43 class SpeechRecognitionError; 45 class SpeechRecognitionError;
44 46
45 class SpeechRecognition final : public RefCountedGarbageCollectedEventTargetWith InlineData<SpeechRecognition>, public ActiveDOMObject { 47 class SpeechRecognition final : public RefCountedGarbageCollectedEventTargetWith InlineData<SpeechRecognition>, public PageLifecycleObserver, public ActiveDOMObj ect {
46 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<S peechRecognition>); 48 DEFINE_EVENT_TARGET_REFCOUNTING_WILL_BE_REMOVED(RefCountedGarbageCollected<S peechRecognition>);
47 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(SpeechRecognition); 49 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(SpeechRecognition);
48 DEFINE_WRAPPERTYPEINFO(); 50 DEFINE_WRAPPERTYPEINFO();
49 public: 51 public:
50 static SpeechRecognition* create(ExecutionContext*); 52 static SpeechRecognition* create(ExecutionContext*);
51 virtual ~SpeechRecognition(); 53 virtual ~SpeechRecognition();
52 54
53 // SpeechRecognition.idl implemementation. 55 // SpeechRecognition.idl implemementation.
54 // Attributes. 56 // Attributes.
55 SpeechGrammarList* grammars() { return m_grammars; } 57 SpeechGrammarList* grammars() { return m_grammars; }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 DEFINE_ATTRIBUTE_EVENT_LISTENER(soundend); 100 DEFINE_ATTRIBUTE_EVENT_LISTENER(soundend);
99 DEFINE_ATTRIBUTE_EVENT_LISTENER(audioend); 101 DEFINE_ATTRIBUTE_EVENT_LISTENER(audioend);
100 DEFINE_ATTRIBUTE_EVENT_LISTENER(result); 102 DEFINE_ATTRIBUTE_EVENT_LISTENER(result);
101 DEFINE_ATTRIBUTE_EVENT_LISTENER(nomatch); 103 DEFINE_ATTRIBUTE_EVENT_LISTENER(nomatch);
102 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); 104 DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
103 DEFINE_ATTRIBUTE_EVENT_LISTENER(start); 105 DEFINE_ATTRIBUTE_EVENT_LISTENER(start);
104 DEFINE_ATTRIBUTE_EVENT_LISTENER(end); 106 DEFINE_ATTRIBUTE_EVENT_LISTENER(end);
105 107
106 virtual void trace(Visitor*) override; 108 virtual void trace(Visitor*) override;
107 109
110 // PageLifecycleObserver
111 virtual void contextDestroyed() override;
112
108 private: 113 private:
109 explicit SpeechRecognition(ExecutionContext*); 114 SpeechRecognition(Page*, ExecutionContext*);
110 115
111 Member<SpeechGrammarList> m_grammars; 116 Member<SpeechGrammarList> m_grammars;
112 Member<MediaStreamTrack> m_audioTrack; 117 Member<MediaStreamTrack> m_audioTrack;
113 String m_lang; 118 String m_lang;
114 bool m_continuous; 119 bool m_continuous;
115 bool m_interimResults; 120 bool m_interimResults;
116 unsigned long m_maxAlternatives; 121 unsigned long m_maxAlternatives;
117 122
118 RawPtrWillBeMember<SpeechRecognitionController> m_controller; 123 RawPtrWillBeMember<SpeechRecognitionController> m_controller;
119 bool m_stoppedByActiveDOMObject; 124 bool m_stoppedByActiveDOMObject;
120 bool m_started; 125 bool m_started;
121 bool m_stopping; 126 bool m_stopping;
122 HeapVector<Member<SpeechRecognitionResult> > m_finalResults; 127 HeapVector<Member<SpeechRecognitionResult> > m_finalResults;
123 }; 128 };
124 129
130 // FIXME: Oilpan: two GarbageCollectedLifetime-based subclasses introduces
131 // ambiguity for WebPrivatePtr<T>'s LifeTimeOf<T> inference of lifetime.
132 template<>
133 class LifetimeOf<SpeechRecognition> {
134 public:
135 #if ENABLE(OILPAN)
136 static const LifetimeManagementType value = RefCountedGarbageCollectedLifeti me;
137 #else
138 static const LifetimeManagementType value = RefCountedLifetime;
139 #endif
140 };
141
125 } // namespace blink 142 } // namespace blink
126 143
127 #endif // SpeechRecognition_h 144 #endif // SpeechRecognition_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698