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

Side by Side Diff: content/renderer/media/media_stream_dispatcher.cc

Issue 2035993002: Avoid double deleting from |MediaStreamDispatcher::label_stream_map_|. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/media_stream_dispatcher.h" 5 #include "content/renderer/media/media_stream_dispatcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "content/common/media/media_stream_messages.h" 10 #include "content/common/media/media_stream_messages.h"
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 } 345 }
346 Stream* stream = &it->second; 346 Stream* stream = &it->second;
347 if (IsAudioInputMediaType(device_info.device.type)) 347 if (IsAudioInputMediaType(device_info.device.type))
348 RemoveStreamDeviceFromArray(device_info, &stream->audio_array); 348 RemoveStreamDeviceFromArray(device_info, &stream->audio_array);
349 else 349 else
350 RemoveStreamDeviceFromArray(device_info, &stream->video_array); 350 RemoveStreamDeviceFromArray(device_info, &stream->video_array);
351 351
352 if (stream->handler.get()) 352 if (stream->handler.get())
353 stream->handler->OnDeviceStopped(label, device_info); 353 stream->handler->OnDeviceStopped(label, device_info);
354 354
355 // |it| could have already been invalidated in the function call above. So we
356 // need to check if |label| is still in |label_stream_map_| again.
357 // Note: this is a quick fix to the crash caused by erasing the invalidated
358 // iterator from |label_stream_map_| (crbug.com/616884). Future work needs to
359 // be done to resolve this re-entering issue.
miu 2016/06/04 04:30:01 s/re-entering/re-entrancy/
xjz 2016/06/06 17:09:53 Done.
360 it = label_stream_map_.find(label);
361 if (it == label_stream_map_.end())
362 return;
363 stream = &it->second;
355 if (stream->audio_array.empty() && stream->video_array.empty()) 364 if (stream->audio_array.empty() && stream->video_array.empty())
356 label_stream_map_.erase(it); 365 label_stream_map_.erase(it);
357 } 366 }
358 367
359 void MediaStreamDispatcher::OnDevicesEnumerated( 368 void MediaStreamDispatcher::OnDevicesEnumerated(
360 int request_id, 369 int request_id,
361 const StreamDeviceInfoArray& device_array) { 370 const StreamDeviceInfoArray& device_array) {
362 DCHECK(thread_checker_.CalledOnValidThread()); 371 DCHECK(thread_checker_.CalledOnValidThread());
363 DCHECK_GE(request_id, 0); 372 DCHECK_GE(request_id, 0);
364 373
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 DCHECK(thread_checker_.CalledOnValidThread()); 456 DCHECK(thread_checker_.CalledOnValidThread());
448 LabelStreamMap::iterator it = label_stream_map_.find(label); 457 LabelStreamMap::iterator it = label_stream_map_.find(label);
449 if (it == label_stream_map_.end() || 458 if (it == label_stream_map_.end() ||
450 it->second.video_array.size() <= static_cast<size_t>(index)) { 459 it->second.video_array.size() <= static_cast<size_t>(index)) {
451 return StreamDeviceInfo::kNoId; 460 return StreamDeviceInfo::kNoId;
452 } 461 }
453 return it->second.video_array[index].session_id; 462 return it->second.video_array[index].session_id;
454 } 463 }
455 464
456 } // namespace content 465 } // namespace content
OLDNEW
« 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