| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_REQUEST_H_ | 5 #ifndef CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_REQUEST_H_ |
| 6 #define CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_REQUEST_H_ | 6 #define CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_REQUEST_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
| 11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
| 12 #include "chrome/common/net/url_fetcher.h" | 12 #include "chrome/common/net/url_fetcher.h" |
| 13 #include "chrome/common/speech_input_result.h" |
| 13 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 14 | 15 |
| 15 class URLFetcher; | 16 class URLFetcher; |
| 16 class URLRequestContextGetter; | 17 class URLRequestContextGetter; |
| 17 | 18 |
| 18 namespace speech_input { | 19 namespace speech_input { |
| 19 | 20 |
| 20 // Provides a simple interface for sending recorded speech data to the server | 21 // Provides a simple interface for sending recorded speech data to the server |
| 21 // and get back recognition results. | 22 // and get back recognition results. |
| 22 class SpeechRecognitionRequest : public URLFetcher::Delegate { | 23 class SpeechRecognitionRequest : public URLFetcher::Delegate { |
| 23 public: | 24 public: |
| 24 // ID passed to URLFetcher::Create(). Used for testing. | 25 // ID passed to URLFetcher::Create(). Used for testing. |
| 25 static int url_fetcher_id_for_tests; | 26 static int url_fetcher_id_for_tests; |
| 26 | 27 |
| 27 // Interface for receiving callbacks from this object. | 28 // Interface for receiving callbacks from this object. |
| 28 class Delegate { | 29 class Delegate { |
| 29 public: | 30 public: |
| 30 virtual void SetRecognitionResult(bool error, const string16& value) = 0; | 31 virtual void SetRecognitionResult( |
| 32 bool error, const SpeechInputResultArray& result) = 0; |
| 31 | 33 |
| 32 protected: | 34 protected: |
| 33 virtual ~Delegate() {} | 35 virtual ~Delegate() {} |
| 34 }; | 36 }; |
| 35 | 37 |
| 36 // |url| is the server address to which the request wil be sent. | 38 // |url| is the server address to which the request wil be sent. |
| 37 SpeechRecognitionRequest(URLRequestContextGetter* context, | 39 SpeechRecognitionRequest(URLRequestContextGetter* context, |
| 38 const GURL& url, | 40 const GURL& url, |
| 39 Delegate* delegate); | 41 Delegate* delegate); |
| 40 | 42 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 66 | 68 |
| 67 // This typedef is to workaround the issue with certain versions of | 69 // This typedef is to workaround the issue with certain versions of |
| 68 // Visual Studio where it gets confused between multiple Delegate | 70 // Visual Studio where it gets confused between multiple Delegate |
| 69 // classes and gives a C2500 error. (I saw this error on the try bots - | 71 // classes and gives a C2500 error. (I saw this error on the try bots - |
| 70 // the workaround was not needed for my machine). | 72 // the workaround was not needed for my machine). |
| 71 typedef SpeechRecognitionRequest::Delegate SpeechRecognitionRequestDelegate; | 73 typedef SpeechRecognitionRequest::Delegate SpeechRecognitionRequestDelegate; |
| 72 | 74 |
| 73 } // namespace speech_input | 75 } // namespace speech_input |
| 74 | 76 |
| 75 #endif // CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_REQUEST_H_ | 77 #endif // CHROME_BROWSER_SPEECH_SPEECH_RECOGNITION_REQUEST_H_ |
| OLD | NEW |