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

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

Issue 11347004: content/browser: Move speech code into content namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_GOOGLE_STREAMING_REMOTE_ENGINE_H_ 5 #ifndef CONTENT_BROWSER_SPEECH_GOOGLE_STREAMING_REMOTE_ENGINE_H_
6 #define CONTENT_BROWSER_SPEECH_GOOGLE_STREAMING_REMOTE_ENGINE_H_ 6 #define CONTENT_BROWSER_SPEECH_GOOGLE_STREAMING_REMOTE_ENGINE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
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 "base/threading/non_thread_safe.h" 14 #include "base/threading/non_thread_safe.h"
15 #include "content/browser/speech/audio_encoder.h" 15 #include "content/browser/speech/audio_encoder.h"
16 #include "content/browser/speech/chunked_byte_buffer.h" 16 #include "content/browser/speech/chunked_byte_buffer.h"
17 #include "content/browser/speech/speech_recognition_engine.h" 17 #include "content/browser/speech/speech_recognition_engine.h"
18 #include "content/common/content_export.h" 18 #include "content/common/content_export.h"
19 #include "content/public/common/speech_recognition_error.h" 19 #include "content/public/common/speech_recognition_error.h"
20 #include "googleurl/src/gurl.h" 20 #include "googleurl/src/gurl.h"
21 #include "net/url_request/url_fetcher_delegate.h" 21 #include "net/url_request/url_fetcher_delegate.h"
22 22
23 namespace content {
24 struct SpeechRecognitionError;
25 struct SpeechRecognitionResult;
26 }
27
28 namespace net { 23 namespace net {
29 class URLRequestContextGetter; 24 class URLRequestContextGetter;
30 } 25 }
31 26
32 namespace speech { 27 namespace content {
33 28
34 class AudioChunk; 29 class AudioChunk;
30 struct SpeechRecognitionError;
31 struct SpeechRecognitionResult;
35 32
36 // Implements a SpeechRecognitionEngine supporting continuous recognition by 33 // Implements a SpeechRecognitionEngine supporting continuous recognition by
37 // means of interaction with Google streaming speech recognition webservice. 34 // means of interaction with Google streaming speech recognition webservice.
38 // More in details, this class establishes two HTTP(S) connections with the 35 // More in details, this class establishes two HTTP(S) connections with the
39 // webservice, for each session, herein called "upstream" and "downstream". 36 // webservice, for each session, herein called "upstream" and "downstream".
40 // Audio chunks are sent on the upstream by means of a chunked HTTP POST upload. 37 // Audio chunks are sent on the upstream by means of a chunked HTTP POST upload.
41 // Recognition results are retrieved in a full-duplex fashion (i.e. while 38 // Recognition results are retrieved in a full-duplex fashion (i.e. while
42 // pushing audio on the upstream) on the downstream by means of a chunked 39 // pushing audio on the upstream) on the downstream by means of a chunked
43 // HTTP GET request. Pairing between the two stream is handled through a 40 // HTTP GET request. Pairing between the two stream is handled through a
44 // randomly generated key, unique for each request, which is passed in the 41 // randomly generated key, unique for each request, which is passed in the
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 128
132 // The methods below handle transitions of the recognizer FSM. 129 // The methods below handle transitions of the recognizer FSM.
133 FSMState ConnectBothStreams(const FSMEventArgs& event_args); 130 FSMState ConnectBothStreams(const FSMEventArgs& event_args);
134 FSMState TransmitAudioUpstream(const FSMEventArgs& event_args); 131 FSMState TransmitAudioUpstream(const FSMEventArgs& event_args);
135 FSMState ProcessDownstreamResponse(const FSMEventArgs& event_args); 132 FSMState ProcessDownstreamResponse(const FSMEventArgs& event_args);
136 FSMState RaiseNoMatchErrorIfGotNoResults(const FSMEventArgs& event_args); 133 FSMState RaiseNoMatchErrorIfGotNoResults(const FSMEventArgs& event_args);
137 FSMState CloseUpstreamAndWaitForResults(const FSMEventArgs& event_args); 134 FSMState CloseUpstreamAndWaitForResults(const FSMEventArgs& event_args);
138 FSMState CloseDownstream(const FSMEventArgs& event_args); 135 FSMState CloseDownstream(const FSMEventArgs& event_args);
139 FSMState AbortSilently(const FSMEventArgs& event_args); 136 FSMState AbortSilently(const FSMEventArgs& event_args);
140 FSMState AbortWithError(const FSMEventArgs& event_args); 137 FSMState AbortWithError(const FSMEventArgs& event_args);
141 FSMState Abort(content::SpeechRecognitionErrorCode error); 138 FSMState Abort(SpeechRecognitionErrorCode error);
142 FSMState DoNothing(const FSMEventArgs& event_args); 139 FSMState DoNothing(const FSMEventArgs& event_args);
143 FSMState NotFeasible(const FSMEventArgs& event_args); 140 FSMState NotFeasible(const FSMEventArgs& event_args);
144 141
145 std::string GetAcceptedLanguages() const; 142 std::string GetAcceptedLanguages() const;
146 std::string GenerateRequestKey() const; 143 std::string GenerateRequestKey() const;
147 144
148 SpeechRecognitionEngineConfig config_; 145 SpeechRecognitionEngineConfig config_;
149 scoped_ptr<net::URLFetcher> upstream_fetcher_; 146 scoped_ptr<net::URLFetcher> upstream_fetcher_;
150 scoped_ptr<net::URLFetcher> downstream_fetcher_; 147 scoped_ptr<net::URLFetcher> downstream_fetcher_;
151 scoped_refptr<net::URLRequestContextGetter> url_context_; 148 scoped_refptr<net::URLRequestContextGetter> url_context_;
152 scoped_ptr<AudioEncoder> encoder_; 149 scoped_ptr<AudioEncoder> encoder_;
153 ChunkedByteBuffer chunked_byte_buffer_; 150 ChunkedByteBuffer chunked_byte_buffer_;
154 size_t previous_response_length_; 151 size_t previous_response_length_;
155 bool got_last_definitive_result_; 152 bool got_last_definitive_result_;
156 bool is_dispatching_event_; 153 bool is_dispatching_event_;
157 FSMState state_; 154 FSMState state_;
158 155
159 DISALLOW_COPY_AND_ASSIGN(GoogleStreamingRemoteEngine); 156 DISALLOW_COPY_AND_ASSIGN(GoogleStreamingRemoteEngine);
160 }; 157 };
161 158
162 } // namespace speech 159 } // namespace content
163 160
164 #endif // CONTENT_BROWSER_SPEECH_GOOGLE_STREAMING_REMOTE_ENGINE_H_ 161 #endif // CONTENT_BROWSER_SPEECH_GOOGLE_STREAMING_REMOTE_ENGINE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698