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

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

Issue 2447263002: 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 f86009aefed82fc268dcaa99a0e31868d7a13577..c3a7b8ac6797371a5608de1628023e23967040ae 100644
--- a/content/browser/renderer_host/media/video_capture_manager.cc
+++ b/content/browser/renderer_host/media/video_capture_manager.cc
@@ -655,8 +655,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);
@@ -708,21 +707,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.
+ 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