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

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

Issue 9320070: Re-added OnChannelClosing in MediaStreamDispatcherHost to close open media devices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Simplified according to chat with wjia. Created 8 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 side-by-side diff with in-line comments
Download patch
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 e65eb9d2c12c78c5e4603454fbd5f10478c3e070..9a42170cda28f704df49e861f9a14e1accb2be63 100644
--- a/content/browser/renderer_host/media/video_capture_manager.cc
+++ b/content/browser/renderer_host/media/video_capture_manager.cc
@@ -47,14 +47,11 @@ VideoCaptureManager::VideoCaptureManager()
}
VideoCaptureManager::~VideoCaptureManager() {
- // TODO(mflodman) Remove this temporary solution when shut-down issue is
- // resolved, i.e. all code below this comment.
- // Temporary solution: close all open devices and delete them, after the
- // thread is stopped.
- DLOG_IF(ERROR, !devices_.empty()) << "VideoCaptureManager: Open devices!";
+ DCHECK(devices_.empty());
+
+ // TODO(mflodman) Remove this temporary solution when all controllers are
+ // guaranteed to be deleted before the destructor is called.
listener_ = NULL;
- // The devices must be stopped on the device thread to avoid threading issues
- // in native device code.
vc_device_thread_.message_loop()->PostTask(
mflodman_chromium_OOO 2012/02/10 13:24:41 There is a case when |controllers_| won't be empty
FROM_HERE,
base::Bind(&VideoCaptureManager::TerminateOnDeviceThread,
@@ -199,17 +196,18 @@ void VideoCaptureManager::OnClose(int capture_session_id) {
DCHECK(IsOnCaptureDeviceThread());
media::VideoCaptureDevice* video_capture_device = NULL;
- VideoCaptureDevices::iterator it = devices_.find(capture_session_id);
- if (it != devices_.end()) {
- video_capture_device = it->second;
- devices_.erase(it);
- }
- if (video_capture_device && !DeviceInUse(video_capture_device)) {
- // Deallocate (if not done already) and delete the device.
- video_capture_device->DeAllocate();
- delete video_capture_device;
+ VideoCaptureDevices::iterator device_it = devices_.find(capture_session_id);
+ if (device_it != devices_.end()) {
+ video_capture_device = device_it->second;
+ devices_.erase(device_it);
+ if (!DeviceInUse(video_capture_device)) {
+ // No other users of this device, deallocate (if not done already) and
+ // delete the device. No need to take care of the controller, that is done
+ // by |OnStop|.
+ video_capture_device->DeAllocate();
+ delete video_capture_device;
+ }
}
-
PostOnClosed(capture_session_id);
}
@@ -506,14 +504,6 @@ media::VideoCaptureDevice* VideoCaptureManager::GetDeviceInternal(
void VideoCaptureManager::TerminateOnDeviceThread() {
DCHECK(IsOnCaptureDeviceThread());
-
- std::set<media::VideoCaptureDevice*> devices_to_delete;
- for (VideoCaptureDevices::iterator it = devices_.begin();
- it != devices_.end(); ++it) {
- it->second->DeAllocate();
- devices_to_delete.insert(it->second);
- }
- STLDeleteElements(&devices_to_delete);
STLDeleteValues(&controllers_);
}

Powered by Google App Engine
This is Rietveld 408576698