OLD | NEW |
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 |
(...skipping 15 matching lines...) Expand all Loading... |
26 #ifndef SpeechRecognition_h | 26 #ifndef SpeechRecognition_h |
27 #define SpeechRecognition_h | 27 #define SpeechRecognition_h |
28 | 28 |
29 #include "bindings/v8/ScriptWrappable.h" | 29 #include "bindings/v8/ScriptWrappable.h" |
30 #include "core/dom/ActiveDOMObject.h" | 30 #include "core/dom/ActiveDOMObject.h" |
31 #include "modules/EventTargetModules.h" | 31 #include "modules/EventTargetModules.h" |
32 #include "modules/speech/SpeechGrammarList.h" | 32 #include "modules/speech/SpeechGrammarList.h" |
33 #include "modules/speech/SpeechRecognitionResult.h" | 33 #include "modules/speech/SpeechRecognitionResult.h" |
34 #include "platform/heap/Handle.h" | 34 #include "platform/heap/Handle.h" |
35 #include "wtf/Compiler.h" | 35 #include "wtf/Compiler.h" |
36 #include "wtf/PassRefPtr.h" | |
37 #include "wtf/RefCounted.h" | |
38 #include "wtf/text/WTFString.h" | 36 #include "wtf/text/WTFString.h" |
39 | 37 |
40 namespace WebCore { | 38 namespace WebCore { |
41 | 39 |
42 class ExceptionState; | 40 class ExceptionState; |
43 class ExecutionContext; | 41 class ExecutionContext; |
44 class SpeechRecognitionController; | 42 class SpeechRecognitionController; |
45 class SpeechRecognitionError; | 43 class SpeechRecognitionError; |
46 | 44 |
47 class SpeechRecognition FINAL : public RefCountedWillBeRefCountedGarbageCollecte
d<SpeechRecognition>, public ScriptWrappable, public ActiveDOMObject, public Eve
ntTargetWithInlineData { | 45 class SpeechRecognition FINAL : public RefCountedGarbageCollected<SpeechRecognit
ion>, public ScriptWrappable, public ActiveDOMObject, public EventTargetWithInli
neData { |
48 REFCOUNTED_EVENT_TARGET(SpeechRecognition); | 46 DEFINE_EVENT_TARGET_REFCOUNTING(RefCountedGarbageCollected<SpeechRecognition
>); |
49 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(SpeechRecognition); | 47 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(SpeechRecognition); |
50 public: | 48 public: |
51 static PassRefPtrWillBeRawPtr<SpeechRecognition> create(ExecutionContext*); | 49 static SpeechRecognition* create(ExecutionContext*); |
52 virtual ~SpeechRecognition(); | 50 virtual ~SpeechRecognition(); |
53 | 51 |
54 // Attributes. | 52 // Attributes. |
55 SpeechGrammarList* grammars() { return m_grammars.get(); } | 53 SpeechGrammarList* grammars() { return m_grammars.get(); } |
56 void setGrammars(PassRefPtrWillBeRawPtr<SpeechGrammarList> grammars) { m_gra
mmars = grammars; } | 54 void setGrammars(SpeechGrammarList* grammars) { m_grammars = grammars; } |
57 String lang() { return m_lang; } | 55 String lang() { return m_lang; } |
58 void setLang(const String& lang) { m_lang = lang; } | 56 void setLang(const String& lang) { m_lang = lang; } |
59 bool continuous() { return m_continuous; } | 57 bool continuous() { return m_continuous; } |
60 void setContinuous(bool continuous) { m_continuous = continuous; } | 58 void setContinuous(bool continuous) { m_continuous = continuous; } |
61 bool interimResults() { return m_interimResults; } | 59 bool interimResults() { return m_interimResults; } |
62 void setInterimResults(bool interimResults) { m_interimResults = interimResu
lts; } | 60 void setInterimResults(bool interimResults) { m_interimResults = interimResu
lts; } |
63 unsigned long maxAlternatives() { return m_maxAlternatives; } | 61 unsigned long maxAlternatives() { return m_maxAlternatives; } |
64 void setMaxAlternatives(unsigned long maxAlternatives) { m_maxAlternatives =
maxAlternatives; } | 62 void setMaxAlternatives(unsigned long maxAlternatives) { m_maxAlternatives =
maxAlternatives; } |
65 | 63 |
66 // Callable by the user. | 64 // Callable by the user. |
67 void start(ExceptionState&); | 65 void start(ExceptionState&); |
68 void stopFunction(); | 66 void stopFunction(); |
69 void abort(); | 67 void abort(); |
70 | 68 |
71 // Called by the SpeechRecognitionClient. | 69 // Called by the SpeechRecognitionClient. |
72 void didStartAudio(); | 70 void didStartAudio(); |
73 void didStartSound(); | 71 void didStartSound(); |
74 void didStartSpeech(); | 72 void didStartSpeech(); |
75 void didEndSpeech(); | 73 void didEndSpeech(); |
76 void didEndSound(); | 74 void didEndSound(); |
77 void didEndAudio(); | 75 void didEndAudio(); |
78 void didReceiveResults(const WillBeHeapVector<RefPtrWillBeMember<SpeechRecog
nitionResult> >& newFinalResults, const WillBeHeapVector<RefPtrWillBeMember<Spee
chRecognitionResult> >& currentInterimResults); | 76 void didReceiveResults(const HeapVector<Member<SpeechRecognitionResult> >& n
ewFinalResults, const HeapVector<Member<SpeechRecognitionResult> >& currentInter
imResults); |
79 void didReceiveNoMatch(PassRefPtrWillBeRawPtr<SpeechRecognitionResult>); | 77 void didReceiveNoMatch(SpeechRecognitionResult*); |
80 void didReceiveError(PassRefPtrWillBeRawPtr<SpeechRecognitionError>); | 78 void didReceiveError(PassRefPtrWillBeRawPtr<SpeechRecognitionError>); |
81 void didStart(); | 79 void didStart(); |
82 void didEnd(); | 80 void didEnd(); |
83 | 81 |
84 // EventTarget. | 82 // EventTarget. |
85 virtual const AtomicString& interfaceName() const OVERRIDE; | 83 virtual const AtomicString& interfaceName() const OVERRIDE; |
86 virtual ExecutionContext* executionContext() const OVERRIDE; | 84 virtual ExecutionContext* executionContext() const OVERRIDE; |
87 | 85 |
88 // ActiveDOMObject. | 86 // ActiveDOMObject. |
89 virtual bool hasPendingActivity() const OVERRIDE; | 87 virtual bool hasPendingActivity() const OVERRIDE; |
90 virtual void stop() OVERRIDE; | 88 virtual void stop() OVERRIDE; |
91 | 89 |
92 DEFINE_ATTRIBUTE_EVENT_LISTENER(audiostart); | 90 DEFINE_ATTRIBUTE_EVENT_LISTENER(audiostart); |
93 DEFINE_ATTRIBUTE_EVENT_LISTENER(soundstart); | 91 DEFINE_ATTRIBUTE_EVENT_LISTENER(soundstart); |
94 DEFINE_ATTRIBUTE_EVENT_LISTENER(speechstart); | 92 DEFINE_ATTRIBUTE_EVENT_LISTENER(speechstart); |
95 DEFINE_ATTRIBUTE_EVENT_LISTENER(speechend); | 93 DEFINE_ATTRIBUTE_EVENT_LISTENER(speechend); |
96 DEFINE_ATTRIBUTE_EVENT_LISTENER(soundend); | 94 DEFINE_ATTRIBUTE_EVENT_LISTENER(soundend); |
97 DEFINE_ATTRIBUTE_EVENT_LISTENER(audioend); | 95 DEFINE_ATTRIBUTE_EVENT_LISTENER(audioend); |
98 DEFINE_ATTRIBUTE_EVENT_LISTENER(result); | 96 DEFINE_ATTRIBUTE_EVENT_LISTENER(result); |
99 DEFINE_ATTRIBUTE_EVENT_LISTENER(nomatch); | 97 DEFINE_ATTRIBUTE_EVENT_LISTENER(nomatch); |
100 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); | 98 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); |
101 DEFINE_ATTRIBUTE_EVENT_LISTENER(start); | 99 DEFINE_ATTRIBUTE_EVENT_LISTENER(start); |
102 DEFINE_ATTRIBUTE_EVENT_LISTENER(end); | 100 DEFINE_ATTRIBUTE_EVENT_LISTENER(end); |
103 | 101 |
104 virtual void trace(Visitor*) OVERRIDE; | 102 virtual void trace(Visitor*) OVERRIDE; |
105 | 103 |
106 private: | 104 private: |
107 friend class RefCounted<SpeechRecognition>; | |
108 | |
109 explicit SpeechRecognition(ExecutionContext*); | 105 explicit SpeechRecognition(ExecutionContext*); |
110 | 106 |
111 RefPtrWillBeMember<SpeechGrammarList> m_grammars; | 107 Member<SpeechGrammarList> m_grammars; |
112 String m_lang; | 108 String m_lang; |
113 bool m_continuous; | 109 bool m_continuous; |
114 bool m_interimResults; | 110 bool m_interimResults; |
115 unsigned long m_maxAlternatives; | 111 unsigned long m_maxAlternatives; |
116 | 112 |
117 SpeechRecognitionController* m_controller; | 113 SpeechRecognitionController* m_controller; |
118 bool m_stoppedByActiveDOMObject; | 114 bool m_stoppedByActiveDOMObject; |
119 bool m_started; | 115 bool m_started; |
120 bool m_stopping; | 116 bool m_stopping; |
121 WillBeHeapVector<RefPtrWillBeMember<SpeechRecognitionResult> > m_finalResult
s; | 117 HeapVector<Member<SpeechRecognitionResult> > m_finalResults; |
122 }; | 118 }; |
123 | 119 |
124 } // namespace WebCore | 120 } // namespace WebCore |
125 | 121 |
126 #endif // SpeechRecognition_h | 122 #endif // SpeechRecognition_h |
OLD | NEW |