| 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);
|
|
|