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

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

Issue 9386020: delete the corresponding controller when a capture device is closed. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« 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 <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 media::VideoCaptureDevice* video_capture_device = NULL; 201 media::VideoCaptureDevice* video_capture_device = NULL;
202 VideoCaptureDevices::iterator it = devices_.find(capture_session_id); 202 VideoCaptureDevices::iterator it = devices_.find(capture_session_id);
203 if (it != devices_.end()) { 203 if (it != devices_.end()) {
204 video_capture_device = it->second; 204 video_capture_device = it->second;
205 devices_.erase(it); 205 devices_.erase(it);
206 } 206 }
207 if (video_capture_device && !DeviceInUse(video_capture_device)) { 207 if (video_capture_device && !DeviceInUse(video_capture_device)) {
208 // Deallocate (if not done already) and delete the device. 208 // Deallocate (if not done already) and delete the device.
209 video_capture_device->DeAllocate(); 209 video_capture_device->DeAllocate();
210 Controllers::iterator cit = controllers_.find(video_capture_device);
211 if (cit != controllers_.end()) {
212 delete cit->second;
213 controllers_.erase(cit);
214 }
210 delete video_capture_device; 215 delete video_capture_device;
211 } 216 }
212 217
213 PostOnClosed(capture_session_id); 218 PostOnClosed(capture_session_id);
214 } 219 }
215 220
216 void VideoCaptureManager::OnStart( 221 void VideoCaptureManager::OnStart(
217 const media::VideoCaptureParams capture_params, 222 const media::VideoCaptureParams capture_params,
218 media::VideoCaptureDevice::EventHandler* video_capture_receiver) { 223 media::VideoCaptureDevice::EventHandler* video_capture_receiver) {
219 DCHECK(IsOnCaptureDeviceThread()); 224 DCHECK(IsOnCaptureDeviceThread());
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 for (VideoCaptureDevices::iterator it = devices_.begin(); 516 for (VideoCaptureDevices::iterator it = devices_.begin();
512 it != devices_.end(); ++it) { 517 it != devices_.end(); ++it) {
513 it->second->DeAllocate(); 518 it->second->DeAllocate();
514 devices_to_delete.insert(it->second); 519 devices_to_delete.insert(it->second);
515 } 520 }
516 STLDeleteElements(&devices_to_delete); 521 STLDeleteElements(&devices_to_delete);
517 STLDeleteValues(&controllers_); 522 STLDeleteValues(&controllers_);
518 } 523 }
519 524
520 } // namespace media_stream 525 } // namespace media_stream
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