| OLD | NEW |
| 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 #include "content/browser/speech/speech_recognition_manager_impl.h" | 5 #include "content/browser/speech/speech_recognition_manager_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "content/browser/browser_main_loop.h" | 8 #include "content/browser/browser_main_loop.h" |
| 9 #include "content/browser/speech/google_one_shot_remote_engine.h" | 9 #include "content/browser/speech/google_one_shot_remote_engine.h" |
| 10 #include "content/browser/speech/google_streaming_remote_engine.h" | 10 #include "content/browser/speech/google_streaming_remote_engine.h" |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 for (SessionsTable::iterator it = sessions_.begin(); it != sessions_.end(); | 332 for (SessionsTable::iterator it = sessions_.begin(); it != sessions_.end(); |
| 333 ++it) { | 333 ++it) { |
| 334 Session& session = it->second; | 334 Session& session = it->second; |
| 335 if (session.config.event_listener == listener) { | 335 if (session.config.event_listener == listener) { |
| 336 AbortSession(session.id); | 336 AbortSession(session.id); |
| 337 session.listener_is_active = false; | 337 session.listener_is_active = false; |
| 338 } | 338 } |
| 339 } | 339 } |
| 340 } | 340 } |
| 341 | 341 |
| 342 void SpeechRecognitionManagerImpl::AbortAllSessionsForRenderer( |
| 343 int render_process_id, int render_view_id) { |
| 344 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 345 for (SessionsTable::iterator it = sessions_.begin(); it != sessions_.end(); |
| 346 ++it) { |
| 347 Session& session = it->second; |
| 348 if (session.context.render_process_id == render_process_id && |
| 349 session.context.render_view_id == render_view_id) { |
| 350 AbortSession(session.id); |
| 351 } |
| 352 } |
| 353 } |
| 354 |
| 342 // ----------------------- Core FSM implementation --------------------------- | 355 // ----------------------- Core FSM implementation --------------------------- |
| 343 void SpeechRecognitionManagerImpl::DispatchEvent(int session_id, | 356 void SpeechRecognitionManagerImpl::DispatchEvent(int session_id, |
| 344 FSMEvent event) { | 357 FSMEvent event) { |
| 345 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 358 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 346 | 359 |
| 347 // There are some corner cases in which the session might be deleted (due to | 360 // There are some corner cases in which the session might be deleted (due to |
| 348 // an EndRecognition event) between a request (e.g. Abort) and its dispatch. | 361 // an EndRecognition event) between a request (e.g. Abort) and its dispatch. |
| 349 if (!SessionExists(session_id)) | 362 if (!SessionExists(session_id)) |
| 350 return; | 363 return; |
| 351 | 364 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 | 543 |
| 531 SpeechRecognitionManagerImpl::Session::Session() | 544 SpeechRecognitionManagerImpl::Session::Session() |
| 532 : id(kSessionIDInvalid), | 545 : id(kSessionIDInvalid), |
| 533 listener_is_active(true) { | 546 listener_is_active(true) { |
| 534 } | 547 } |
| 535 | 548 |
| 536 SpeechRecognitionManagerImpl::Session::~Session() { | 549 SpeechRecognitionManagerImpl::Session::~Session() { |
| 537 } | 550 } |
| 538 | 551 |
| 539 } // namespace speech | 552 } // namespace speech |
| OLD | NEW |