Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Side by Side Diff: content/browser/speech/speech_recognition_request.h

Issue 8373021: Convert URLFetcher::Delegates to use an interface in content/public/common. Also remove the old U... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync and remove unncessary forward declares Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
15 #include "content/common/net/url_fetcher.h" 15 #include "content/public/common/url_fetcher_delegate.h"
16 #include "content/common/speech_input_result.h" 16 #include "content/common/speech_input_result.h"
17 #include "googleurl/src/gurl.h" 17 #include "googleurl/src/gurl.h"
18 18
19 class URLFetcher; 19 class URLFetcher;
20 20
21 namespace net { 21 namespace net {
22 class URLRequestContextGetter; 22 class URLRequestContextGetter;
23 } 23 }
24 24
25 namespace speech_input { 25 namespace speech_input {
26 26
27 // Provides a simple interface for sending recorded speech data to the server 27 // Provides a simple interface for sending recorded speech data to the server
28 // and get back recognition results. 28 // and get back recognition results.
29 class SpeechRecognitionRequest : public URLFetcher::Delegate { 29 class SpeechRecognitionRequest : public content::URLFetcherDelegate {
30 public: 30 public:
31 // ID passed to URLFetcher::Create(). Used for testing. 31 // ID passed to URLFetcher::Create(). Used for testing.
32 CONTENT_EXPORT static int url_fetcher_id_for_tests; 32 CONTENT_EXPORT static int url_fetcher_id_for_tests;
33 33
34 // Interface for receiving callbacks from this object. 34 // Interface for receiving callbacks from this object.
35 class CONTENT_EXPORT Delegate { 35 class CONTENT_EXPORT Delegate {
36 public: 36 public:
37 virtual void SetRecognitionResult(const SpeechInputResult& result) = 0; 37 virtual void SetRecognitionResult(const SpeechInputResult& result) = 0;
38 38
39 protected: 39 protected:
(...skipping 15 matching lines...) Expand all
55 const std::string& hardware_info, 55 const std::string& hardware_info,
56 const std::string& origin_url, 56 const std::string& origin_url,
57 const std::string& content_type); 57 const std::string& content_type);
58 58
59 // Send a single chunk of audio immediately to the server. 59 // Send a single chunk of audio immediately to the server.
60 CONTENT_EXPORT void UploadAudioChunk(const std::string& audio_data, 60 CONTENT_EXPORT void UploadAudioChunk(const std::string& audio_data,
61 bool is_last_chunk); 61 bool is_last_chunk);
62 62
63 CONTENT_EXPORT bool HasPendingRequest() { return url_fetcher_ != NULL; } 63 CONTENT_EXPORT bool HasPendingRequest() { return url_fetcher_ != NULL; }
64 64
65 // URLFetcher::Delegate methods. 65 // content::URLFetcherDelegate methods.
66 virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE; 66 virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE;
67 67
68 private: 68 private:
69 scoped_refptr<net::URLRequestContextGetter> url_context_; 69 scoped_refptr<net::URLRequestContextGetter> url_context_;
70 Delegate* delegate_; 70 Delegate* delegate_;
71 scoped_ptr<URLFetcher> url_fetcher_; 71 scoped_ptr<URLFetcher> url_fetcher_;
72 72
73 DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionRequest); 73 DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionRequest);
74 }; 74 };
75 75
76 // This typedef is to workaround the issue with certain versions of 76 // This typedef is to workaround the issue with certain versions of
77 // Visual Studio where it gets confused between multiple Delegate 77 // Visual Studio where it gets confused between multiple Delegate
78 // 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 -
79 // the workaround was not needed for my machine). 79 // the workaround was not needed for my machine).
80 typedef SpeechRecognitionRequest::Delegate SpeechRecognitionRequestDelegate; 80 typedef SpeechRecognitionRequest::Delegate SpeechRecognitionRequestDelegate;
81 81
82 } // namespace speech_input 82 } // namespace speech_input
83 83
84 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_REQUEST_H_ 84 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_REQUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698