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/speech_recognition_engine.h" | 10 #include "content/browser/speech/speech_recognition_engine.h" |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
320 AbortSession(session.id); | 320 AbortSession(session.id); |
321 session.listener_is_active = false; | 321 session.listener_is_active = false; |
322 } | 322 } |
323 } | 323 } |
324 } | 324 } |
325 | 325 |
326 // ----------------------- Core FSM implementation --------------------------- | 326 // ----------------------- Core FSM implementation --------------------------- |
327 void SpeechRecognitionManagerImpl::DispatchEvent(int session_id, | 327 void SpeechRecognitionManagerImpl::DispatchEvent(int session_id, |
328 FSMEvent event) { | 328 FSMEvent event) { |
329 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 329 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
330 | |
331 // There are some corner cases in which the session might be deleted (due to | |
332 // an EndRecognition event) between a request (e.g. Abort) and its dispatch. | |
Satish
2012/05/20 21:40:26
In any of these cases, does the caller need to be
Primiano Tucci (use gerrit)
2012/05/21 16:03:13
As a general reply, every caller (delegate) receiv
| |
333 if (!SessionExists(session_id)) | |
334 return; | |
335 | |
330 const Session& session = GetSession(session_id); | 336 const Session& session = GetSession(session_id); |
331 FSMState session_state = GetSessionState(session_id); | 337 FSMState session_state = GetSessionState(session_id); |
332 DCHECK_LE(session_state, SESSION_STATE_MAX_VALUE); | 338 DCHECK_LE(session_state, SESSION_STATE_MAX_VALUE); |
333 DCHECK_LE(event, EVENT_MAX_VALUE); | 339 DCHECK_LE(event, EVENT_MAX_VALUE); |
334 | 340 |
335 // Event dispatching must be sequential, otherwise it will break all the rules | 341 // Event dispatching must be sequential, otherwise it will break all the rules |
336 // and the assumptions of the finite state automata model. | 342 // and the assumptions of the finite state automata model. |
337 DCHECK(!is_dispatching_event_); | 343 DCHECK(!is_dispatching_event_); |
338 is_dispatching_event_ = true; | 344 is_dispatching_event_ = true; |
339 ExecuteTransitionAndGetNextState(session, session_state, event); | 345 ExecuteTransitionAndGetNextState(session, session_state, event); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
518 | 524 |
519 SpeechRecognitionManagerImpl::Session::Session() | 525 SpeechRecognitionManagerImpl::Session::Session() |
520 : id(kSessionIDInvalid), | 526 : id(kSessionIDInvalid), |
521 listener_is_active(true) { | 527 listener_is_active(true) { |
522 } | 528 } |
523 | 529 |
524 SpeechRecognitionManagerImpl::Session::~Session() { | 530 SpeechRecognitionManagerImpl::Session::~Session() { |
525 } | 531 } |
526 | 532 |
527 } // namespace speech | 533 } // namespace speech |
OLD | NEW |