Changeset 65327 in webkit


Ignore:
Timestamp:
Aug 13, 2010 9:49:30 AM (14 years ago)
Author:
commit-queue@webkit.org
Message:

2010-08-13 Satish Sampath <satish@chromium.org>

Reviewed by Jeremy Orlow.

Support for multiple speech enabled elements in same page.
https://bugs.webkit.org/show_bug.cgi?id=43922

  • page/SpeechInput.cpp: Generates request ids as necessary when each speech enabled input element gets created/destroyed and multiplexes the listener callbacks to the appropriate input element based on the request id. (WebCore::SpeechInput::SpeechInput): (WebCore::SpeechInput::~SpeechInput): (WebCore::SpeechInput::registerListener): (WebCore::SpeechInput::unregisterListener): (WebCore::SpeechInput::didCompleteRecording): (WebCore::SpeechInput::didCompleteRecognition): (WebCore::SpeechInput::setRecognitionResult): (WebCore::SpeechInput::startRecognition): (WebCore::SpeechInput::stopRecording): (WebCore::SpeechInput::cancelRecognition):
  • page/SpeechInput.h:
  • page/SpeechInputClient.h: Now requires a one time set for the WebCore::SpeechInputListener and takes in a 'requestId' for all calls.
  • page/SpeechInputListener.h: Now returns the above mentioned requestId in all the listener callbacks for identifying which input element the event goes to.
  • platform/mock/SpeechInputClientMock.cpp: (WebCore::SpeechInputClientMock::SpeechInputClientMock): (WebCore::SpeechInputClientMock::setListener): (WebCore::SpeechInputClientMock::startRecognition): (WebCore::SpeechInputClientMock::stopRecording): (WebCore::SpeechInputClientMock::cancelRecognition): (WebCore::SpeechInputClientMock::timerFired):
  • platform/mock/SpeechInputClientMock.h:
  • rendering/TextControlInnerElements.cpp: (WebCore::InputFieldSpeechButtonElement::InputFieldSpeechButtonElement): (WebCore::InputFieldSpeechButtonElement::~InputFieldSpeechButtonElement): (WebCore::InputFieldSpeechButtonElement::defaultEventHandler): (WebCore::InputFieldSpeechButtonElement::speechInput): (WebCore::InputFieldSpeechButtonElement::didCompleteRecording): (WebCore::InputFieldSpeechButtonElement::didCompleteRecognition): (WebCore::InputFieldSpeechButtonElement::setRecognitionResult):
  • rendering/TextControlInnerElements.h:

2010-08-13 Satish Sampath <satish@chromium.org>

Reviewed by Jeremy Orlow.

