| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_REQUEST_H_ | 5 #ifndef CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_REQUEST_H_ |
| 6 #define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_REQUEST_H_ | 6 #define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_REQUEST_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 // |url| is the server address to which the request wil be sent. | 40 // |url| is the server address to which the request wil be sent. |
| 41 SpeechRecognitionRequest(URLRequestContextGetter* context, | 41 SpeechRecognitionRequest(URLRequestContextGetter* context, |
| 42 Delegate* delegate); | 42 Delegate* delegate); |
| 43 | 43 |
| 44 virtual ~SpeechRecognitionRequest(); | 44 virtual ~SpeechRecognitionRequest(); |
| 45 | 45 |
| 46 // Sends a new request with the given audio data, returns true if successful. | 46 // Sends a new request with the given audio data, returns true if successful. |
| 47 // The same object can be used to send multiple requests but only after the | 47 // The same object can be used to send multiple requests but only after the |
| 48 // previous request has completed. | 48 // previous request has completed. |
| 49 bool Send(const std::string& language, | 49 void Start(const std::string& language, |
| 50 const std::string& grammar, | 50 const std::string& grammar, |
| 51 const std::string& hardware_info, | 51 const std::string& hardware_info, |
| 52 const std::string& origin_url, | 52 const std::string& origin_url, |
| 53 const std::string& content_type, | 53 const std::string& content_type); |
| 54 const std::string& audio_data); | 54 |
| 55 // Send a single chunk of audio immediately to the server. |
| 56 void UploadAudioChunk(const std::string& audio_data, bool is_last_chunk); |
| 55 | 57 |
| 56 bool HasPendingRequest() { return url_fetcher_ != NULL; } | 58 bool HasPendingRequest() { return url_fetcher_ != NULL; } |
| 57 | 59 |
| 58 // URLFetcher::Delegate methods. | 60 // URLFetcher::Delegate methods. |
| 59 virtual void OnURLFetchComplete(const URLFetcher* source, | 61 virtual void OnURLFetchComplete(const URLFetcher* source, |
| 60 const GURL& url, | 62 const GURL& url, |
| 61 const net::URLRequestStatus& status, | 63 const net::URLRequestStatus& status, |
| 62 int response_code, | 64 int response_code, |
| 63 const ResponseCookies& cookies, | 65 const ResponseCookies& cookies, |
| 64 const std::string& data); | 66 const std::string& data); |
| 65 | 67 |
| 66 private: | 68 private: |
| 67 scoped_refptr<URLRequestContextGetter> url_context_; | 69 scoped_refptr<URLRequestContextGetter> url_context_; |
| 68 Delegate* delegate_; | 70 Delegate* delegate_; |
| 69 scoped_ptr<URLFetcher> url_fetcher_; | 71 scoped_ptr<URLFetcher> url_fetcher_; |
| 70 | 72 |
| 71 DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionRequest); | 73 DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionRequest); |
| 72 }; | 74 }; |
| 73 | 75 |
| 74 // This typedef is to workaround the issue with certain versions of | 76 // This typedef is to workaround the issue with certain versions of |
| 75 // Visual Studio where it gets confused between multiple Delegate | 77 // Visual Studio where it gets confused between multiple Delegate |
| 76 // classes and gives a C2500 error. (I saw this error on the try bots - | 78 // classes and gives a C2500 error. (I saw this error on the try bots - |
| 77 // the workaround was not needed for my machine). | 79 // the workaround was not needed for my machine). |
| 78 typedef SpeechRecognitionRequest::Delegate SpeechRecognitionRequestDelegate; | 80 typedef SpeechRecognitionRequest::Delegate SpeechRecognitionRequestDelegate; |
| 79 | 81 |
| 80 } // namespace speech_input | 82 } // namespace speech_input |
| 81 | 83 |
| 82 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_REQUEST_H_ | 84 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_REQUEST_H_ |
| OLD | NEW |