summaryrefslogtreecommitdiffstats
path: root/chrome/browser/speech
diff options
context:
space:
mode:
authorsatish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-01 14:28:51 +0000
committersatish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-01 14:28:51 +0000
commit19b88c5ddc50ae43b56fefd354f6bb26ef0937f0 (patch)
tree66398f6045f0f35561fa855a30101237ea7454ff /chrome/browser/speech
parent268f64bdabe6917c676f04fe1401bca55804af1b (diff)
downloadchromium_src-19b88c5ddc50ae43b56fefd354f6bb26ef0937f0.zip
chromium_src-19b88c5ddc50ae43b56fefd354f6bb26ef0937f0.tar.gz
chromium_src-19b88c5ddc50ae43b56fefd354f6bb26ef0937f0.tar.bz2
Fix data race in destroying the info bubble.
The info bubble is a member variable of the class and the controller class's lifetime is managed in the IO thread. However the info bubble's lifetime is managed in the UI thread and in this case it was not destroyed before the IO thread was notified of the event. So the IO thread could process the notification and destroy the controller object before it finished with releasing the bubble. This change destroys the bubble before notifying the delegate to prevent such cases. BUG=53765 TEST=running unit_tests --gtest_filter="*Speech*Cancelled*" under RaceChecker should find no data races. Review URL: http://codereview.chromium.org/3328001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58169 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/speech')
-rw-r--r--chrome/browser/speech/speech_input_bubble_controller.cc18
1 files changed, 12 insertions, 6 deletions
diff --git a/chrome/browser/speech/speech_input_bubble_controller.cc b/chrome/browser/speech/speech_input_bubble_controller.cc
index 98bf620..6b7c650 100644
--- a/chrome/browser/speech/speech_input_bubble_controller.cc
+++ b/chrome/browser/speech/speech_input_bubble_controller.cc
@@ -74,26 +74,32 @@ void SpeechInputBubbleController::SetBubbleToRecognizingMode(int caller_id) {
void SpeechInputBubbleController::RecognitionCancelled() {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
+
+ int old_bubble_caller_id = current_bubble_caller_id_;
+ current_bubble_caller_id_ = 0;
+ bubble_.reset();
+
ChromeThread::PostTask(
ChromeThread::IO, FROM_HERE,
NewRunnableMethod(
this,
&SpeechInputBubbleController::InvokeDelegateRecognitionCancelled,
- current_bubble_caller_id_));
- current_bubble_caller_id_ = 0;
- bubble_.reset();
+ old_bubble_caller_id));
}
void SpeechInputBubbleController::InfoBubbleClosed() {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
+
+ int old_bubble_caller_id = current_bubble_caller_id_;
+ current_bubble_caller_id_ = 0;
+ bubble_.reset();
+
ChromeThread::PostTask(
ChromeThread::IO, FROM_HERE,
NewRunnableMethod(
this,
&SpeechInputBubbleController::InvokeDelegateFocusChanged,
- current_bubble_caller_id_));
- current_bubble_caller_id_ = 0;
- bubble_.reset();
+ old_bubble_caller_id));
}
void SpeechInputBubbleController::InvokeDelegateRecognitionCancelled(