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

Unified Diff: content/browser/renderer_host/media/video_capture_manager.cc

Issue 2417383002: VideoCaptureManager: fixed double-deletion bug in StopCaptureForClient() on error (Closed)
Patch Set: Created 4 years, 2 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: content/browser/renderer_host/media/video_capture_manager.cc
diff --git a/content/browser/renderer_host/media/video_capture_manager.cc b/content/browser/renderer_host/media/video_capture_manager.cc
index 7cd548ab0f0eb1f194216c125eb63ec85ae58d05..d83a3bfb9e8b89e214cbb8f98ffabb31011447b9 100644
--- a/content/browser/renderer_host/media/video_capture_manager.cc
+++ b/content/browser/renderer_host/media/video_capture_manager.cc
@@ -659,8 +659,7 @@ void VideoCaptureManager::StartCaptureForClient(
VideoCaptureControllerEventHandler* client_handler,
const DoneCB& done_cb) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- DVLOG(1) << "VideoCaptureManager::StartCaptureForClient #" << session_id
- << ", request: "
+ DVLOG(1) << __func__ << ", session_id = " << session_id << ", request: "
<< media::VideoCaptureFormat::ToString(params.requested_format);
DeviceEntry* entry = GetOrCreateDeviceEntry(session_id, params);
@@ -712,21 +711,22 @@ void VideoCaptureManager::StopCaptureForClient(
}
} else {
LogVideoCaptureEvent(VIDEO_CAPTURE_STOP_CAPTURE_DUE_TO_ERROR);
- SessionMap::iterator it;
- for (it = sessions_.begin(); it != sessions_.end(); ++it) {
- if (it->second.type == entry->stream_type &&
- it->second.id == entry->id) {
- listener_->Aborted(it->second.type, it->first);
+ for (auto it : sessions_) {
+ if (it.second.type == entry->stream_type && it.second.id == entry->id) {
+ listener_->Aborted(it.second.type, it.first);
+ // Aborted() call might synchronously destroy |entry|, recheck.
xianglu 2016/10/14 23:28:22 If the entry is always going to be deleted after A
mcasas 2016/10/14 23:44:10 The |entry| might still be alive if there's more t
+ entry = GetDeviceEntryByController(controller);
+ if (!entry)
+ return;
break;
}
}
}
// Detach client from controller.
- media::VideoCaptureSessionId session_id =
+ const media::VideoCaptureSessionId session_id =
controller->RemoveClient(client_id, client_handler);
- DVLOG(1) << "VideoCaptureManager::StopCaptureForClient, session_id = "
- << session_id;
+ DVLOG(1) << __func__ << ", session_id = " << session_id;
// If controller has no more clients, delete controller and device.
DestroyDeviceEntryIfNoClients(entry);
« 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