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

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

Issue 7649016: Removing singleton property of MediaStreamManager and creating thread first when needed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reverted parts of previous upload. Created 9 years, 4 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_host.h" 5 #include "content/browser/renderer_host/media/video_capture_host.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "content/common/media/video_capture_messages.h" 9 #include "content/common/media/video_capture_messages.h"
10 10
11 VideoCaptureHost::VideoCaptureHost() {} 11 VideoCaptureHost::VideoCaptureHost(
12 const content::ResourceContext* resource_context)
13 : resource_context_(resource_context) {
14 }
12 15
13 VideoCaptureHost::~VideoCaptureHost() {} 16 VideoCaptureHost::~VideoCaptureHost() {}
14 17
15 void VideoCaptureHost::OnChannelClosing() { 18 void VideoCaptureHost::OnChannelClosing() {
16 BrowserMessageFilter::OnChannelClosing(); 19 BrowserMessageFilter::OnChannelClosing();
17 20
18 // Since the IPC channel is gone, close all requested VideCaptureDevices. 21 // Since the IPC channel is gone, close all requested VideCaptureDevices.
19 for (EntryMap::iterator it = entries_.begin(); it != entries_.end(); it++) { 22 for (EntryMap::iterator it = entries_.begin(); it != entries_.end(); it++) {
20 VideoCaptureController* controller = it->second; 23 VideoCaptureController* controller = it->second;
21 // Since the channel is closing we need a task to make sure VideoCaptureHost 24 // Since the channel is closing we need a task to make sure VideoCaptureHost
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 143
141 void VideoCaptureHost::OnStartCapture(int device_id, 144 void VideoCaptureHost::OnStartCapture(int device_id,
142 const media::VideoCaptureParams& params) { 145 const media::VideoCaptureParams& params) {
143 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
144 147
145 VideoCaptureControllerID controller_id(device_id); 148 VideoCaptureControllerID controller_id(device_id);
146 149
147 DCHECK(entries_.find(controller_id) == entries_.end()); 150 DCHECK(entries_.find(controller_id) == entries_.end());
148 151
149 scoped_refptr<VideoCaptureController> controller = 152 scoped_refptr<VideoCaptureController> controller =
150 new VideoCaptureController(controller_id, peer_handle(), this); 153 new VideoCaptureController(controller_id, peer_handle(), this,
154 resource_context_);
151 entries_.insert(std::make_pair(controller_id, controller)); 155 entries_.insert(std::make_pair(controller_id, controller));
152 controller->StartCapture(params); 156 controller->StartCapture(params);
153 } 157 }
154 158
155 void VideoCaptureHost::OnStopCapture(int device_id) { 159 void VideoCaptureHost::OnStopCapture(int device_id) {
156 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 160 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
157 161
158 VideoCaptureControllerID controller_id(device_id); 162 VideoCaptureControllerID controller_id(device_id);
159 EntryMap::iterator it = entries_.find(controller_id); 163 EntryMap::iterator it = entries_.find(controller_id);
160 if (it != entries_.end()) { 164 if (it != entries_.end()) {
(...skipping 26 matching lines...) Expand all
187 191
188 void VideoCaptureHost::DoDeleteVideoCaptureController( 192 void VideoCaptureHost::DoDeleteVideoCaptureController(
189 const VideoCaptureControllerID& id) { 193 const VideoCaptureControllerID& id) {
190 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
191 195
192 // Report that the device have successfully been stopped. 196 // Report that the device have successfully been stopped.
193 Send(new VideoCaptureMsg_StateChanged(id.device_id, 197 Send(new VideoCaptureMsg_StateChanged(id.device_id,
194 media::VideoCapture::kStopped)); 198 media::VideoCapture::kStopped));
195 entries_.erase(id); 199 entries_.erase(id);
196 } 200 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698