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

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

Issue 10867049: fix browser crash when closing 2 or more tabs running getUserMedia (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 | « no previous file | 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 c57ef7072ac4d8bf731075491a729f50339a089c..4bedce6a01adead9e48646dd5a32c836a22a7ac0 100644
--- a/chrome/browser/media/media_stream_capture_indicator.cc
+++ b/chrome/browser/media/media_stream_capture_indicator.cc
@@ -423,28 +423,28 @@ void MediaStreamCaptureIndicator::RemoveCaptureDeviceTab(
int render_view_id,
const content::MediaStreamDevices& devices) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
CaptureDeviceTabs::iterator iter = std::find_if(
tabs_.begin(), tabs_.end(), TabEquals(render_process_id, render_view_id));
- DCHECK(iter != tabs_.end());
- content::MediaStreamDevices::const_iterator dev = devices.begin();
- for (; dev != devices.end(); ++dev) {
- DCHECK(dev->type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE ||
- dev->type == content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE);
- if (dev->type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE)
- --iter->audio_ref_count;
- else
- --iter->video_ref_count;
+ if (iter != tabs_.end()) {
Ami GONE FROM CHROMIUM 2012/08/24 17:57:57 Do you understand how it can happen that this is =
no longer working on chromium 2012/08/24 18:09:58 Yes. This happens when we have multiple tabs using
+ content::MediaStreamDevices::const_iterator dev = devices.begin();
+ for (; dev != devices.end(); ++dev) {
+ DCHECK(dev->type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE ||
+ dev->type == content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE);
+ if (dev->type == content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE)
+ --iter->audio_ref_count;
+ else
+ --iter->video_ref_count;
+
+ DCHECK_GE(iter->audio_ref_count, 0);
+ DCHECK_GE(iter->video_ref_count, 0);
+ }
- DCHECK_GE(iter->audio_ref_count, 0);
- DCHECK_GE(iter->video_ref_count, 0);
+ // Remove the tab if all the devices have been closed.
+ if (iter->audio_ref_count == 0 && iter->video_ref_count == 0)
+ tabs_.erase(iter);
}
- // Remove the tab if all the devices have been closed.
- if (iter->audio_ref_count == 0 && iter->video_ref_count == 0)
- tabs_.erase(iter);
-
UpdateStatusTrayIconContextMenu();
Ami GONE FROM CHROMIUM 2012/08/24 17:57:57 Do you want to do this even if iter==tabs_.end() (
no longer working on chromium 2012/08/24 18:09:58 Good question, I think both ways work the same. Bu
Ami GONE FROM CHROMIUM 2012/08/24 18:21:41 I don't know the code to make a call. It's up to
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698