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

Unified Diff: chrome/browser/media/media_stream_capture_indicator.cc

Issue 10825313: MediaStreamCaptureIndicator: fix crash due to destruction on wrong thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/media/media_stream_capture_indicator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/media/media_stream_capture_indicator.cc
diff --git a/chrome/browser/media/media_stream_capture_indicator.cc b/chrome/browser/media/media_stream_capture_indicator.cc
index 68d56432d159b180f53138cd8b54fd3233c8925e..e937ceefa3cfca4626ae03557112d7400914ac8c 100644
--- a/chrome/browser/media/media_stream_capture_indicator.cc
+++ b/chrome/browser/media/media_stream_capture_indicator.cc
@@ -122,7 +122,6 @@ MediaStreamCaptureIndicator::MediaStreamCaptureIndicator()
mic_image_(NULL),
camera_image_(NULL),
balloon_image_(NULL),
- ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)),
request_index_(0) {
}
@@ -275,7 +274,8 @@ void MediaStreamCaptureIndicator::ShowBalloon(
pending_messages_[request_index_++] =
l10n_util::GetStringFUTF16(message_id,
UTF8ToUTF16(extension->name()));
- tracker_.LoadImage(
+ EnsureImageLoadingTracker();
+ tracker_->LoadImage(
extension,
extension->GetIconResource(32, ExtensionIconSet::MATCH_BIGGER),
gfx::Size(32, 32),
@@ -307,6 +307,10 @@ void MediaStreamCaptureIndicator::OnImageLoaded(
void MediaStreamCaptureIndicator::Hide() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ // We have to destroy |tracker_| on the UI thread.
+ tracker_.reset();
+
if (!status_icon_)
return;
@@ -445,3 +449,12 @@ void MediaStreamCaptureIndicator::RemoveCaptureDeviceTab(
UpdateStatusTrayIconContextMenu();
}
+void MediaStreamCaptureIndicator::EnsureImageLoadingTracker() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (tracker_.get())
+ return;
+
+ tracker_.reset(new ImageLoadingTracker(this));
+ pending_messages_.clear();
+ request_index_ = 0;
+}
« no previous file with comments | « chrome/browser/media/media_stream_capture_indicator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698