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