Support for multiple speech enabled elements in same page.
https://bugs.webkit.org/show_bug.cgi?id=43922

  • public/WebSpeechInputController.h: Bubbles up the requestId given by webcore to the embedder. (WebKit::WebSpeechInputController::startRecognition): (WebKit::WebSpeechInputController::cancelRecognition): (WebKit::WebSpeechInputController::stopRecording):
  • public/WebSpeechInputListener.h: Passes down the requestId given by embedder to webcore. (WebKit::WebSpeechInputListener::didCompleteRecording): (WebKit::WebSpeechInputListener::setRecognitionResult): (WebKit::WebSpeechInputListener::didCompleteRecognition):
  • src/SpeechInputClientImpl.cpp: (WebKit::SpeechInputClientImpl::setListener): (WebKit::SpeechInputClientImpl::startRecognition): (WebKit::SpeechInputClientImpl::stopRecording): (WebKit::SpeechInputClientImpl::cancelRecognition): (WebKit::SpeechInputClientImpl::didCompleteRecording): (WebKit::SpeechInputClientImpl::didCompleteRecognition): (WebKit::SpeechInputClientImpl::setRecognitionResult):
  • src/SpeechInputClientImpl.h:
  • src/WebSpeechInputControllerMockImpl.cpp: (WebKit::WebSpeechInputControllerMockImpl::WebSpeechInputControllerMockImpl): (WebKit::WebSpeechInputControllerMockImpl::~WebSpeechInputControllerMockImpl): (WebKit::WebSpeechInputControllerMockImpl::didCompleteRecording): (WebKit::WebSpeechInputControllerMockImpl::didCompleteRecognition): (WebKit::WebSpeechInputControllerMockImpl::setRecognitionResult): (WebKit::WebSpeechInputControllerMockImpl::startRecognition): (WebKit::WebSpeechInputControllerMockImpl::cancelRecognition): (WebKit::WebSpeechInputControllerMockImpl::stopRecording):
  • src/WebSpeechInputControllerMockImpl.h:
Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r65324 r65327  
     12010-08-13  Satish Sampath  <satish@chromium.org>
     2
     3        Reviewed by Jeremy Orlow.
     4
     5        Support for multiple speech enabled elements in same page.
     6        https://bugs.webkit.org/show_bug.cgi?id=43922
     7
     8        * page/SpeechInput.cpp: Generates request ids as necessary when each speech enabled input element gets
     9        created/destroyed and multiplexes the listener callbacks to the appropriate input element based on the request id.
     10        (WebCore::SpeechInput::SpeechInput):
     11        (WebCore::SpeechInput::~SpeechInput):
     12        (WebCore::SpeechInput::registerListener):
     13        (WebCore::SpeechInput::unregisterListener):
     14        (WebCore::SpeechInput::didCompleteRecording):
     15        (WebCore::SpeechInput::didCompleteRecognition):
     16        (WebCore::SpeechInput::setRecognitionResult):
     17        (WebCore::SpeechInput::startRecognition):
     18        (WebCore::SpeechInput::stopRecording):
     19        (WebCore::SpeechInput::cancelRecognition):
     20        * page/SpeechInput.h:
     21        * page/SpeechInputClient.h: Now requires a one time set for the WebCore::SpeechInputListener and
     22        takes in a 'requestId' for all calls.
     23        * page/SpeechInputListener.h: Now returns the above mentioned requestId in all the listener callbacks for
     24        identifying which input element the event goes to.
     25        * platform/mock/SpeechInputClientMock.cpp:
     26        (WebCore::SpeechInputClientMock::SpeechInputClientMock):
     27        (WebCore::SpeechInputClientMock::setListener):
     28        (WebCore::SpeechInputClientMock::startRecognition):
     29        (WebCore::SpeechInputClientMock::stopRecording):
     30        (WebCore::SpeechInputClientMock::cancelRecognition):
     31        (WebCore::SpeechInputClientMock::timerFired):
     32        * platform/mock/SpeechInputClientMock.h:
     33        * rendering/TextControlInnerElements.cpp:
     34        (WebCore::InputFieldSpeechButtonElement::InputFieldSpeechButtonElement):
     35        (WebCore::InputFieldSpeechButtonElement::~InputFieldSpeechButtonElement):
     36        (WebCore::InputFieldSpeechButtonElement::defaultEventHandler):
     37        (WebCore::InputFieldSpeechButtonElement::speechInput):
     38        (WebCore::InputFieldSpeechButtonElement::didCompleteRecording):
     39        (WebCore::InputFieldSpeechButtonElement::didCompleteRecognition):
     40        (WebCore::InputFieldSpeechButtonElement::setRecognitionResult):
     41        * rendering/TextControlInnerElements.h:
     42
    1432010-08-13  Eric Carlson  <eric.carlson@apple.com>
    244
  • trunk/WebCore/page/SpeechInput.cpp

    r64111 r65327  
    4242SpeechInput::SpeechInput(SpeechInputClient* client)
    4343    : m_client(client)
    44     , m_listener(0)
     44    , m_nextListenerId(1)
    4545{
     46    m_client->setListener(this);
    4647}
    4748
    48 void SpeechInput::didCompleteRecording()
     49SpeechInput::~SpeechInput()
    4950{
    50     ASSERT(m_listener);
    51     m_listener->didCompleteRecording();
     51    m_client->setListener(0);
    5252}
    5353
    54 void SpeechInput::didCompleteRecognition()
     54int SpeechInput::registerListener(SpeechInputListener* listener)
    5555{
    56     ASSERT(m_listener);
    57     m_listener->didCompleteRecognition();
    58     m_listener = 0;
     56#if defined(DEBUG)
     57    // Check if already present.
     58    for (HashMap<int, SpeechInputListener*>::iterator it = m_listeners.begin(); it != m_listeners.end(); ++it)
     59      ASSERT(it->second != listener);
     60#endif
     61
     62    m_listeners.add(m_nextListenerId, listener);
     63    return m_nextListenerId++;
    5964}
    6065
    61 void SpeechInput::setRecognitionResult(const String& result)
     66void SpeechInput::unregisterListener(int listenerId)
    6267{
    63     ASSERT(m_listener);
    64     m_listener->setRecognitionResult(result);
     68    if (m_listeners.contains(listenerId))
     69        m_listeners.remove(listenerId);
    6570}
    6671
    67 bool SpeechInput::startRecognition(SpeechInputListener* listener)
     72void SpeechInput::didCompleteRecording(int listenerId)
    6873{
    69     // Cancel any ongoing recognition first.
    70     if (m_listener) {
    71         m_listener->didCompleteRecognition();
    72         m_listener = 0;
    73         m_client->cancelRecognition();
    74     }
    75 
    76     m_listener = listener;
    77     return m_client->startRecognition(this);
     74    // Don't assert if not present as the element might have been removed by the page while
     75    // this event was on the way.
     76    if (m_listeners.contains(listenerId))
     77        m_listeners.get(listenerId)->didCompleteRecording(listenerId);
    7878}
    7979
    80 void SpeechInput::stopRecording()
     80void SpeechInput::didCompleteRecognition(int listenerId)
    8181{
    82     ASSERT(m_listener);
    83     m_client->stopRecording();
     82    // Don't assert if not present as the element might have been removed by the page while
     83    // this event was on the way.
     84    if (m_listeners.contains(listenerId))
     85        m_listeners.get(listenerId)->didCompleteRecognition(listenerId);
     86}
     87
     88void SpeechInput::setRecognitionResult(int listenerId, const String& result)
     89{
     90    // Don't assert if not present as the element might have been removed by the page while
     91    // this event was on the way.
     92    if (m_listeners.contains(listenerId))
     93        m_listeners.get(listenerId)->setRecognitionResult(listenerId, result);
     94}
     95
     96bool SpeechInput::startRecognition(int listenerId)
     97{
     98    ASSERT(m_listeners.contains(listenerId));
     99    return m_client->startRecognition(listenerId);
     100}
     101
     102void SpeechInput::stopRecording(int listenerId)
     103{
     104    ASSERT(m_listeners.contains(listenerId));
     105    m_client->stopRecording(listenerId);
     106}
     107
     108void SpeechInput::cancelRecognition(int listenerId)
     109{
     110    ASSERT(m_listeners.contains(listenerId));
     111    m_client->cancelRecognition(listenerId);
    84112}
    85113
  • trunk/WebCore/page/SpeechInput.h

    r65021 r65327  
    3636#include "SpeechInputListener.h"
    3737#include <wtf/Forward.h>
     38#include <wtf/HashMap.h>
    3839#include <wtf/Noncopyable.h>
    3940
     
    4950public:
    5051    SpeechInput(SpeechInputClient*);
    51     virtual ~SpeechInput() { }
     52    virtual ~SpeechInput();
     53
     54    // Generates a unique ID for the given listener to be used for speech requests.
     55    // This should be the first call made by listeners before anything else.
     56    int registerListener(SpeechInputListener*);
     57
     58    // Invoked when the listener is done with recording or getting destroyed.
     59    // Failure to unregister may result in crashes if there were any pending speech events.
     60    void unregisterListener(int);
    5261
    5362    // Methods invoked by the input elements.
    54     bool startRecognition(SpeechInputListener* listener);
    55     void stopRecording();
     63    bool startRecognition(int);
     64    void stopRecording(int);
     65    void cancelRecognition(int);
    5666
    5767    // SpeechInputListener methods.
    58     virtual void didCompleteRecording();
    59     virtual void didCompleteRecognition();
    60     virtual void setRecognitionResult(const String&);
     68    virtual void didCompleteRecording(int);
     69    virtual void didCompleteRecognition(int);
     70    virtual void setRecognitionResult(int, const String&);
    6171
    6272private:
    6373    SpeechInputClient* m_client;
    64     SpeechInputListener* m_listener;
     74    HashMap<int, SpeechInputListener*> m_listeners;
     75    int m_nextListenerId;
    6576};
    6677
  • trunk/WebCore/page/SpeechInputClient.h

    r64111 r65327  
    4141class SpeechInputClient {
    4242public:
    43     virtual bool startRecognition(SpeechInputListener* listener) = 0;
     43    // This is the first call made by a listener, registering itself for future callbacks.
     44    // When the listener no longer needs speech input (for e.g. when it gets destroyed),
     45    // it should set a null listener to stop receiving callbacks.
     46    // The client does not take ownership of the pointer.
     47    virtual void setListener(SpeechInputListener*) = 0;
     48
     49    // Starts speech recognition and audio recording.
     50    virtual bool startRecognition(int requestId) = 0;
    4451
    4552    // Stops audio recording and performs recognition with the audio recorded until now
    4653    // (does not discard audio).
    47     virtual void stopRecording() = 0;
     54    virtual void stopRecording(int requestId) = 0;
    4855
    4956    // Cancels an ongoing recognition and discards any audio recorded so far. No partial
    5057    // recognition results are returned to the listener.
    51     virtual void cancelRecognition() = 0;
     58    virtual void cancelRecognition(int requestId) = 0;
    5259
    5360protected:
  • trunk/WebCore/page/SpeechInputListener.h

    r65021 r65327  
    4242public:
    4343    // Informs that audio recording has completed and recognition is underway.
    44     virtual void didCompleteRecording() = 0;
     44    virtual void didCompleteRecording(int requestId) = 0;
    4545
    4646    // Informs that speech recognition has completed. This gets invoked irrespective of whether
     
    4848    // handler typically frees up any temporary resources allocated and waits for the next speech
    4949    // recognition request.
    50     virtual void didCompleteRecognition() = 0;
     50    virtual void didCompleteRecognition(int requestId) = 0;
    5151
    5252    // Gives results from speech recognition, either partial or the final results.
     
    5454    // available as the user keeps speaking. If the speech could not be recognized properly
    5555    // or if there was any other errors in the process, this method may never be called.
    56     virtual void setRecognitionResult(const String& result) = 0;
     56    virtual void setRecognitionResult(int requestId, const String& result) = 0;
    5757
    5858protected:
  • trunk/WebCore/platform/mock/SpeechInputClientMock.cpp

    r64351 r65327  
    4242    , m_timer(this, &SpeechInputClientMock::timerFired)
    4343    , m_listener(0)
     44    , m_requestId(0)
    4445{
    4546}
    4647
    47 bool SpeechInputClientMock::startRecognition(SpeechInputListener* listener)
     48void SpeechInputClientMock::setListener(SpeechInputListener* listener)
     49{
     50    m_listener = listener;
     51}
     52
     53bool SpeechInputClientMock::startRecognition(int requestId)
    4854{
    4955    if (m_timer.isActive())
    5056        return false;
    51     m_listener = listener;
     57    m_requestId = requestId;
    5258    m_recording = true;
    5359    m_timer.startOneShot(0);
     
    5561}
    5662
    57 void SpeechInputClientMock::stopRecording()
     63void SpeechInputClientMock::stopRecording(int requestId)
    5864{
     65    ASSERT(requestId == m_requestId);
    5966    if (m_timer.isActive() && m_recording) {
    6067        m_timer.stop();
     
    6370}
    6471
    65 void SpeechInputClientMock::cancelRecognition()
     72void SpeechInputClientMock::cancelRecognition(int requestId)
    6673{
     74    ASSERT(requestId == m_requestId);
    6775    if (m_timer.isActive()) {
    6876        m_timer.stop();
    6977        m_recording = false;
    70         m_listener->didCompleteRecognition();
    71         m_listener = 0;
     78        m_listener->didCompleteRecognition(m_requestId);
     79        m_requestId = 0;
    7280    }
    7381}
     
    8290    if (m_recording) {
    8391        m_recording = false;
    84         m_listener->didCompleteRecording();
     92        m_listener->didCompleteRecording(m_requestId);
    8593        m_timer.startOneShot(0);
    8694    } else {
    87         m_listener->setRecognitionResult(m_recognitionResult);
    88         m_listener->didCompleteRecognition();
    89         m_listener = 0;
     95        m_listener->setRecognitionResult(m_requestId, m_recognitionResult);
     96        m_listener->didCompleteRecognition(m_requestId);
     97        m_requestId = 0;
    9098    }
    9199}
  • trunk/WebCore/platform/mock/SpeechInputClientMock.h

    r64351 r65327  
    5050
    5151    // SpeechInputClient methods.
    52     bool startRecognition(SpeechInputListener*);
    53     void stopRecording();
    54     void cancelRecognition();
     52    void setListener(SpeechInputListener*);
     53    bool startRecognition(int);
     54    void stopRecording(int);
     55    void cancelRecognition(int);
    5556
    5657private:
     
    6061    Timer<SpeechInputClientMock> m_timer;
    6162    SpeechInputListener* m_listener;
     63    int m_requestId;
    6264    String m_recognitionResult;
    6365};
  • trunk/WebCore/rendering/TextControlInnerElements.cpp

    r65220 r65327  
    347347    , m_capturing(false)
    348348    , m_state(Idle)
    349 {
     349    , m_listenerId(document()->page()->speechInput()->registerListener(this))
     350{
     351}
     352
     353InputFieldSpeechButtonElement::~InputFieldSpeechButtonElement()
     354{
     355    SpeechInput* speech = speechInput();
     356    if (speech)  { // Could be null when page is unloading.
     357        if (m_state != Idle)
     358            speech->cancelRecognition(m_listenerId);
     359        speech->unregisterListener(m_listenerId);
     360    }
    350361}
    351362
     
    387398        switch (m_state) {
    388399        case Idle:
    389             if (speechInput()->startRecognition(this))
     400            if (speechInput()->startRecognition(m_listenerId))
    390401                setState(Recording);
    391402            break;
    392403        case Recording:
    393             speechInput()->stopRecording();
     404            speechInput()->stopRecording(m_listenerId);
    394405            break;
    395406        case Recognizing:
     
    414425SpeechInput* InputFieldSpeechButtonElement::speechInput()
    415426{
    416     return document()->page()->speechInput();
    417 }
    418 
    419 void InputFieldSpeechButtonElement::didCompleteRecording()
     427    return document()->page() ? document()->page()->speechInput() : 0;
     428}
     429
     430void InputFieldSpeechButtonElement::didCompleteRecording(int)
    420431{
    421432    setState(Recognizing);
    422433}
    423434
    424 void InputFieldSpeechButtonElement::didCompleteRecognition()
     435void InputFieldSpeechButtonElement::didCompleteRecognition(int)
    425436{
    426437    setState(Idle);
    427438}
    428439
    429 void InputFieldSpeechButtonElement::setRecognitionResult(const String& result)
     440void InputFieldSpeechButtonElement::setRecognitionResult(int, const String& result)
    430441{
    431442    HTMLInputElement* input = static_cast<HTMLInputElement*>(shadowAncestorNode());
  • trunk/WebCore/rendering/TextControlInnerElements.h

    r65220 r65327  
    127127
    128128    static PassRefPtr<InputFieldSpeechButtonElement> create(Node*);
     129    virtual ~InputFieldSpeechButtonElement();
    129130
    130131    virtual void detach();
     
    133134
    134135    // SpeechInputListener methods.
    135     void didCompleteRecording();
    136     void didCompleteRecognition();
    137     void setRecognitionResult(const String& result);
     136    void didCompleteRecording(int);
     137    void didCompleteRecognition(int);
     138    void setRecognitionResult(int, const String& result);
    138139
    139140private:
     
    144145    bool m_capturing;
    145146    SpeechInputState m_state;
     147    int m_listenerId;
    146148};
    147149
  • trunk/WebKit/chromium/ChangeLog

    r65304 r65327  
     12010-08-13  Satish Sampath  <satish@chromium.org>
     2
     3        Reviewed by Jeremy Orlow.
     4
     5        Support for multiple speech enabled elements in same page.
     6        https://bugs.webkit.org/show_bug.cgi?id=43922
     7
     8        * public/WebSpeechInputController.h: Bubbles up the requestId given by webcore to the embedder.
     9        (WebKit::WebSpeechInputController::startRecognition):
     10        (WebKit::WebSpeechInputController::cancelRecognition):
     11        (WebKit::WebSpeechInputController::stopRecording):
     12        * public/WebSpeechInputListener.h: Passes down the requestId given by embedder to webcore.
     13        (WebKit::WebSpeechInputListener::didCompleteRecording):
     14        (WebKit::WebSpeechInputListener::setRecognitionResult):
     15        (WebKit::WebSpeechInputListener::didCompleteRecognition):
     16        * src/SpeechInputClientImpl.cpp:
     17        (WebKit::SpeechInputClientImpl::setListener):
     18        (WebKit::SpeechInputClientImpl::startRecognition):
     19        (WebKit::SpeechInputClientImpl::stopRecording):
     20        (WebKit::SpeechInputClientImpl::cancelRecognition):
     21        (WebKit::SpeechInputClientImpl::didCompleteRecording):
     22        (WebKit::SpeechInputClientImpl::didCompleteRecognition):
     23        (WebKit::SpeechInputClientImpl::setRecognitionResult):
     24        * src/SpeechInputClientImpl.h:
     25        * src/WebSpeechInputControllerMockImpl.cpp:
     26        (WebKit::WebSpeechInputControllerMockImpl::WebSpeechInputControllerMockImpl):
     27        (WebKit::WebSpeechInputControllerMockImpl::~WebSpeechInputControllerMockImpl):
     28        (WebKit::WebSpeechInputControllerMockImpl::didCompleteRecording):
     29        (WebKit::WebSpeechInputControllerMockImpl::didCompleteRecognition):
     30        (WebKit::WebSpeechInputControllerMockImpl::setRecognitionResult):
     31        (WebKit::WebSpeechInputControllerMockImpl::startRecognition):
     32        (WebKit::WebSpeechInputControllerMockImpl::cancelRecognition):
     33        (WebKit::WebSpeechInputControllerMockImpl::stopRecording):
     34        * src/WebSpeechInputControllerMockImpl.h:
     35
    1362010-08-12  Yury Semikhatsky  <yurys@chromium.org>
    237
  • trunk/WebKit/chromium/public/WebSpeechInputController.h

    r64042 r65327  
    4242    // runs to the limit or stopRecording is called. Progress indications and the recognized
    4343    // text are returned via the listener interface.
     44    virtual bool startRecognition(int)
     45    {
     46        return startRecognition();
     47    }
     48    // FIXME: Remove this once chromium has picked up this change.
    4449    virtual bool startRecognition()
    4550    {
    46          WEBKIT_ASSERT_NOT_REACHED();
    47          return false;
     51        WEBKIT_ASSERT_NOT_REACHED();
     52        return false;
    4853    }
    4954
    5055    // Cancels an ongoing recognition and discards any audio recorded so far. No partial
    5156    // recognition results are returned to the listener.
     57    virtual void cancelRecognition(int) { cancelRecognition(); }
     58    // FIXME: Remove this once chromium has picked up this change.
    5259    virtual void cancelRecognition() { WEBKIT_ASSERT_NOT_REACHED(); }
    5360
     
    5764    // recording 'endpointer' should detect silence in the input and stop recording automatically.
    5865    // Call startRecognition() to record audio and recognize speech again.
     66    virtual void stopRecording(int) { stopRecording(); }
     67    // FIXME: Remove this once chromium has picked up this change.
    5968    virtual void stopRecording() { WEBKIT_ASSERT_NOT_REACHED(); }
    6069
  • trunk/WebKit/chromium/public/WebSpeechInputListener.h

    r64042 r65327  
    4848    // Typically after this call the listener would update the UI to reflect that recognition is
    4949    // in progress.
    50     virtual void didCompleteRecording() = 0;
     50    virtual void didCompleteRecording(int) = 0;
     51    // FIXME: Remove this once chromium has picked up this change.
     52    virtual void didCompleteRecording()
     53    {
     54        didCompleteRecording(1);
     55    }
    5156
    5257    // Gives results from speech recognition, either partial or the final results.
     
    5459    // available as the user keeps speaking. If the speech could not be recognized properly
    5560    // or if there was any other errors in the process, this method may never be called.
    56     virtual void setRecognitionResult(const WebString&) = 0;
     61    virtual void setRecognitionResult(int, const WebString&) = 0;
     62    // FIXME: Remove this once chromium has picked up this change.
     63    virtual void setRecognitionResult(const WebString& result)
     64    {
     65        setRecognitionResult(1, result);
     66    }
    5767
    5868    // Informs that speech recognition has completed. This gets invoked irrespective of whether
     
    6070    // handler typically frees up any temporary resources allocated and waits for the next speech
    6171    // recognition request.
    62     virtual void didCompleteRecognition() = 0;
     72    virtual void didCompleteRecognition(int) = 0;
     73    // FIXME: Remove this once chromium has picked up this change.
     74    virtual void didCompleteRecognition()
     75    {
     76        didCompleteRecognition(1);
     77    }
    6378
    6479protected:
  • trunk/WebKit/chromium/src/SpeechInputClientImpl.cpp

    r64352 r65327  
    5252}
    5353
    54 bool SpeechInputClientImpl::startRecognition(WebCore::SpeechInputListener* listener)
     54void SpeechInputClientImpl::setListener(WebCore::SpeechInputListener* listener)
    5555{
    5656    m_listener = listener;
    57     return m_controller->startRecognition();
    5857}
    5958
    60 void SpeechInputClientImpl::stopRecording()
     59bool SpeechInputClientImpl::startRecognition(int requestId)
    6160{
    6261    ASSERT(m_listener);
    63     m_controller->stopRecording();
     62    return m_controller->startRecognition(requestId);
    6463}
    6564
    66 void SpeechInputClientImpl::cancelRecognition()
     65void SpeechInputClientImpl::stopRecording(int requestId)
    6766{
    6867    ASSERT(m_listener);
    69     m_controller->cancelRecognition();
     68    m_controller->stopRecording(requestId);
    7069}
    7170
    72 void SpeechInputClientImpl::didCompleteRecording()
     71void SpeechInputClientImpl::cancelRecognition(int requestId)
    7372{
    7473    ASSERT(m_listener);
    75     m_listener->didCompleteRecording();
     74    m_controller->cancelRecognition(requestId);
    7675}
    7776
    78 void SpeechInputClientImpl::didCompleteRecognition()
     77void SpeechInputClientImpl::didCompleteRecording(int requestId)
    7978{
    8079    ASSERT(m_listener);
    81     m_listener->didCompleteRecognition();
    82     m_listener = 0;
     80    m_listener->didCompleteRecording(requestId);
    8381}
    8482
    85 void SpeechInputClientImpl::setRecognitionResult(const WebString& result)
     83void SpeechInputClientImpl::didCompleteRecognition(int requestId)
    8684{
    8785    ASSERT(m_listener);
    88     m_listener->setRecognitionResult(result);
     86    m_listener->didCompleteRecognition(requestId);
     87}
     88
     89void SpeechInputClientImpl::setRecognitionResult(int requestId, const WebString& result)
     90{
     91    ASSERT(m_listener);
     92    m_listener->setRecognitionResult(requestId, result);
    8993}
    9094
  • trunk/WebKit/chromium/src/SpeechInputClientImpl.h

    r64111 r65327  
    5454
    5555    // SpeechInputClient methods.
    56     bool startRecognition(WebCore::SpeechInputListener*);
    57     void stopRecording();
    58     void cancelRecognition();
     56    void setListener(WebCore::SpeechInputListener*);
     57    bool startRecognition(int);
     58    void stopRecording(int);
     59    void cancelRecognition(int);
    5960
    6061    // WebSpeechInputListener methods.
    61     void didCompleteRecording();
    62     void setRecognitionResult(const WebString&);
    63     void didCompleteRecognition();
     62    void didCompleteRecording(int);
     63    void setRecognitionResult(int, const WebString&);
     64    void didCompleteRecognition(int);
    6465
    6566private:
    6667    WebSpeechInputController* m_controller; // To call into the embedder.
    67     WebCore::SpeechInputListener* m_listener; // Valid when recognition is in progress.
     68    WebCore::SpeechInputListener* m_listener;
    6869};
    6970
  • trunk/WebKit/chromium/src/WebSpeechInputControllerMockImpl.cpp

    r65021 r65327  
    4747    , m_listener(listener)
    4848{
     49    m_webcoreMock->setListener(this);
     50}
     51
     52WebSpeechInputControllerMockImpl::~WebSpeechInputControllerMockImpl()
     53{
     54    m_webcoreMock->setListener(0);
    4955}
    5056
     
    5460}
    5561
    56 void WebSpeechInputControllerMockImpl::didCompleteRecording()
     62void WebSpeechInputControllerMockImpl::didCompleteRecording(int requestId)
    5763{
    58     m_listener->didCompleteRecording();
     64    m_listener->didCompleteRecording(requestId);
    5965}
    6066
    61 void WebSpeechInputControllerMockImpl::didCompleteRecognition()
     67void WebSpeechInputControllerMockImpl::didCompleteRecognition(int requestId)
    6268{
    63     m_listener->didCompleteRecognition();
     69    m_listener->didCompleteRecognition(requestId);
    6470}
    6571
    66 void WebSpeechInputControllerMockImpl::setRecognitionResult(const WTF::String& result)
     72void WebSpeechInputControllerMockImpl::setRecognitionResult(int requestId, const WTF::String& result)
    6773{
    68     m_listener->setRecognitionResult(result);
     74    m_listener->setRecognitionResult(requestId, result);
    6975}
    7076
    71 bool WebSpeechInputControllerMockImpl::startRecognition()
     77bool WebSpeechInputControllerMockImpl::startRecognition(int requestId)
    7278{
    73     return m_webcoreMock->startRecognition(this);
     79    return m_webcoreMock->startRecognition(requestId);
    7480}
    7581
    76 void WebSpeechInputControllerMockImpl::cancelRecognition()
     82void WebSpeechInputControllerMockImpl::cancelRecognition(int requestId)
    7783{
    78     m_webcoreMock->cancelRecognition();
     84    m_webcoreMock->cancelRecognition(requestId);
    7985}
    8086
    81 void WebSpeechInputControllerMockImpl::stopRecording()
     87void WebSpeechInputControllerMockImpl::stopRecording(int requestId)
    8288{
    83     m_webcoreMock->stopRecording();
     89    m_webcoreMock->stopRecording(requestId);
    8490}
    8591
  • trunk/WebKit/chromium/src/WebSpeechInputControllerMockImpl.h

    r65021 r65327  
    4848public:
    4949    WebSpeechInputControllerMockImpl(WebSpeechInputListener*);
     50    virtual ~WebSpeechInputControllerMockImpl();
    5051
    5152    // WebCore::SpeechInputListener methods.
    52     void didCompleteRecording();
    53     void didCompleteRecognition();
    54     void setRecognitionResult(const WTF::String& result);
     53    void didCompleteRecording(int requestId);
     54    void didCompleteRecognition(int requestId);
     55    void setRecognitionResult(int requestId, const WTF::String& result);
    5556
    5657    // WebSpeechInputController methods.
    57     bool startRecognition();
    58     void cancelRecognition();
    59     void stopRecording();
     58    bool startRecognition(int requestId);
     59    void cancelRecognition(int requestId);
     60    void stopRecording(int requestId);
    6061
    6162    // WebSpeechInputControllerMock methods.
Note: See TracChangeset for help on using the changeset viewer.