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

Side by Side Diff: content/browser/speech/speech_recognition_manager_impl.cc

Issue 1891543002: Devirtualize SpeechRecognitionEngine (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@kill_one_shot_engine
Patch Set: drop an include Created 4 years, 8 months 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #include "content/browser/speech/speech_recognition_manager_impl.h" 5 #include "content/browser/speech/speech_recognition_manager_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/single_thread_task_runner.h" 11 #include "base/single_thread_task_runner.h"
12 #include "base/thread_task_runner_handle.h" 12 #include "base/thread_task_runner_handle.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "content/browser/browser_main_loop.h" 14 #include "content/browser/browser_main_loop.h"
15 #include "content/browser/renderer_host/media/media_stream_manager.h" 15 #include "content/browser/renderer_host/media/media_stream_manager.h"
16 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" 16 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h"
17 #include "content/browser/speech/google_streaming_remote_engine.h"
18 #include "content/browser/speech/speech_recognition_engine.h" 17 #include "content/browser/speech/speech_recognition_engine.h"
19 #include "content/browser/speech/speech_recognizer_impl.h" 18 #include "content/browser/speech/speech_recognizer_impl.h"
20 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
21 #include "content/public/browser/content_browser_client.h" 20 #include "content/public/browser/content_browser_client.h"
22 #include "content/public/browser/resource_context.h" 21 #include "content/public/browser/resource_context.h"
23 #include "content/public/browser/speech_recognition_event_listener.h" 22 #include "content/public/browser/speech_recognition_event_listener.h"
24 #include "content/public/browser/speech_recognition_manager_delegate.h" 23 #include "content/public/browser/speech_recognition_manager_delegate.h"
25 #include "content/public/browser/speech_recognition_session_config.h" 24 #include "content/public/browser/speech_recognition_session_config.h"
26 #include "content/public/browser/speech_recognition_session_context.h" 25 #include "content/public/browser/speech_recognition_session_context.h"
27 #include "content/public/common/speech_recognition_error.h" 26 #include "content/public/common/speech_recognition_error.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 delegate_->GetDiagnosticInformation(&can_report_metrics, &hardware_info); 112 delegate_->GetDiagnosticInformation(&can_report_metrics, &hardware_info);
114 113
115 #if !defined(OS_ANDROID) 114 #if !defined(OS_ANDROID)
116 // A SpeechRecognitionEngine (and corresponding Config) is required only 115 // A SpeechRecognitionEngine (and corresponding Config) is required only
117 // when using SpeechRecognizerImpl, which performs the audio capture and 116 // when using SpeechRecognizerImpl, which performs the audio capture and
118 // endpointing in the browser. This is not the case of Android where, not 117 // endpointing in the browser. This is not the case of Android where, not
119 // only the speech recognition, but also the audio capture and endpointing 118 // only the speech recognition, but also the audio capture and endpointing
120 // activities performed outside of the browser (delegated via JNI to the 119 // activities performed outside of the browser (delegated via JNI to the
121 // Android API implementation). 120 // Android API implementation).
122 121
123 SpeechRecognitionEngineConfig remote_engine_config; 122 SpeechRecognitionEngine::Config remote_engine_config;
124 remote_engine_config.language = config.language; 123 remote_engine_config.language = config.language;
125 remote_engine_config.grammars = config.grammars; 124 remote_engine_config.grammars = config.grammars;
126 remote_engine_config.audio_sample_rate = 125 remote_engine_config.audio_sample_rate =
127 SpeechRecognizerImpl::kAudioSampleRate; 126 SpeechRecognizerImpl::kAudioSampleRate;
128 remote_engine_config.audio_num_bits_per_sample = 127 remote_engine_config.audio_num_bits_per_sample =
129 SpeechRecognizerImpl::kNumBitsPerAudioSample; 128 SpeechRecognizerImpl::kNumBitsPerAudioSample;
130 remote_engine_config.filter_profanities = config.filter_profanities; 129 remote_engine_config.filter_profanities = config.filter_profanities;
131 remote_engine_config.continuous = config.continuous; 130 remote_engine_config.continuous = config.continuous;
132 remote_engine_config.interim_results = config.interim_results; 131 remote_engine_config.interim_results = config.interim_results;
133 remote_engine_config.max_hypotheses = config.max_hypotheses; 132 remote_engine_config.max_hypotheses = config.max_hypotheses;
134 remote_engine_config.hardware_info = hardware_info; 133 remote_engine_config.hardware_info = hardware_info;
135 remote_engine_config.origin_url = config.origin_url; 134 remote_engine_config.origin_url = config.origin_url;
136 remote_engine_config.auth_token = config.auth_token; 135 remote_engine_config.auth_token = config.auth_token;
137 remote_engine_config.auth_scope = config.auth_scope; 136 remote_engine_config.auth_scope = config.auth_scope;
138 remote_engine_config.preamble = config.preamble; 137 remote_engine_config.preamble = config.preamble;
139 138
140 SpeechRecognitionEngine* google_remote_engine = 139 SpeechRecognitionEngine* google_remote_engine =
141 new GoogleStreamingRemoteEngine(config.url_request_context_getter.get()); 140 new SpeechRecognitionEngine(config.url_request_context_getter.get());
142 google_remote_engine->SetConfig(remote_engine_config); 141 google_remote_engine->SetConfig(remote_engine_config);
143 142
144 session->recognizer = new SpeechRecognizerImpl( 143 session->recognizer = new SpeechRecognizerImpl(
145 this, 144 this,
146 session_id, 145 session_id,
147 config.continuous, 146 config.continuous,
148 config.interim_results, 147 config.interim_results,
149 google_remote_engine); 148 google_remote_engine);
150 #else 149 #else
151 session->recognizer = new SpeechRecognizerImplAndroid(this, session_id); 150 session->recognizer = new SpeechRecognizerImplAndroid(this, session_id);
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 SpeechRecognitionManagerImpl::Session::Session() 672 SpeechRecognitionManagerImpl::Session::Session()
674 : id(kSessionIDInvalid), 673 : id(kSessionIDInvalid),
675 abort_requested(false), 674 abort_requested(false),
676 listener_is_active(true) { 675 listener_is_active(true) {
677 } 676 }
678 677
679 SpeechRecognitionManagerImpl::Session::~Session() { 678 SpeechRecognitionManagerImpl::Session::~Session() {
680 } 679 }
681 680
682 } // namespace content 681 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698