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

Side by Side Diff: content/browser/renderer_host/media/video_capture_manager.cc

Issue 899943004: Fix race when setting Desktop window id. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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/browser/renderer_host/media/video_capture_manager.h" 5 #include "content/browser/renderer_host/media/video_capture_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 void VideoCaptureManager::DoStopDevice(DeviceEntry* entry) { 273 void VideoCaptureManager::DoStopDevice(DeviceEntry* entry) {
274 DCHECK_CURRENTLY_ON(BrowserThread::IO); 274 DCHECK_CURRENTLY_ON(BrowserThread::IO);
275 DCHECK(std::find(devices_.begin(), devices_.end(), entry) != devices_.end()); 275 DCHECK(std::find(devices_.begin(), devices_.end(), entry) != devices_.end());
276 276
277 // Find the matching start request. 277 // Find the matching start request.
278 for (DeviceStartQueue::reverse_iterator request = 278 for (DeviceStartQueue::reverse_iterator request =
279 device_start_queue_.rbegin(); 279 device_start_queue_.rbegin();
280 request != device_start_queue_.rend(); ++request) { 280 request != device_start_queue_.rend(); ++request) {
281 if (request->serial_id() == entry->serial_id) { 281 if (request->serial_id() == entry->serial_id) {
282 request->set_abort_start(); 282 request->set_abort_start();
283 // This is a CHECK to make sure the media::VideoCaptureDevice is not
284 // deleted on the wrong thread if |entry| is deleted.
285 CHECK(entry->video_capture_device() == NULL);
Sergey Ulanov 2015/02/05 18:52:06 I think it's better to add a CHECK in ~DesktopCapt
perkj_chrome 2015/02/06 13:04:26 How about in ~DeviceEntry to catch all types of ca
283 DVLOG(3) << "DoStopDevice, aborting start request for device " 286 DVLOG(3) << "DoStopDevice, aborting start request for device "
284 << entry->id << " serial_id = " << entry->serial_id; 287 << entry->id << " serial_id = " << entry->serial_id;
285 return; 288 return;
286 } 289 }
287 } 290 }
288 291
289 DVLOG(3) << "DoStopDevice. Send stop request for device = " << entry->id 292 DVLOG(3) << "DoStopDevice. Send stop request for device = " << entry->id
290 << " serial_id = " << entry->serial_id << "."; 293 << " serial_id = " << entry->serial_id << ".";
291 if (entry->video_capture_device()) { 294 if (entry->video_capture_device()) {
292 // |entry->video_capture_device| can be null if creating the device fails. 295 // |entry->video_capture_device| can be null if creating the device fails.
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 return; 646 return;
644 } 647 }
645 648
646 // Post |existing_device->video_capture_device| to the VideoCaptureDevice to 649 // Post |existing_device->video_capture_device| to the VideoCaptureDevice to
647 // the device_task_runner_. This is safe since the device is destroyed on the 650 // the device_task_runner_. This is safe since the device is destroyed on the
648 // device_task_runner_. 651 // device_task_runner_.
649 device_task_runner_->PostTask( 652 device_task_runner_->PostTask(
650 FROM_HERE, 653 FROM_HERE,
651 base::Bind(&VideoCaptureManager::SetDesktopCaptureWindowIdOnDeviceThread, 654 base::Bind(&VideoCaptureManager::SetDesktopCaptureWindowIdOnDeviceThread,
652 this, 655 this,
653 existing_device->video_capture_device(), 656 existing_device->video_capture_device(),
Sergey Ulanov 2015/02/05 18:52:06 can this be NULL?
perkj_chrome 2015/02/06 13:04:26 Hmm, maybe that is the issue. video_capture_devic
654 window_id)); 657 window_id));
655 } 658 }
656 659
657 void VideoCaptureManager::DoStopDeviceOnDeviceThread( 660 void VideoCaptureManager::DoStopDeviceOnDeviceThread(
658 scoped_ptr<media::VideoCaptureDevice> device) { 661 scoped_ptr<media::VideoCaptureDevice> device) {
659 SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StopDeviceTime"); 662 SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StopDeviceTime");
660 DCHECK(IsOnDeviceThread()); 663 DCHECK(IsOnDeviceThread());
661 device->StopAndDeAllocate(); 664 device->StopAndDeAllocate();
662 DVLOG(3) << "DoStopDeviceOnDeviceThread"; 665 DVLOG(3) << "DoStopDeviceOnDeviceThread";
663 } 666 }
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 gfx::NativeViewId window_id) { 857 gfx::NativeViewId window_id) {
855 DCHECK(IsOnDeviceThread()); 858 DCHECK(IsOnDeviceThread());
856 DCHECK(notification_window_ids_.find(session_id) == 859 DCHECK(notification_window_ids_.find(session_id) ==
857 notification_window_ids_.end()); 860 notification_window_ids_.end());
858 notification_window_ids_[session_id] = window_id; 861 notification_window_ids_[session_id] = window_id;
859 VLOG(2) << "Screen capture notification window saved for session " 862 VLOG(2) << "Screen capture notification window saved for session "
860 << session_id << " on device thread."; 863 << session_id << " on device thread.";
861 } 864 }
862 865
863 } // namespace content 866 } // 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