Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 #include "core/page/Page.h" | 36 #include "core/page/Page.h" |
| 37 #include "core/speech/SpeechInputListener.h" | 37 #include "core/speech/SpeechInputListener.h" |
| 38 #include "wtf/Forward.h" | 38 #include "wtf/Forward.h" |
| 39 #include "wtf/HashMap.h" | 39 #include "wtf/HashMap.h" |
| 40 | 40 |
| 41 namespace WebCore { | 41 namespace WebCore { |
| 42 | 42 |
| 43 class IntRect; | 43 class IntRect; |
| 44 class SecurityOrigin; | 44 class SecurityOrigin; |
| 45 class SpeechInputClient; | 45 class SpeechInputClient; |
| 46 class SpeechInputListener; | |
| 47 class InputFieldSpeechButtonElement; | |
| 48 | 46 |
| 49 // This class connects the input elements requiring speech input with the platfo rm specific | 47 // This class connects the input elements requiring speech input with the platfo rm specific |
| 50 // speech recognition engine. It provides methods for the input elements to acti vate speech | 48 // speech recognition engine. It provides methods for the input elements to acti vate speech |
| 51 // recognition and methods for the speech recognition engine to return back the results. | 49 // recognition and methods for the speech recognition engine to return back the results. |
| 52 class SpeechInput FINAL : public SpeechInputListener, public Supplement<Page> { | 50 class SpeechInput FINAL : public NoBaseWillBeGarbageCollectedFinalized<SpeechInp ut>, public SpeechInputListener, public WillBeHeapSupplement<Page> { |
| 51 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(SpeechInput); | |
| 53 WTF_MAKE_NONCOPYABLE(SpeechInput); | 52 WTF_MAKE_NONCOPYABLE(SpeechInput); |
| 54 public: | 53 public: |
| 55 virtual ~SpeechInput(); | 54 virtual ~SpeechInput(); |
| 56 | 55 |
| 57 static PassOwnPtr<SpeechInput> create(PassOwnPtr<SpeechInputClient>); | 56 static PassOwnPtrWillBeRawPtr<SpeechInput> create(PassOwnPtr<SpeechInputClie nt>); |
| 58 static const char* supplementName(); | 57 static const char* supplementName(); |
| 59 static SpeechInput* from(Page* page) { return static_cast<SpeechInput*>(Supp lement<Page>::from(page, supplementName())); } | 58 static SpeechInput* from(Page* page) { return static_cast<SpeechInput*>(Will BeHeapSupplement<Page>::from(page, supplementName())); } |
| 60 | 59 |
| 61 // Generates a unique ID for the given listener to be used for speech reques ts. | 60 // Generates a unique ID for the given listener to be used for speech reques ts. |
| 62 // This should be the first call made by listeners before anything else. | 61 // This should be the first call made by listeners before anything else. |
| 63 int registerListener(InputFieldSpeechButtonElement*); | 62 int registerListener(SpeechInputListener*); |
| 64 | 63 |
| 65 // Invoked when the listener is done with recording or getting destroyed. | 64 // Invoked when the listener is done with recording or getting destroyed. |
| 66 // Failure to unregister may result in crashes if there were any pending spe ech events. | 65 // Failure to unregister may result in crashes if there were any pending spe ech events. |
| 67 void unregisterListener(int); | 66 void unregisterListener(int); |
| 68 | 67 |
| 69 // Methods invoked by the input elements. | 68 // Methods invoked by the input elements. |
| 70 bool startRecognition(int listenerId, const IntRect& elementRect, const Atom icString& language, const String& grammar, SecurityOrigin*); | 69 bool startRecognition(int listenerId, const IntRect& elementRect, const Atom icString& language, const String& grammar, SecurityOrigin*); |
| 71 void stopRecording(int); | 70 void stopRecording(int); |
| 72 void cancelRecognition(int); | 71 void cancelRecognition(int); |
| 73 | 72 |
| 74 // SpeechInputListener methods. | 73 // SpeechInputListener methods. |
| 75 virtual void didCompleteRecording(int) OVERRIDE; | 74 virtual void didCompleteRecording(int) OVERRIDE; |
| 76 virtual void didCompleteRecognition(int) OVERRIDE; | 75 virtual void didCompleteRecognition(int) OVERRIDE; |
| 77 virtual void setRecognitionResult(int, const SpeechInputResultArray&) OVERRI DE; | 76 virtual void setRecognitionResult(int, const SpeechInputResultArray&) OVERRI DE; |
| 78 | 77 |
| 79 virtual void trace(Visitor*) OVERRIDE { } | 78 virtual void trace(Visitor*) OVERRIDE; |
| 80 void clearWeakMembers(Visitor*); | 79 void clearWeakMembers(Visitor*); |
| 81 | 80 |
| 82 private: | 81 private: |
| 83 explicit SpeechInput(PassOwnPtr<SpeechInputClient>); | 82 explicit SpeechInput(PassOwnPtr<SpeechInputClient>); |
| 84 | 83 |
| 85 OwnPtr<SpeechInputClient> m_client; | 84 OwnPtr<SpeechInputClient> m_client; |
| 86 // FIXME: Oilpan: go back to using SpeechInputListener as the type when | 85 WillBeHeapHashMap<int, RawPtrWillBeWeakMember<SpeechInputListener> > m_liste ners; |
|
Mads Ager (chromium)
2014/04/29 14:56:09
Thank you!!! :)
| |
| 87 // all SpeechInputListeners (SpeechInput and InputFieldSpeechButtonElement) | |
| 88 // have been moved to the oilpan heap. At that point SpeechInputListener | |
| 89 // will be a GarbageCollectedMixin. | |
| 90 HashMap<int, InputFieldSpeechButtonElement*> m_listeners; | |
| 91 int m_nextListenerId; | 86 int m_nextListenerId; |
| 92 }; | 87 }; |
| 93 | 88 |
| 94 } // namespace WebCore | 89 } // namespace WebCore |
| 95 | 90 |
| 96 #endif // ENABLE(INPUT_SPEECH) | 91 #endif // ENABLE(INPUT_SPEECH) |
| 97 | 92 |
| 98 #endif // SpeechInput_h | 93 #endif // SpeechInput_h |
| OLD | NEW |