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

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

Issue 2447263002: VideoCaptureManager: fixed double-deletion bug in StopCaptureForClient() on error (Closed)
Patch Set: Created 4 years, 1 month 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 #include <utility> 9 #include <utility>
10 10
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 } 648 }
649 649
650 void VideoCaptureManager::StartCaptureForClient( 650 void VideoCaptureManager::StartCaptureForClient(
651 media::VideoCaptureSessionId session_id, 651 media::VideoCaptureSessionId session_id,
652 const media::VideoCaptureParams& params, 652 const media::VideoCaptureParams& params,
653 base::ProcessHandle client_render_process, 653 base::ProcessHandle client_render_process,
654 VideoCaptureControllerID client_id, 654 VideoCaptureControllerID client_id,
655 VideoCaptureControllerEventHandler* client_handler, 655 VideoCaptureControllerEventHandler* client_handler,
656 const DoneCB& done_cb) { 656 const DoneCB& done_cb) {
657 DCHECK_CURRENTLY_ON(BrowserThread::IO); 657 DCHECK_CURRENTLY_ON(BrowserThread::IO);
658 DVLOG(1) << "VideoCaptureManager::StartCaptureForClient #" << session_id 658 DVLOG(1) << __func__ << ", session_id = " << session_id << ", request: "
659 << ", request: "
660 << media::VideoCaptureFormat::ToString(params.requested_format); 659 << media::VideoCaptureFormat::ToString(params.requested_format);
661 660
662 DeviceEntry* entry = GetOrCreateDeviceEntry(session_id, params); 661 DeviceEntry* entry = GetOrCreateDeviceEntry(session_id, params);
663 if (!entry) { 662 if (!entry) {
664 done_cb.Run(base::WeakPtr<VideoCaptureController>()); 663 done_cb.Run(base::WeakPtr<VideoCaptureController>());
665 return; 664 return;
666 } 665 }
667 666
668 DCHECK(entry->video_capture_controller()); 667 DCHECK(entry->video_capture_controller());
669 668
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 LogVideoCaptureEvent(VIDEO_CAPTURE_STOP_CAPTURE_OK); 700 LogVideoCaptureEvent(VIDEO_CAPTURE_STOP_CAPTURE_OK);
702 } else if (entry->stream_type == MEDIA_DEVICE_VIDEO_CAPTURE) { 701 } else if (entry->stream_type == MEDIA_DEVICE_VIDEO_CAPTURE) {
703 LogVideoCaptureEvent( 702 LogVideoCaptureEvent(
704 VIDEO_CAPTURE_STOP_CAPTURE_OK_NO_FRAMES_PRODUCED_BY_DEVICE); 703 VIDEO_CAPTURE_STOP_CAPTURE_OK_NO_FRAMES_PRODUCED_BY_DEVICE);
705 } else { 704 } else {
706 LogVideoCaptureEvent( 705 LogVideoCaptureEvent(
707 VIDEO_CAPTURE_STOP_CAPTURE_OK_NO_FRAMES_PRODUCED_BY_DESKTOP_OR_TAB); 706 VIDEO_CAPTURE_STOP_CAPTURE_OK_NO_FRAMES_PRODUCED_BY_DESKTOP_OR_TAB);
708 } 707 }
709 } else { 708 } else {
710 LogVideoCaptureEvent(VIDEO_CAPTURE_STOP_CAPTURE_DUE_TO_ERROR); 709 LogVideoCaptureEvent(VIDEO_CAPTURE_STOP_CAPTURE_DUE_TO_ERROR);
711 SessionMap::iterator it; 710 for (auto it : sessions_) {
712 for (it = sessions_.begin(); it != sessions_.end(); ++it) { 711 if (it.second.type == entry->stream_type && it.second.id == entry->id) {
713 if (it->second.type == entry->stream_type && 712 listener_->Aborted(it.second.type, it.first);
714 it->second.id == entry->id) { 713 // Aborted() call might synchronously destroy |entry|, recheck.
715 listener_->Aborted(it->second.type, it->first); 714 entry = GetDeviceEntryByController(controller);
715 if (!entry)
716 return;
716 break; 717 break;
717 } 718 }
718 } 719 }
719 } 720 }
720 721
721 // Detach client from controller. 722 // Detach client from controller.
722 media::VideoCaptureSessionId session_id = 723 const media::VideoCaptureSessionId session_id =
723 controller->RemoveClient(client_id, client_handler); 724 controller->RemoveClient(client_id, client_handler);
724 DVLOG(1) << "VideoCaptureManager::StopCaptureForClient, session_id = " 725 DVLOG(1) << __func__ << ", session_id = " << session_id;
725 << session_id;
726 726
727 // If controller has no more clients, delete controller and device. 727 // If controller has no more clients, delete controller and device.
728 DestroyDeviceEntryIfNoClients(entry); 728 DestroyDeviceEntryIfNoClients(entry);
729 } 729 }
730 730
731 void VideoCaptureManager::PauseCaptureForClient( 731 void VideoCaptureManager::PauseCaptureForClient(
732 VideoCaptureController* controller, 732 VideoCaptureController* controller,
733 VideoCaptureControllerID client_id, 733 VideoCaptureControllerID client_id,
734 VideoCaptureControllerEventHandler* client_handler) { 734 VideoCaptureControllerEventHandler* client_handler) {
735 DCHECK_CURRENTLY_ON(BrowserThread::IO); 735 DCHECK_CURRENTLY_ON(BrowserThread::IO);
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 if (!device_in_queue) { 1282 if (!device_in_queue) {
1283 // Session ID is only valid for Screen capture. So we can fake it to 1283 // Session ID is only valid for Screen capture. So we can fake it to
1284 // resume video capture devices here. 1284 // resume video capture devices here.
1285 QueueStartDevice(kFakeSessionId, entry.get(), entry->parameters); 1285 QueueStartDevice(kFakeSessionId, entry.get(), entry->parameters);
1286 } 1286 }
1287 } 1287 }
1288 } 1288 }
1289 #endif // defined(OS_ANDROID) 1289 #endif // defined(OS_ANDROID)
1290 1290
1291 } // namespace content 1291 } // 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