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

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

Issue 88283002: Reland review 34393006: Refactor MediaStreamManager to not output real device id. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changes since the revert. Created 7 years 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) 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/media_stream_manager.h" 5 #include "content/browser/renderer_host/media/media_stream_manager.h"
6 6
7 #include <list> 7 #include <list>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/rand_util.h" 14 #include "base/rand_util.h"
15 #include "base/run_loop.h"
15 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
16 #include "content/browser/renderer_host/media/audio_input_device_manager.h" 17 #include "content/browser/renderer_host/media/audio_input_device_manager.h"
17 #include "content/browser/renderer_host/media/device_request_message_filter.h" 18 #include "content/browser/renderer_host/media/device_request_message_filter.h"
18 #include "content/browser/renderer_host/media/media_stream_requester.h" 19 #include "content/browser/renderer_host/media/media_stream_requester.h"
19 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h" 20 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h"
20 #include "content/browser/renderer_host/media/video_capture_manager.h" 21 #include "content/browser/renderer_host/media/video_capture_manager.h"
21 #include "content/browser/renderer_host/media/web_contents_capture_util.h" 22 #include "content/browser/renderer_host/media/web_contents_capture_util.h"
22 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
23 #include "content/public/browser/content_browser_client.h" 24 #include "content/public/browser/content_browser_client.h"
24 #include "content/public/browser/media_device_id.h" 25 #include "content/public/browser/media_device_id.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 InitializeDeviceManagersOnIOThread(); 175 InitializeDeviceManagersOnIOThread();
175 } else { 176 } else {
176 BrowserThread::PostTask( 177 BrowserThread::PostTask(
177 BrowserThread::IO, FROM_HERE, 178 BrowserThread::IO, FROM_HERE,
178 base::Bind(&MediaStreamManager::InitializeDeviceManagersOnIOThread, 179 base::Bind(&MediaStreamManager::InitializeDeviceManagersOnIOThread,
179 base::Unretained(this))); 180 base::Unretained(this)));
180 } 181 }
181 } 182 }
182 183
183 MediaStreamManager::~MediaStreamManager() { 184 MediaStreamManager::~MediaStreamManager() {
185 DVLOG(1) << "~MediaStreamManager";
184 DCHECK(requests_.empty()); 186 DCHECK(requests_.empty());
185 DCHECK(!device_thread_.get()); 187 DCHECK(!device_thread_.get());
186 } 188 }
187 189
188 VideoCaptureManager* MediaStreamManager::video_capture_manager() { 190 VideoCaptureManager* MediaStreamManager::video_capture_manager() {
189 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 191 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
190 DCHECK(video_capture_manager_.get()); 192 DCHECK(video_capture_manager_.get());
191 return video_capture_manager_.get(); 193 return video_capture_manager_.get();
192 } 194 }
193 195
194 AudioInputDeviceManager* MediaStreamManager::audio_input_device_manager() { 196 AudioInputDeviceManager* MediaStreamManager::audio_input_device_manager() {
195 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 197 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
196 DCHECK(audio_input_device_manager_.get()); 198 DCHECK(audio_input_device_manager_.get());
197 return audio_input_device_manager_.get(); 199 return audio_input_device_manager_.get();
198 } 200 }
199 201
200 std::string MediaStreamManager::MakeMediaAccessRequest( 202 std::string MediaStreamManager::MakeMediaAccessRequest(
201 int render_process_id, 203 int render_process_id,
202 int render_view_id, 204 int render_view_id,
203 int page_request_id, 205 int page_request_id,
204 const StreamOptions& options, 206 const StreamOptions& options,
205 const GURL& security_origin, 207 const GURL& security_origin,
206 const MediaRequestResponseCallback& callback) { 208 const MediaRequestResponseCallback& callback) {
207 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 209 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
208 // Create a new request based on options. 210 // Create a new request based on options.
209 MediaStreamRequest stream_request( 211 MediaStreamRequest stream_request(
210 render_process_id, render_view_id, page_request_id, std::string(), 212 render_process_id, render_view_id, page_request_id,
211 security_origin, MEDIA_DEVICE_ACCESS, std::string(), std::string(), 213 security_origin, MEDIA_DEVICE_ACCESS, std::string(), std::string(),
212 options.audio_type, options.video_type); 214 options.audio_type, options.video_type);
213 DeviceRequest* request = new DeviceRequest(NULL, stream_request, 215 DeviceRequest* request = new DeviceRequest(NULL, stream_request,
214 render_process_id, render_view_id); 216 render_process_id, render_view_id);
215 const std::string& label = AddRequest(request); 217 const std::string& label = AddRequest(request);
216 218
217 request->callback = callback; 219 request->callback = callback;
218 220 BrowserThread::PostTask(
219 HandleRequest(label); 221 BrowserThread::IO, FROM_HERE,
220 222 base::Bind(&MediaStreamManager::SetupRequest,
223 base::Unretained(this), label));
tommi (sloooow) - chröme 2013/11/26 14:44:21 add a note that explains why we're doing this asyn
perkj_chrome 2013/11/27 13:41:34 Done.
221 return label; 224 return label;
222 } 225 }
223 226
224 std::string MediaStreamManager::GenerateStream( 227 std::string MediaStreamManager::GenerateStream(
225 MediaStreamRequester* requester, 228 MediaStreamRequester* requester,
226 int render_process_id, 229 int render_process_id,
227 int render_view_id, 230 int render_view_id,
228 int page_request_id, 231 int page_request_id,
229 const StreamOptions& options, 232 const StreamOptions& options,
230 const GURL& security_origin) { 233 const GURL& security_origin) {
231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 234 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
235 DVLOG(1) << "GenerateStream()";
232 if (CommandLine::ForCurrentProcess()->HasSwitch( 236 if (CommandLine::ForCurrentProcess()->HasSwitch(
233 switches::kUseFakeDeviceForMediaStream)) { 237 switches::kUseFakeDeviceForMediaStream)) {
234 UseFakeDevice(); 238 UseFakeDevice();
235 } 239 }
236 if (CommandLine::ForCurrentProcess()->HasSwitch( 240 if (CommandLine::ForCurrentProcess()->HasSwitch(
237 switches::kUseFakeUIForMediaStream)) { 241 switches::kUseFakeUIForMediaStream)) {
238 UseFakeUI(scoped_ptr<FakeMediaStreamUIProxy>()); 242 UseFakeUI(scoped_ptr<FakeMediaStreamUIProxy>());
239 } 243 }
240 244
241 int target_render_process_id = render_process_id;
242 int target_render_view_id = render_view_id;
243 std::string tab_capture_device_id;
244
245 // Customize options for a WebContents based capture.
246 if (options.audio_type == MEDIA_TAB_AUDIO_CAPTURE ||
247 options.video_type == MEDIA_TAB_VIDEO_CAPTURE) {
248 // TODO(justinlin): Can't plumb audio mirroring using stream type right
249 // now, so plumbing by device_id. Will revisit once it's refactored.
250 // http://crbug.com/163100
251 tab_capture_device_id =
252 WebContentsCaptureUtil::AppendWebContentsDeviceScheme(
253 !options.video_device_id.empty() ?
254 options.video_device_id : options.audio_device_id);
255
256 bool has_valid_device_id = WebContentsCaptureUtil::ExtractTabCaptureTarget(
257 tab_capture_device_id, &target_render_process_id,
258 &target_render_view_id);
259 if (!has_valid_device_id ||
260 (options.audio_type != MEDIA_TAB_AUDIO_CAPTURE &&
261 options.audio_type != MEDIA_NO_SERVICE) ||
262 (options.video_type != MEDIA_TAB_VIDEO_CAPTURE &&
263 options.video_type != MEDIA_NO_SERVICE)) {
264 LOG(ERROR) << "Invalid request.";
265 return std::string();
266 }
267 }
268
269 std::string translated_audio_device_id;
270 std::string translated_video_device_id;
271 if (options.audio_type == MEDIA_DEVICE_AUDIO_CAPTURE) {
272 bool found_match = TranslateGUIDToRawId(
273 MEDIA_DEVICE_AUDIO_CAPTURE, security_origin, options.audio_device_id,
274 &translated_audio_device_id);
275 DCHECK(found_match || translated_audio_device_id.empty());
276 }
277
278 if (options.video_type == MEDIA_DEVICE_VIDEO_CAPTURE) {
279 bool found_match = TranslateGUIDToRawId(
280 MEDIA_DEVICE_VIDEO_CAPTURE, security_origin, options.video_device_id,
281 &translated_video_device_id);
282 DCHECK(found_match || translated_video_device_id.empty());
283 }
284
285 if (options.video_type == MEDIA_DESKTOP_VIDEO_CAPTURE ||
286 options.audio_type == MEDIA_LOOPBACK_AUDIO_CAPTURE) {
287 // For screen capture we only support two valid combinations:
288 // (1) screen video capture only, or
289 // (2) screen video capture with loopback audio capture.
290 if (options.video_type != MEDIA_DESKTOP_VIDEO_CAPTURE ||
291 (options.audio_type != MEDIA_NO_SERVICE &&
292 options.audio_type != MEDIA_LOOPBACK_AUDIO_CAPTURE)) {
293 // TODO(sergeyu): Surface error message to the calling JS code.
294 LOG(ERROR) << "Invalid screen capture request.";
295 return std::string();
296 }
297 translated_video_device_id = options.video_device_id;
298 }
299
300 // Create a new request based on options. 245 // Create a new request based on options.
301 MediaStreamRequest stream_request( 246 MediaStreamRequest stream_request(
302 target_render_process_id, target_render_view_id, page_request_id, 247 render_process_id, render_view_id, page_request_id,
303 tab_capture_device_id, security_origin, MEDIA_GENERATE_STREAM, 248 security_origin, MEDIA_GENERATE_STREAM,
304 translated_audio_device_id, translated_video_device_id, 249 options.audio_device_id, options.video_device_id,
305 options.audio_type, options.video_type); 250 options.audio_type, options.video_type);
306 DeviceRequest* request = new DeviceRequest(requester, stream_request, 251 DeviceRequest* request = new DeviceRequest(requester, stream_request,
307 render_process_id, 252 render_process_id,
308 render_view_id); 253 render_view_id);
309 const std::string& label = AddRequest(request); 254 const std::string& label = AddRequest(request);
310 HandleRequest(label); 255
256 // Need to post a task since the requester won't have label till
257 // this function returns.
258 BrowserThread::PostTask(
259 BrowserThread::IO, FROM_HERE,
260 base::Bind(&MediaStreamManager::SetupRequest,
261 base::Unretained(this), label));
tommi (sloooow) - chröme 2013/11/26 14:44:21 same comment as in the constructor.
perkj_chrome 2013/11/27 13:41:34 Done.
311 return label; 262 return label;
312 } 263 }
313 264
314 void MediaStreamManager::CancelRequest(const std::string& label) { 265 void MediaStreamManager::CancelRequest(const std::string& label) {
315 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 266 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
316 DVLOG(1) << "CancelRequest({label = " << label << "})"; 267 DVLOG(1) << "CancelRequest({label = " << label << "})";
317 DeviceRequests::iterator request_it = requests_.find(label); 268 DeviceRequest* request = FindRequest(label);
318 if (request_it == requests_.end()) { 269 if (!request) {
319 NOTREACHED(); 270 // The request does not exist.
271 LOG(ERROR) << "The request does not exist.";
tommi (sloooow) - chröme 2013/11/26 14:44:21 does it help to also log the label?
perkj_chrome 2013/11/27 13:41:34 Done.
320 return; 272 return;
321 } 273 }
322 scoped_ptr<DeviceRequest> request(request_it->second);
323 RemoveRequest(request_it);
324
325 if (request->request.request_type == MEDIA_ENUMERATE_DEVICES) { 274 if (request->request.request_type == MEDIA_ENUMERATE_DEVICES) {
275 DeleteRequest(label);
326 return; 276 return;
327 } 277 }
328 278
329 // This is a request for opening one or more devices. 279 // This is a request for opening one or more devices.
330 for (StreamDeviceInfoArray::iterator device_it = request->devices.begin(); 280 for (StreamDeviceInfoArray::iterator device_it = request->devices.begin();
331 device_it != request->devices.end(); ++device_it) { 281 device_it != request->devices.end(); ++device_it) {
tommi (sloooow) - chröme 2013/11/26 14:44:21 fix indent
perkj_chrome 2013/11/27 13:41:34 Done.
332 // If we have not yet requested the device to be opened - just ignore it. 282 // If we have not yet requested the device to be opened - just ignore it.
333 if (request->state(device_it->device.type) != MEDIA_REQUEST_STATE_OPENING 283 if (request->state(device_it->device.type) != MEDIA_REQUEST_STATE_OPENING
tommi (sloooow) - chröme 2013/11/26 14:44:21 call request->state() once and store the result in
perkj_chrome 2013/11/27 13:41:34 Done.
334 && 284 &&
335 request->state(device_it->device.type) != MEDIA_REQUEST_STATE_DONE) { 285 request->state(device_it->device.type) != MEDIA_REQUEST_STATE_DONE) {
336 continue; 286 continue;
337 } 287 }
338 // Stop the opening/opened devices of the requests. 288 // Stop the opening/opened devices of the requests.
339 CloseDevice(device_it->device.type, device_it->session_id); 289 CloseDevice(device_it->device.type, device_it->session_id);
340 } 290 }
341 291
342 // Cancel the request if still pending at UI side. 292 // Cancel the request if still pending at UI side.
343 request->SetState(NUM_MEDIA_TYPES, MEDIA_REQUEST_STATE_CLOSING); 293 request->SetState(NUM_MEDIA_TYPES, MEDIA_REQUEST_STATE_CLOSING);
294 DeleteRequest(label);
344 } 295 }
345 296
346 void MediaStreamManager::CancelAllRequests(int render_process_id) { 297 void MediaStreamManager::CancelAllRequests(int render_process_id) {
347 DeviceRequests::iterator request_it = requests_.begin(); 298 DeviceRequests::iterator request_it = requests_.begin();
348 while (request_it != requests_.end()) { 299 while (request_it != requests_.end()) {
349 if (request_it->second->requesting_process_id != render_process_id) { 300 if (request_it->second->requesting_process_id != render_process_id) {
350 ++request_it; 301 ++request_it;
351 continue; 302 continue;
352 } 303 }
353 304
354 std::string label = request_it->first; 305 std::string label = request_it->first;
355 ++request_it; 306 ++request_it;
356 CancelRequest(label); 307 CancelRequest(label);
357 } 308 }
358 } 309 }
359 310
360 void MediaStreamManager::StopStreamDevice(int render_process_id, 311 void MediaStreamManager::StopStreamDevice(int render_process_id,
361 int render_view_id, 312 int render_view_id,
362 const std::string& device_id) { 313 const std::string& device_id) {
363 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 314 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
364 DVLOG(1) << "StopStreamDevice({render_view_id = " << render_view_id << "} " 315 DVLOG(1) << "StopStreamDevice({render_view_id = " << render_view_id << "} "
365 << ", {device_id = " << device_id << "})"; 316 << ", {device_id = " << device_id << "})";
366 317
367 // Find the first request for this |render_process_id| and |render_view_id|
368 // of type MEDIA_GENERATE_STREAM that has requested to use |device_id| and
369 // stop it.
370 for (DeviceRequests::iterator request_it = requests_.begin(); 318 for (DeviceRequests::iterator request_it = requests_.begin();
371 request_it != requests_.end(); ++request_it) { 319 request_it != requests_.end(); ++request_it) {
372 DeviceRequest* request = request_it->second; 320 DeviceRequest* request = request_it->second;
373 const MediaStreamRequest& ms_request = request->request; 321 const MediaStreamRequest& ms_request = request->request;
374 if (request->requesting_process_id != render_process_id || 322 if (request->requesting_process_id != render_process_id ||
375 request->requesting_view_id != render_view_id || 323 request->requesting_view_id != render_view_id ||
376 ms_request.request_type != MEDIA_GENERATE_STREAM) { 324 ms_request.request_type != MEDIA_GENERATE_STREAM) {
377 continue; 325 continue;
378 } 326 }
379 327
(...skipping 22 matching lines...) Expand all
402 device_it->session_id != session_id) { 350 device_it->session_id != session_id) {
403 ++device_it; 351 ++device_it;
404 continue; 352 continue;
405 } 353 }
406 if (request->state(type) == MEDIA_REQUEST_STATE_DONE) 354 if (request->state(type) == MEDIA_REQUEST_STATE_DONE)
407 CloseDevice(type, session_id); 355 CloseDevice(type, session_id);
408 device_it = devices->erase(device_it); 356 device_it = devices->erase(device_it);
409 } 357 }
410 // If this request doesn't have any active devices, remove the request. 358 // If this request doesn't have any active devices, remove the request.
411 if (devices->empty()) { 359 if (devices->empty()) {
412 DeviceRequests::iterator del_itor(request_it); 360 std::string label = request_it->first;
413 ++request_it; 361 ++request_it;
414 scoped_ptr<DeviceRequest> request(del_itor->second); 362 DeleteRequest(label);
415 RemoveRequest(del_itor);
416 } else { 363 } else {
417 ++request_it; 364 ++request_it;
418 } 365 }
419 } 366 }
420 } 367 }
421 368
422 void MediaStreamManager::CloseDevice(MediaStreamType type, int session_id) { 369 void MediaStreamManager::CloseDevice(MediaStreamType type, int session_id) {
423 DVLOG(1) << "CloseDevice(" 370 DVLOG(1) << "CloseDevice("
424 << "{type = " << type << "} " 371 << "{type = " << type << "} "
425 << "{session_id = " << session_id << "})"; 372 << "{session_id = " << session_id << "})";
(...skipping 29 matching lines...) Expand all
455 // starts monitoring devices. 402 // starts monitoring devices.
456 if (!requester) { 403 if (!requester) {
457 if (!monitoring_started_) 404 if (!monitoring_started_)
458 StartMonitoring(); 405 StartMonitoring();
459 406
460 return std::string(); 407 return std::string();
461 } 408 }
462 409
463 // Create a new request. 410 // Create a new request.
464 StreamOptions options; 411 StreamOptions options;
465 EnumerationCache* cache = NULL;
466 if (type == MEDIA_DEVICE_AUDIO_CAPTURE) { 412 if (type == MEDIA_DEVICE_AUDIO_CAPTURE) {
467 options.audio_type = type; 413 options.audio_type = type;
468 cache = &audio_enumeration_cache_;
469 } else if (type == MEDIA_DEVICE_VIDEO_CAPTURE) { 414 } else if (type == MEDIA_DEVICE_VIDEO_CAPTURE) {
470 options.video_type = type; 415 options.video_type = type;
471 cache = &video_enumeration_cache_;
472 } else { 416 } else {
473 NOTREACHED(); 417 NOTREACHED();
474 return std::string(); 418 return std::string();
475 } 419 }
476 420
477 MediaStreamRequest stream_request( 421 MediaStreamRequest stream_request(
478 render_process_id, render_view_id, page_request_id, std::string(), 422 render_process_id, render_view_id, page_request_id,
479 security_origin, MEDIA_ENUMERATE_DEVICES, std::string(), std::string(), 423 security_origin, MEDIA_ENUMERATE_DEVICES, std::string(), std::string(),
480 options.audio_type, options.video_type); 424 options.audio_type, options.video_type);
481 DeviceRequest* request = new DeviceRequest(requester, stream_request, 425 DeviceRequest* request = new DeviceRequest(requester, stream_request,
482 render_process_id, 426 render_process_id,
483 render_view_id); 427 render_view_id);
484 const std::string& label = AddRequest(request); 428 const std::string& label = AddRequest(request);
429 BrowserThread::PostTask(
430 BrowserThread::IO, FROM_HERE,
431 base::Bind(&MediaStreamManager::DoEnumerateDevices,
432 base::Unretained(this), label));
tommi (sloooow) - chröme 2013/11/26 14:44:21 same concerns here as above.
perkj_chrome 2013/11/27 13:41:34 Done.
433
434 return label;
435 }
436
437 void MediaStreamManager::DoEnumerateDevices(const std::string& label) {
438 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
439 DeviceRequest* request = FindRequest(label);
440 if (!request)
441 return; // This can happen if the request has been canceled.
442
443 MediaStreamType type;
444 EnumerationCache* cache;
445 if (request->request.audio_type == MEDIA_DEVICE_AUDIO_CAPTURE) {
446 DCHECK(request->request.video_type == MEDIA_NO_SERVICE);
tommi (sloooow) - chröme 2013/11/26 14:44:21 DCHECK_EQ?
perkj_chrome 2013/11/27 13:41:34 Done.
447 type = MEDIA_DEVICE_AUDIO_CAPTURE;
448 cache = &audio_enumeration_cache_;
449 } else {
450 DCHECK(request->request.video_type == MEDIA_DEVICE_VIDEO_CAPTURE);
tommi (sloooow) - chröme 2013/11/26 14:44:21 DCHECK_EQ?
perkj_chrome 2013/11/27 13:41:34 Done.
451 type = MEDIA_DEVICE_VIDEO_CAPTURE;
452 cache = &video_enumeration_cache_;
453 }
485 454
486 if (cache->valid) { 455 if (cache->valid) {
487 // Cached device list of this type exists. Just send it out. 456 // Cached device list of this type exists. Just send it out.
488 request->SetState(type, MEDIA_REQUEST_STATE_REQUESTED); 457 request->SetState(type, MEDIA_REQUEST_STATE_REQUESTED);
489 458 request->devices = cache->devices;
490 // Need to post a task since the requester won't have label till 459 FinalizeEnumerateDevices(label, request);
491 // this function returns.
492 BrowserThread::PostTask(
493 BrowserThread::IO, FROM_HERE,
494 base::Bind(&MediaStreamManager::SendCachedDeviceList,
495 base::Unretained(this), cache, label));
496 } else { 460 } else {
497 StartEnumeration(request); 461 StartEnumeration(request);
498 } 462 }
499
500 DVLOG(1) << "Enumerate Devices ({label = " << label << "})"; 463 DVLOG(1) << "Enumerate Devices ({label = " << label << "})";
501 return label;
502 } 464 }
503 465
504 std::string MediaStreamManager::OpenDevice( 466 std::string MediaStreamManager::OpenDevice(
505 MediaStreamRequester* requester, 467 MediaStreamRequester* requester,
506 int render_process_id, 468 int render_process_id,
507 int render_view_id, 469 int render_view_id,
508 int page_request_id, 470 int page_request_id,
509 const std::string& device_id, 471 const std::string& device_id,
510 MediaStreamType type, 472 MediaStreamType type,
511 const GURL& security_origin) { 473 const GURL& security_origin) {
512 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 474 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
513 DCHECK(type == MEDIA_DEVICE_AUDIO_CAPTURE || 475 DCHECK(type == MEDIA_DEVICE_AUDIO_CAPTURE ||
514 type == MEDIA_DEVICE_VIDEO_CAPTURE); 476 type == MEDIA_DEVICE_VIDEO_CAPTURE);
515 477
516 // Create a new request. 478 // Create a new request.
517 StreamOptions options; 479 StreamOptions options;
518 if (IsAudioMediaType(type)) { 480 if (IsAudioMediaType(type)) {
519 options.audio_type = type; 481 options.audio_type = type;
520 options.audio_device_id = device_id; 482 options.audio_device_id = device_id;
521 } else if (IsVideoMediaType(type)) { 483 } else if (IsVideoMediaType(type)) {
522 options.video_type = type; 484 options.video_type = type;
523 options.video_device_id = device_id; 485 options.video_device_id = device_id;
524 } else { 486 } else {
525 NOTREACHED(); 487 NOTREACHED();
526 return std::string(); 488 return std::string();
527 } 489 }
528 490
529 MediaStreamRequest stream_request( 491 MediaStreamRequest stream_request(
530 render_process_id, render_view_id, page_request_id, std::string(), 492 render_process_id, render_view_id, page_request_id,
531 security_origin, MEDIA_OPEN_DEVICE, options.audio_device_id, 493 security_origin, MEDIA_OPEN_DEVICE, options.audio_device_id,
532 options.video_device_id, options.audio_type, options.video_type); 494 options.video_device_id, options.audio_type, options.video_type);
533 DeviceRequest* request = new DeviceRequest(requester, stream_request, 495 DeviceRequest* request = new DeviceRequest(requester, stream_request,
534 render_process_id, 496 render_process_id,
535 render_view_id); 497 render_view_id);
536 const std::string& label = AddRequest(request); 498 const std::string& label = AddRequest(request);
537 StartEnumeration(request); 499 BrowserThread::PostTask(
500 BrowserThread::IO, FROM_HERE,
501 base::Bind(&MediaStreamManager::SetupRequest,
502 base::Unretained(this), label));
tommi (sloooow) - chröme 2013/11/26 14:44:21 same here
perkj_chrome 2013/11/27 13:41:34 Done.
538 503
539 DVLOG(1) << "OpenDevice ({label = " << label << "})"; 504 DVLOG(1) << "OpenDevice ({label = " << label << "})";
540 return label; 505 return label;
541 } 506 }
542 507
543 void MediaStreamManager::SendCachedDeviceList(
544 EnumerationCache* cache,
545 const std::string& label) {
546 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
547 if (cache->valid) {
548 DeviceRequests::iterator it = requests_.find(label);
549 if (it != requests_.end()) {
550 it->second->requester->DevicesEnumerated(label, cache->devices);
551 }
552 }
553 }
554
555 void MediaStreamManager::StopRemovedDevices( 508 void MediaStreamManager::StopRemovedDevices(
556 const StreamDeviceInfoArray& old_devices, 509 const StreamDeviceInfoArray& old_devices,
557 const StreamDeviceInfoArray& new_devices) { 510 const StreamDeviceInfoArray& new_devices) {
558 DVLOG(1) << "StopRemovedDevices(" 511 DVLOG(1) << "StopRemovedDevices("
559 << "{#old_devices = " << old_devices.size() << "} " 512 << "{#old_devices = " << old_devices.size() << "} "
560 << "{#new_devices = " << new_devices.size() << "})"; 513 << "{#new_devices = " << new_devices.size() << "})";
561 for (StreamDeviceInfoArray::const_iterator old_dev_it = old_devices.begin(); 514 for (StreamDeviceInfoArray::const_iterator old_dev_it = old_devices.begin();
562 old_dev_it != old_devices.end(); ++old_dev_it) { 515 old_dev_it != old_devices.end(); ++old_dev_it) {
563 bool device_found = false; 516 bool device_found = false;
564 for (StreamDeviceInfoArray::const_iterator new_dev_it = new_devices.begin(); 517 for (StreamDeviceInfoArray::const_iterator new_dev_it = new_devices.begin();
(...skipping 13 matching lines...) Expand all
578 } 531 }
579 532
580 void MediaStreamManager::StopRemovedDevice(const MediaStreamDevice& device) { 533 void MediaStreamManager::StopRemovedDevice(const MediaStreamDevice& device) {
581 std::vector<int> session_ids; 534 std::vector<int> session_ids;
582 for (DeviceRequests::const_iterator it = requests_.begin(); 535 for (DeviceRequests::const_iterator it = requests_.begin();
583 it != requests_.end() ; ++it) { 536 it != requests_.end() ; ++it) {
584 const DeviceRequest* request = it->second; 537 const DeviceRequest* request = it->second;
585 for (StreamDeviceInfoArray::const_iterator device_it = 538 for (StreamDeviceInfoArray::const_iterator device_it =
586 request->devices.begin(); 539 request->devices.begin();
587 device_it != request->devices.end(); ++device_it) { 540 device_it != request->devices.end(); ++device_it) {
588 if (device_it->device.IsEqual(device)) { 541 std::string source_id = content::GetHMACForMediaDeviceID(
542 request->request.security_origin,
543 device.id);
544 if (device_it->device.id == source_id &&
545 device_it->device.type == device.type) {
589 session_ids.push_back(device_it->session_id); 546 session_ids.push_back(device_it->session_id);
590 if (it->second->requester) { 547 if (it->second->requester) {
591 it->second->requester->DeviceStopped( 548 it->second->requester->DeviceStopped(
592 it->second->requesting_view_id, 549 it->second->requesting_view_id,
593 it->first, 550 it->first,
594 *device_it); 551 *device_it);
595 } 552 }
596 } 553 }
597 } 554 }
598 } 555 }
(...skipping 24 matching lines...) Expand all
623 void MediaStreamManager::StopMonitoring() { 580 void MediaStreamManager::StopMonitoring() {
624 DCHECK_EQ(base::MessageLoop::current(), io_loop_); 581 DCHECK_EQ(base::MessageLoop::current(), io_loop_);
625 if (monitoring_started_) { 582 if (monitoring_started_) {
626 base::SystemMonitor::Get()->RemoveDevicesChangedObserver(this); 583 base::SystemMonitor::Get()->RemoveDevicesChangedObserver(this);
627 monitoring_started_ = false; 584 monitoring_started_ = false;
628 ClearEnumerationCache(&audio_enumeration_cache_); 585 ClearEnumerationCache(&audio_enumeration_cache_);
629 ClearEnumerationCache(&video_enumeration_cache_); 586 ClearEnumerationCache(&video_enumeration_cache_);
630 } 587 }
631 } 588 }
632 589
633 bool MediaStreamManager::TranslateGUIDToRawId(MediaStreamType stream_type, 590 bool MediaStreamManager::TranslateRequestedSourceIdToDeviceId(
634 const GURL& security_origin, 591 MediaStreamRequest* request) {
635 const std::string& device_guid, 592 // If a specific device has been requested we need to find the real device id.
636 std::string* raw_device_id) { 593 if (request->audio_type == MEDIA_DEVICE_AUDIO_CAPTURE &&
594 !request->requested_audio_device_id.empty()) {
595 if (!TranslateSourceIdToDeviceId(MEDIA_DEVICE_AUDIO_CAPTURE,
596 request->security_origin,
597 request->requested_audio_device_id,
598 &request->requested_audio_device_id)) {
599 // TODO(perkj): gUM should support mandatory and optional constraints.
600 // Ie - if the sourceId is optional but it does not match - gUM should
601 // not fail. For now we treat sourceId as a mandatory constraint.
602 LOG(ERROR) << "Requested device does not exist.";
603 return false;
604 }
605 }
606
607 if (request->video_type == MEDIA_DEVICE_VIDEO_CAPTURE &&
608 !request->requested_video_device_id.empty()) {
609 if (!TranslateSourceIdToDeviceId(MEDIA_DEVICE_VIDEO_CAPTURE,
610 request->security_origin,
611 request->requested_video_device_id,
612 &request->requested_video_device_id)) {
613 // TODO(perkj): guM should support mandatory and optional constraints.
614 // Ie - if the sourceId is optional but it does not match - guM should
615 // not fail. For now we treat sourceId as a mandatory constraint.
616 LOG(ERROR) << "Requested device does not exist.";
617 return false;
618 }
619 }
620 DVLOG(3) << "Requested audio device " << request->requested_audio_device_id
621 << " video device " << request->requested_video_device_id;
622 return true;
623 }
624
625 void MediaStreamManager::TranslateDeviceIdToSourceId(
626 const MediaStreamRequest& request,
627 MediaStreamDevice* device) {
628 if (request.audio_type == MEDIA_DEVICE_AUDIO_CAPTURE ||
629 request.video_type == MEDIA_DEVICE_VIDEO_CAPTURE) {
630 device->id = content::GetHMACForMediaDeviceID(
631 request.security_origin,
632 device->id);
633 return;
tommi (sloooow) - chröme 2013/11/26 14:44:21 remove
perkj_chrome 2013/11/27 13:41:34 Done.
634 }
635 return;
tommi (sloooow) - chröme 2013/11/26 14:44:21 remove
perkj_chrome 2013/11/27 13:41:34 Done.
636 }
637
638 bool MediaStreamManager::TranslateSourceIdToDeviceId(
639 MediaStreamType stream_type,
640 const GURL& security_origin,
641 const std::string& source_id,
642 std::string* device_id) {
637 DCHECK(stream_type == MEDIA_DEVICE_AUDIO_CAPTURE || 643 DCHECK(stream_type == MEDIA_DEVICE_AUDIO_CAPTURE ||
638 stream_type == MEDIA_DEVICE_VIDEO_CAPTURE); 644 stream_type == MEDIA_DEVICE_VIDEO_CAPTURE);
639 if (device_guid.empty()) 645 DCHECK(!source_id.empty());
640 return false;
641 646
642 EnumerationCache* cache = 647 EnumerationCache* cache =
643 stream_type == MEDIA_DEVICE_AUDIO_CAPTURE ? 648 stream_type == MEDIA_DEVICE_AUDIO_CAPTURE ?
644 &audio_enumeration_cache_ : &video_enumeration_cache_; 649 &audio_enumeration_cache_ : &video_enumeration_cache_;
645 650
646 // If device monitoring hasn't started, the |device_guid| is not valid. 651 // If device monitoring hasn't started, the |device_guid| is not valid.
647 if (!cache->valid) 652 if (!cache->valid)
648 return false; 653 return false;
649 654
650 for (StreamDeviceInfoArray::const_iterator it = cache->devices.begin(); 655 for (StreamDeviceInfoArray::const_iterator it = cache->devices.begin();
651 it != cache->devices.end(); 656 it != cache->devices.end();
652 ++it) { 657 ++it) {
653 if (content::DoesMediaDeviceIDMatchHMAC( 658 if (content::DoesMediaDeviceIDMatchHMAC(security_origin, source_id,
654 security_origin, device_guid, it->device.id)) { 659 it->device.id)) {
655 *raw_device_id = it->device.id; 660 *device_id = it->device.id;
656 return true; 661 return true;
657 } 662 }
658 } 663 }
659 return false; 664 return false;
660 } 665 }
661 666
662 void MediaStreamManager::ClearEnumerationCache(EnumerationCache* cache) { 667 void MediaStreamManager::ClearEnumerationCache(EnumerationCache* cache) {
663 DCHECK_EQ(base::MessageLoop::current(), io_loop_); 668 DCHECK_EQ(base::MessageLoop::current(), io_loop_);
664 cache->valid = false; 669 cache->valid = false;
665 } 670 }
(...skipping 27 matching lines...) Expand all
693 std::string unique_label; 698 std::string unique_label;
694 do { 699 do {
695 unique_label = RandomLabel(); 700 unique_label = RandomLabel();
696 } while (requests_.find(unique_label) != requests_.end()); 701 } while (requests_.find(unique_label) != requests_.end());
697 702
698 requests_.insert(std::make_pair(unique_label, request)); 703 requests_.insert(std::make_pair(unique_label, request));
699 704
700 return unique_label; 705 return unique_label;
701 } 706 }
702 707
703 void MediaStreamManager::RemoveRequest(DeviceRequests::iterator it) { 708 MediaStreamManager::DeviceRequest*
709 MediaStreamManager::FindRequest(const std::string& label) {
710 DeviceRequests::iterator request_it = requests_.find(label);
711 return request_it == requests_.end() ? NULL : request_it->second;
712 }
713
714 void MediaStreamManager::DeleteRequest(const std::string& label) {
715 DeviceRequests::iterator it = requests_.find(label);
716 scoped_ptr<DeviceRequest> request(it->second);
704 requests_.erase(it); 717 requests_.erase(it);
705 } 718 }
706 719
707 void MediaStreamManager::PostRequestToUI(const std::string& label) { 720 void MediaStreamManager::PostRequestToUI(const std::string& label,
721 DeviceRequest* request) {
708 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 722 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
709 DeviceRequest* request = requests_[label]; 723 DVLOG(1) << "PostRequestToUI({label= " << label << "})";
724 // If a specific device has been requested we need to find the real device id.
725 if (!TranslateRequestedSourceIdToDeviceId(&request->request)) {
726 FinalizeRequestFailed(label, request);
727 return;
728 }
729
730 const MediaStreamType audio_type = request->request.audio_type;
731 const MediaStreamType video_type = request->request.video_type;
732
733 // Post the request to UI and set the state.
734 if (IsAudioMediaType(audio_type))
735 request->SetState(audio_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL);
736 if (IsVideoMediaType(video_type))
737 request->SetState(video_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL);
710 738
711 if (use_fake_ui_) { 739 if (use_fake_ui_) {
712 if (!fake_ui_) 740 if (!fake_ui_)
713 fake_ui_.reset(new FakeMediaStreamUIProxy()); 741 fake_ui_.reset(new FakeMediaStreamUIProxy());
714 742
715 MediaStreamDevices devices; 743 MediaStreamDevices devices;
716 if (audio_enumeration_cache_.valid) { 744 if (audio_enumeration_cache_.valid) {
717 for (StreamDeviceInfoArray::const_iterator it = 745 for (StreamDeviceInfoArray::const_iterator it =
718 audio_enumeration_cache_.devices.begin(); 746 audio_enumeration_cache_.devices.begin();
719 it != audio_enumeration_cache_.devices.end(); ++it) { 747 it != audio_enumeration_cache_.devices.end(); ++it) {
(...skipping 14 matching lines...) Expand all
734 } else { 762 } else {
735 request->ui_proxy = MediaStreamUIProxy::Create(); 763 request->ui_proxy = MediaStreamUIProxy::Create();
736 } 764 }
737 765
738 request->ui_proxy->RequestAccess( 766 request->ui_proxy->RequestAccess(
739 request->request, 767 request->request,
740 base::Bind(&MediaStreamManager::HandleAccessRequestResponse, 768 base::Bind(&MediaStreamManager::HandleAccessRequestResponse,
741 base::Unretained(this), label)); 769 base::Unretained(this), label));
742 } 770 }
743 771
744 void MediaStreamManager::HandleRequest(const std::string& label) { 772 void MediaStreamManager::SetupRequest(const std::string& label) {
745 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 773 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
746 DeviceRequest* request = requests_[label]; 774 DeviceRequest* request = FindRequest(label);
775 if (!request) {
776 DVLOG(1) << "SetupRequest label " << label << "dont exist!!";
tommi (sloooow) - chröme 2013/11/26 14:44:21 s/dont/doesn't also add a space before, i.e. " doe
777 return; // This can happen if the request has been canceled.
778 }
779
780 if (!request->request.security_origin.is_valid()) {
781 LOG(ERROR) << "Invalid security origin. "
782 << request->request.security_origin;
783 FinalizeRequestFailed(label, request);
784 return;
785 }
747 786
748 const MediaStreamType audio_type = request->request.audio_type; 787 const MediaStreamType audio_type = request->request.audio_type;
749 const MediaStreamType video_type = request->request.video_type; 788 const MediaStreamType video_type = request->request.video_type;
750 789
751 bool is_web_contents_capture = 790 bool is_web_contents_capture =
752 audio_type == MEDIA_TAB_AUDIO_CAPTURE || 791 audio_type == MEDIA_TAB_AUDIO_CAPTURE ||
753 video_type == MEDIA_TAB_VIDEO_CAPTURE; 792 video_type == MEDIA_TAB_VIDEO_CAPTURE;
793 if (is_web_contents_capture && !SetupTabCaptureRequest(request)) {
794 FinalizeRequestFailed(label, request);
795 return;
796 }
754 797
755 bool is_screen_capture = 798 bool is_screen_capture =
756 video_type == MEDIA_DESKTOP_VIDEO_CAPTURE; 799 video_type == MEDIA_DESKTOP_VIDEO_CAPTURE;
800 if (is_screen_capture && !SetupScreenCaptureRequest(request)) {
801 FinalizeRequestFailed(label, request);
802 return;
803 }
757 804
758 if (!is_web_contents_capture && 805 if (!is_web_contents_capture &&
759 !is_screen_capture && 806 !is_screen_capture &&
760 ((IsAudioMediaType(audio_type) && !audio_enumeration_cache_.valid) || 807 ((IsAudioMediaType(audio_type) && !audio_enumeration_cache_.valid) ||
761 (IsVideoMediaType(video_type) && !video_enumeration_cache_.valid))) { 808 (IsVideoMediaType(video_type) && !video_enumeration_cache_.valid))) {
762 // Enumerate the devices if there is no valid device lists to be used. 809 // Enumerate the devices if there is no valid device lists to be used.
763 StartEnumeration(request); 810 StartEnumeration(request);
764 return; 811 return;
765 } 812 }
813 PostRequestToUI(label, request);
814 }
766 815
767 // No need to do new device enumerations, post the request to UI 816 bool MediaStreamManager::SetupTabCaptureRequest(DeviceRequest* request) {
768 // immediately. 817 DCHECK(request->request.audio_type == MEDIA_TAB_AUDIO_CAPTURE ||
769 if (IsAudioMediaType(audio_type)) 818 request->request.video_type == MEDIA_TAB_VIDEO_CAPTURE);
770 request->SetState(audio_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL);
771 if (IsVideoMediaType(video_type))
772 request->SetState(video_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL);
773 819
774 PostRequestToUI(label); 820 MediaStreamRequest* ms_request = &request->request;
821 // Customize options for a WebContents based capture.
822 int target_render_process_id = 0;
823 int target_render_view_id = 0;
824
825 // TODO(justinlin): Can't plumb audio mirroring using stream type right
826 // now, so plumbing by device_id. Will revisit once it's refactored.
827 // http://crbug.com/163100
828 std::string tab_capture_device_id =
829 WebContentsCaptureUtil::AppendWebContentsDeviceScheme(
830 !ms_request->requested_video_device_id.empty() ?
831 ms_request->requested_video_device_id :
832 ms_request->requested_audio_device_id);
833
834 bool has_valid_device_id = WebContentsCaptureUtil::ExtractTabCaptureTarget(
835 tab_capture_device_id, &target_render_process_id,
836 &target_render_view_id);
837 if (!has_valid_device_id ||
838 (ms_request->audio_type != MEDIA_TAB_AUDIO_CAPTURE &&
839 ms_request->audio_type != MEDIA_NO_SERVICE) ||
840 (ms_request->video_type != MEDIA_TAB_VIDEO_CAPTURE &&
841 ms_request->video_type != MEDIA_NO_SERVICE)) {
842 return false;
843 }
844 ms_request->tab_capture_device_id = tab_capture_device_id;
845 ms_request->render_process_id = target_render_process_id;
846 ms_request->render_view_id = target_render_view_id;
847 DVLOG(3) << "SetupTabCaptureRequest "
848 << ", {tab_capture_device_id = " << tab_capture_device_id << "}"
849 << ", {target_render_process_id = " << target_render_process_id
850 << "}"
851 << ", {target_render_view_id = " << target_render_view_id << "}";
852 return true;
853 }
854
855 bool MediaStreamManager::SetupScreenCaptureRequest(DeviceRequest* request) {
856 DCHECK(request->request.audio_type == MEDIA_LOOPBACK_AUDIO_CAPTURE ||
857 request->request.video_type == MEDIA_DESKTOP_VIDEO_CAPTURE);
858 const MediaStreamRequest& ms_request = request->request;
859
860 // For screen capture we only support two valid combinations:
861 // (1) screen video capture only, or
862 // (2) screen video capture with loopback audio capture.
863 if (ms_request.video_type != MEDIA_DESKTOP_VIDEO_CAPTURE ||
864 (ms_request.audio_type != MEDIA_NO_SERVICE &&
865 ms_request.audio_type != MEDIA_LOOPBACK_AUDIO_CAPTURE)) {
866 // TODO(sergeyu): Surface error message to the calling JS code.
867 LOG(ERROR) << "Invalid screen capture request.";
868 return false;
869 }
870 return true;
871 }
872
873 const StreamDeviceInfo* MediaStreamManager::FindRequestedDeviceInfoForTest(
874 const std::string& source_id,
875 int render_process_id,
876 int render_view_id,
877 MediaStreamRequestType type) {
878 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
879 for (DeviceRequests::const_iterator it = requests_.begin();
880 it != requests_.end() ; ++it) {
881 const DeviceRequest* request = it->second;
882 if (request->request.render_process_id == render_process_id &&
883 request->request.render_view_id == render_view_id &&
884 request->request.request_type == type) {
885 for (StreamDeviceInfoArray::const_iterator device_it =
886 request->devices.begin();
887 device_it != request->devices.end(); ++device_it) {
888 if (source_id == device_it->device.id) {
889 return &*device_it;
890 }
891 }
892 }
893 }
894 return NULL;
775 } 895 }
776 896
777 bool MediaStreamManager::FindExistingRequestedDeviceInfo( 897 bool MediaStreamManager::FindExistingRequestedDeviceInfo(
778 int render_process_id, 898 int render_process_id,
779 int render_view_id, 899 int render_view_id,
900 const GURL& security_origin,
780 MediaStreamRequestType type, 901 MediaStreamRequestType type,
781 const std::string& device_id, 902 const std::string& device_id,
903 MediaStreamType device_type,
782 StreamDeviceInfo* device_info, 904 StreamDeviceInfo* device_info,
783 MediaRequestState* request_state) const { 905 MediaRequestState* request_state) const {
784 DCHECK(device_info); 906 DCHECK(device_info);
785 DCHECK(request_state); 907 DCHECK(request_state);
908
909 std::string source_id = content::GetHMACForMediaDeviceID(
910 security_origin,
911 device_id);
912
786 for (DeviceRequests::const_iterator it = requests_.begin(); 913 for (DeviceRequests::const_iterator it = requests_.begin();
787 it != requests_.end() ; ++it) { 914 it != requests_.end() ; ++it) {
788 const DeviceRequest* request = it->second; 915 const DeviceRequest* request = it->second;
789 if (request->requesting_process_id ==render_process_id && 916 if (request->requesting_process_id == render_process_id &&
790 request->requesting_view_id == render_view_id && 917 request->requesting_view_id == render_view_id &&
791 request->request.request_type == type) { 918 request->request.request_type == type) {
792 for (StreamDeviceInfoArray::const_iterator device_it = 919 for (StreamDeviceInfoArray::const_iterator device_it =
793 request->devices.begin(); 920 request->devices.begin();
794 device_it != request->devices.end(); ++device_it) { 921 device_it != request->devices.end(); ++device_it) {
795 if (device_it->device.id == device_id) { 922 if (device_it->device.id == source_id &&
923 device_it->device.type == device_type) {
796 *device_info = *device_it; 924 *device_info = *device_it;
797 *request_state = request->state(device_it->device.type); 925 *request_state = request->state(device_it->device.type);
798 return true; 926 return true;
799 } 927 }
800 } 928 }
801 } 929 }
802 } 930 }
803 return false; 931 return false;
804 } 932 }
805 933
934 void MediaStreamManager::FinalizeGenerateStream(const std::string& label,
935 DeviceRequest* request) {
936 DVLOG(1) << "FinalizeGenerateStream label " << label;
937 const StreamDeviceInfoArray& requested_devices = request->devices;
938
939 // Partition the array of devices into audio vs video.
940 StreamDeviceInfoArray audio_devices, video_devices;
941 for (StreamDeviceInfoArray::const_iterator device_it =
942 requested_devices.begin();
943 device_it != requested_devices.end(); ++device_it) {
944 if (IsAudioMediaType(device_it->device.type)) {
945 audio_devices.push_back(*device_it);
946 } else if (IsVideoMediaType(device_it->device.type)) {
947 video_devices.push_back(*device_it);
948 } else {
949 NOTREACHED();
950 }
951 }
952
953 request->requester->StreamGenerated(label, audio_devices, video_devices);
954 }
955
956 void MediaStreamManager::FinalizeRequestFailed(
957 const std::string& label,
958 DeviceRequest* request) {
959 if (request->requester)
960 request->requester->StreamGenerationFailed(label);
961
962 if (request->request.request_type == MEDIA_DEVICE_ACCESS &&
963 !request->callback.is_null()) {
964 request->callback.Run(MediaStreamDevices(), request->ui_proxy.Pass());
965 }
966
967 DeleteRequest(label);
968 }
969
970 void MediaStreamManager::FinalizeOpenDevice(const std::string& label,
971 DeviceRequest* request) {
972 const StreamDeviceInfoArray& requested_devices = request->devices;
973 request->requester->DeviceOpened(label, requested_devices.front());
974 }
975
976 void MediaStreamManager::FinalizeEnumerateDevices(const std::string& label,
977 DeviceRequest* request) {
978 for (StreamDeviceInfoArray::iterator it = request->devices.begin();
979 it != request->devices.end(); ++it) {
980 TranslateDeviceIdToSourceId(request->request, &it->device);
981 }
982 request->requester->DevicesEnumerated(label, request->devices);
983 }
984
985 void MediaStreamManager::FinalizeMediaAccessRequest(
986 const std::string& label,
987 DeviceRequest* request,
988 const MediaStreamDevices& devices) {
989 if (!request->callback.is_null())
990 request->callback.Run(devices, request->ui_proxy.Pass());
991
992 // Delete the request since it is done.
993 DeleteRequest(label);
994 }
995
806 void MediaStreamManager::InitializeDeviceManagersOnIOThread() { 996 void MediaStreamManager::InitializeDeviceManagersOnIOThread() {
807 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 997 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
808 if (device_thread_) 998 if (device_thread_)
809 return; 999 return;
810 1000
811 device_thread_.reset(new base::Thread("MediaStreamDeviceThread")); 1001 device_thread_.reset(new base::Thread("MediaStreamDeviceThread"));
812 #if defined(OS_WIN) 1002 #if defined(OS_WIN)
813 device_thread_->init_com_with_mta(true); 1003 device_thread_->init_com_with_mta(true);
814 #endif 1004 #endif
815 CHECK(device_thread_->Start()); 1005 CHECK(device_thread_->Start());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 request->SetState(device_it->device.type, MEDIA_REQUEST_STATE_DONE); 1041 request->SetState(device_it->device.type, MEDIA_REQUEST_STATE_DONE);
852 1042
853 if (IsAudioMediaType(device_it->device.type)) { 1043 if (IsAudioMediaType(device_it->device.type)) {
854 // Store the native audio parameters in the device struct. 1044 // Store the native audio parameters in the device struct.
855 // TODO(xians): Handle the tab capture sample rate/channel layout 1045 // TODO(xians): Handle the tab capture sample rate/channel layout
856 // in AudioInputDeviceManager::Open(). 1046 // in AudioInputDeviceManager::Open().
857 if (device_it->device.type != content::MEDIA_TAB_AUDIO_CAPTURE) { 1047 if (device_it->device.type != content::MEDIA_TAB_AUDIO_CAPTURE) {
858 const StreamDeviceInfo* info = 1048 const StreamDeviceInfo* info =
859 audio_input_device_manager_->GetOpenedDeviceInfoById( 1049 audio_input_device_manager_->GetOpenedDeviceInfoById(
860 device_it->session_id); 1050 device_it->session_id);
861 DCHECK_EQ(info->device.id, device_it->device.id);
862 device_it->device.input = info->device.input; 1051 device_it->device.input = info->device.input;
863 device_it->device.matched_output = info->device.matched_output; 1052 device_it->device.matched_output = info->device.matched_output;
864 } 1053 }
865 } 1054 }
866 if (RequestDone(*request)) 1055 if (RequestDone(*request))
867 HandleRequestDone(label, request); 1056 HandleRequestDone(label, request);
868 break; 1057 break;
869 } 1058 }
870 } 1059 }
871 } 1060 }
872 } 1061 }
873 1062
874 void MediaStreamManager::HandleRequestDone(const std::string& label, 1063 void MediaStreamManager::HandleRequestDone(const std::string& label,
875 DeviceRequest* request) { 1064 DeviceRequest* request) {
876 DCHECK(RequestDone(*request)); 1065 DCHECK(RequestDone(*request));
877 DVLOG(1) << "HandleRequestDone(" 1066 DVLOG(1) << "HandleRequestDone("
878 << ", {label = " << label << "})"; 1067 << ", {label = " << label << "})";
879 1068
880 const StreamDeviceInfoArray& requested_devices = request->devices;
881 switch (request->request.request_type) { 1069 switch (request->request.request_type) {
882 case MEDIA_OPEN_DEVICE: 1070 case MEDIA_OPEN_DEVICE:
883 request->requester->DeviceOpened(label, requested_devices.front()); 1071 FinalizeOpenDevice(label, request);
884 break; 1072 break;
885 case MEDIA_GENERATE_STREAM: { 1073 case MEDIA_GENERATE_STREAM: {
886 // Partition the array of devices into audio vs video. 1074 FinalizeGenerateStream(label, request);
887 StreamDeviceInfoArray audio_devices, video_devices;
888 for (StreamDeviceInfoArray::const_iterator device_it =
889 requested_devices.begin();
890 device_it != requested_devices.end(); ++device_it) {
891 if (IsAudioMediaType(device_it->device.type)) {
892 audio_devices.push_back(*device_it);
893 } else if (IsVideoMediaType(device_it->device.type)) {
894 video_devices.push_back(*device_it);
895 } else {
896 NOTREACHED();
897 }
898 }
899
900 request->requester->StreamGenerated(label, audio_devices, video_devices);
901 break; 1075 break;
902 } 1076 }
903 default: 1077 default:
904 NOTREACHED(); 1078 NOTREACHED();
905 break; 1079 break;
906 } 1080 }
907 1081
908 if (request->ui_proxy.get()) { 1082 if (request->ui_proxy.get()) {
909 request->ui_proxy->OnStarted( 1083 request->ui_proxy->OnStarted(
910 base::Bind(&MediaStreamManager::StopMediaStreamFromBrowser, 1084 base::Bind(&MediaStreamManager::StopMediaStreamFromBrowser,
(...skipping 22 matching lines...) Expand all
933 !std::equal(devices.begin(), devices.end(), cache->devices.begin(), 1107 !std::equal(devices.begin(), devices.end(), cache->devices.begin(),
934 StreamDeviceInfo::IsEqual)) { 1108 StreamDeviceInfo::IsEqual)) {
935 StopRemovedDevices(cache->devices, devices); 1109 StopRemovedDevices(cache->devices, devices);
936 cache->devices = devices; 1110 cache->devices = devices;
937 need_update_clients = true; 1111 need_update_clients = true;
938 1112
939 // The device might not be able to be enumerated when it is not warmed up, 1113 // The device might not be able to be enumerated when it is not warmed up,
940 // for example, when the machine just wakes up from sleep. We set the cache 1114 // for example, when the machine just wakes up from sleep. We set the cache
941 // to be invalid so that the next media request will trigger the 1115 // to be invalid so that the next media request will trigger the
942 // enumeration again. See issue/317673. 1116 // enumeration again. See issue/317673.
943 if (devices.size()) 1117 cache->valid = devices.size() ? true : false;
tommi (sloooow) - chröme 2013/11/26 14:44:21 nit: cache->valid = !devices.empty();
perkj_chrome 2013/11/27 13:41:34 Done.
944 cache->valid = true;
945 else
946 cache->valid = false;
947 } 1118 }
948 1119
949 if (need_update_clients && monitoring_started_) 1120 if (need_update_clients && monitoring_started_)
950 NotifyDevicesChanged(stream_type, devices); 1121 NotifyDevicesChanged(stream_type, devices);
951 1122
952 // Publish the result for all requests waiting for device list(s). 1123 // Publish the result for all requests waiting for device list(s).
953 // Find the requests waiting for this device list, store their labels and 1124 // Find the requests waiting for this device list, store their labels and
954 // release the iterator before calling device settings. We might get a call 1125 // release the iterator before calling device settings. We might get a call
955 // back from device_settings that will need to iterate through devices. 1126 // back from device_settings that will need to iterate through devices.
956 std::list<std::string> label_list; 1127 std::list<std::string> label_list;
957 for (DeviceRequests::iterator it = requests_.begin(); it != requests_.end(); 1128 for (DeviceRequests::iterator it = requests_.begin(); it != requests_.end();
958 ++it) { 1129 ++it) {
959 if (it->second->state(stream_type) == MEDIA_REQUEST_STATE_REQUESTED && 1130 if (it->second->state(stream_type) == MEDIA_REQUEST_STATE_REQUESTED &&
960 Requested(it->second->request, stream_type)) { 1131 Requested(it->second->request, stream_type)) {
961 if (it->second->request.request_type != MEDIA_ENUMERATE_DEVICES) 1132 if (it->second->request.request_type != MEDIA_ENUMERATE_DEVICES)
962 it->second->SetState(stream_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL); 1133 it->second->SetState(stream_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL);
963 label_list.push_back(it->first); 1134 label_list.push_back(it->first);
964 } 1135 }
965 } 1136 }
966 for (std::list<std::string>::iterator it = label_list.begin(); 1137 for (std::list<std::string>::iterator it = label_list.begin();
967 it != label_list.end(); ++it) { 1138 it != label_list.end(); ++it) {
968 DeviceRequest* request = requests_[*it]; 1139 DeviceRequest* request = FindRequest(*it);
969 switch (request->request.request_type) { 1140 switch (request->request.request_type) {
970 case MEDIA_ENUMERATE_DEVICES: 1141 case MEDIA_ENUMERATE_DEVICES:
971 if (need_update_clients && request->requester) 1142 if (need_update_clients && request->requester) {
972 request->requester->DevicesEnumerated(*it, devices); 1143 request->devices = devices;
1144 FinalizeEnumerateDevices(*it, request);
1145 }
973 break; 1146 break;
974 default: 1147 default:
975 if (request->state(request->request.audio_type) == 1148 if (request->state(request->request.audio_type) ==
976 MEDIA_REQUEST_STATE_REQUESTED || 1149 MEDIA_REQUEST_STATE_REQUESTED ||
977 request->state(request->request.video_type) == 1150 request->state(request->request.video_type) ==
978 MEDIA_REQUEST_STATE_REQUESTED) { 1151 MEDIA_REQUEST_STATE_REQUESTED) {
979 // We are doing enumeration for other type of media, wait until it is 1152 // We are doing enumeration for other type of media, wait until it is
980 // all done before posting the request to UI because UI needs 1153 // all done before posting the request to UI because UI needs
981 // the device lists to handle the request. 1154 // the device lists to handle the request.
982 break; 1155 break;
983 } 1156 }
984 1157
985 // Post the request to UI for permission approval. 1158 PostRequestToUI(*it, request);
986 PostRequestToUI(*it);
987 break; 1159 break;
988 } 1160 }
989 } 1161 }
990 label_list.clear(); 1162 label_list.clear();
991 --active_enumeration_ref_count_[stream_type]; 1163 --active_enumeration_ref_count_[stream_type];
992 DCHECK_GE(active_enumeration_ref_count_[stream_type], 0); 1164 DCHECK_GE(active_enumeration_ref_count_[stream_type], 0);
993 } 1165 }
994 1166
995 void MediaStreamManager::HandleAccessRequestResponse( 1167 void MediaStreamManager::HandleAccessRequestResponse(
996 const std::string& label, 1168 const std::string& label,
997 const MediaStreamDevices& devices) { 1169 const MediaStreamDevices& devices) {
998 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1170 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
999 DVLOG(1) << "HandleAccessRequestResponse(" 1171 DVLOG(1) << "HandleAccessRequestResponse("
1000 << ", {label = " << label << "})"; 1172 << ", {label = " << label << "})";
1001 1173
1002 DeviceRequests::iterator request_it = requests_.find(label); 1174 DeviceRequest* request = FindRequest(label);
1003 if (request_it == requests_.end()) { 1175 if (!request) {
1176 // The request has been canceled before the UI returns.
tommi (sloooow) - chröme 2013/11/26 14:44:21 nit: The request was canceled before the UI return
perkj_chrome 2013/11/27 13:41:34 Done.
1177 return;
1178 }
1179
1180 if (request->request.request_type == MEDIA_DEVICE_ACCESS) {
1181 FinalizeMediaAccessRequest(label, request, devices);
1004 return; 1182 return;
1005 } 1183 }
1006 1184
1007 // Handle the case when the request was denied. 1185 // Handle the case when the request was denied.
1008 if (devices.empty()) { 1186 if (devices.empty()) {
1009 // Notify the users about the request result. 1187 FinalizeRequestFailed(label, request);
1010 scoped_ptr<DeviceRequest> request(request_it->second);
1011 if (request->requester)
1012 request->requester->StreamGenerationFailed(label);
1013
1014 if (request->request.request_type == MEDIA_DEVICE_ACCESS &&
1015 !request->callback.is_null()) {
1016 request->callback.Run(MediaStreamDevices(), request->ui_proxy.Pass());
1017 }
1018
1019 RemoveRequest(request_it);
1020 return;
1021 }
1022
1023 if (request_it->second->request.request_type == MEDIA_DEVICE_ACCESS) {
1024 scoped_ptr<DeviceRequest> request(request_it->second);
1025 if (!request->callback.is_null())
1026 request->callback.Run(devices, request->ui_proxy.Pass());
1027
1028 // Delete the request since it is done.
1029 RemoveRequest(request_it);
1030 return; 1188 return;
1031 } 1189 }
1032 1190
1033 // Process all newly-accepted devices for this request. 1191 // Process all newly-accepted devices for this request.
1034 DeviceRequest* request = request_it->second;
1035 bool found_audio = false; 1192 bool found_audio = false;
1036 bool found_video = false; 1193 bool found_video = false;
1037 for (MediaStreamDevices::const_iterator device_it = devices.begin(); 1194 for (MediaStreamDevices::const_iterator device_it = devices.begin();
1038 device_it != devices.end(); ++device_it) { 1195 device_it != devices.end(); ++device_it) {
1039 StreamDeviceInfo device_info; 1196 StreamDeviceInfo device_info;
1040 device_info.device = *device_it; 1197 device_info.device = *device_it;
1041 1198
1042 // TODO(justinlin): Nicer way to do this? 1199 // TODO(justinlin): Nicer way to do this?
1043 // Re-append the device's id since we lost it when posting request to UI. 1200 // Re-append the device's id since we lost it when posting request to UI.
1044 if (device_info.device.type == content::MEDIA_TAB_VIDEO_CAPTURE || 1201 if (device_info.device.type == content::MEDIA_TAB_VIDEO_CAPTURE ||
(...skipping 20 matching lines...) Expand all
1065 if (device_info.device.type == request->request.audio_type) { 1222 if (device_info.device.type == request->request.audio_type) {
1066 found_audio = true; 1223 found_audio = true;
1067 } else if (device_info.device.type == request->request.video_type) { 1224 } else if (device_info.device.type == request->request.video_type) {
1068 found_video = true; 1225 found_video = true;
1069 } 1226 }
1070 1227
1071 // If this is request for a new MediaStream, a device is only opened once 1228 // If this is request for a new MediaStream, a device is only opened once
1072 // per render view. This is so that the permission to use a device can be 1229 // per render view. This is so that the permission to use a device can be
1073 // revoked by a single call to StopStreamDevice regardless of how many 1230 // revoked by a single call to StopStreamDevice regardless of how many
1074 // MediaStreams it is being used in. 1231 // MediaStreams it is being used in.
1075
1076 if (request->request.request_type == MEDIA_GENERATE_STREAM) { 1232 if (request->request.request_type == MEDIA_GENERATE_STREAM) {
1077 MediaRequestState state; 1233 MediaRequestState state;
1078 if (FindExistingRequestedDeviceInfo(request->requesting_process_id, 1234 if (FindExistingRequestedDeviceInfo(request->requesting_process_id,
1079 request->requesting_view_id, 1235 request->requesting_view_id,
1236 request->request.security_origin,
1080 request->request.request_type, 1237 request->request.request_type,
1081 device_it->id, 1238 device_info.device.id,
1239 device_info.device.type,
1082 &device_info, 1240 &device_info,
1083 &state)) { 1241 &state)) {
1084 request->devices.push_back(device_info); 1242 request->devices.push_back(device_info);
1085 request->SetState(device_info.device.type, state); 1243 request->SetState(device_info.device.type, state);
1086 DVLOG(1) << "HandleAccessRequestResponse - device already opened " 1244 DVLOG(1) << "HandleAccessRequestResponse - device already opened "
1087 << ", {label = " << label << "}" 1245 << ", {label = " << label << "}"
1088 << ", device_id = " << device_it->id << "}"; 1246 << ", device_id = " << device_it->id << "}";
1089 continue; 1247 continue;
1090 } 1248 }
1091 } 1249 }
1092 device_info.session_id = 1250 device_info.session_id =
1093 GetDeviceManager(device_info.device.type)->Open(device_info); 1251 GetDeviceManager(device_info.device.type)->Open(device_info);
1252 TranslateDeviceIdToSourceId(request->request, &device_info.device);
1094 request->devices.push_back(device_info); 1253 request->devices.push_back(device_info);
1254
1095 request->SetState(device_info.device.type, MEDIA_REQUEST_STATE_OPENING); 1255 request->SetState(device_info.device.type, MEDIA_REQUEST_STATE_OPENING);
1096 DVLOG(1) << "HandleAccessRequestResponse - opening device " 1256 DVLOG(1) << "HandleAccessRequestResponse - opening device "
1097 << ", {label = " << label << "}" 1257 << ", {label = " << label << "}"
1098 << ", {device_id = " << device_it->id << "}" 1258 << ", {device_id = " << device_info.device.id << "}"
1099 << ", {session_id = " << device_info.session_id << "}"; 1259 << ", {session_id = " << device_info.session_id << "}";
1100 } 1260 }
1101 1261
1102 // Check whether we've received all stream types requested. 1262 // Check whether we've received all stream types requested.
1103 if (!found_audio && IsAudioMediaType(request->request.audio_type)) { 1263 if (!found_audio && IsAudioMediaType(request->request.audio_type)) {
1104 request->SetState(request->request.audio_type, MEDIA_REQUEST_STATE_ERROR); 1264 request->SetState(request->request.audio_type, MEDIA_REQUEST_STATE_ERROR);
1105 DVLOG(1) << "Set no audio found label " << label; 1265 DVLOG(1) << "Set no audio found label " << label;
1106 } 1266 }
1107 1267
1108 if (!found_video && IsVideoMediaType(request->request.video_type)) 1268 if (!found_video && IsVideoMediaType(request->request.video_type))
1109 request->SetState(request->request.video_type, MEDIA_REQUEST_STATE_ERROR); 1269 request->SetState(request->request.video_type, MEDIA_REQUEST_STATE_ERROR);
1110 1270
1111 if (RequestDone(*request)) 1271 if (RequestDone(*request))
1112 HandleRequestDone(label, request); 1272 HandleRequestDone(label, request);
1113 } 1273 }
1114 1274
1115 void MediaStreamManager::StopMediaStreamFromBrowser(const std::string& label) { 1275 void MediaStreamManager::StopMediaStreamFromBrowser(const std::string& label) {
1116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1276 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1117 1277
1118 DeviceRequests::iterator it = requests_.find(label); 1278 DeviceRequest* request = FindRequest(label);
1119 if (it == requests_.end()) 1279 if (!request)
1120 return; 1280 return;
1121 1281
1122 DeviceRequest* request = it->second;
1123 // Notify renderers that the devices in the stream will be stopped. 1282 // Notify renderers that the devices in the stream will be stopped.
1124 if (request->requester) { 1283 if (request->requester) {
1125 for (StreamDeviceInfoArray::iterator device_it = request->devices.begin(); 1284 for (StreamDeviceInfoArray::iterator device_it = request->devices.begin();
1126 device_it != request->devices.end(); ++device_it) { 1285 device_it != request->devices.end(); ++device_it) {
1127 request->requester->DeviceStopped(request->requesting_view_id, 1286 request->requester->DeviceStopped(request->requesting_view_id,
1128 label, 1287 label,
1129 *device_it); 1288 *device_it);
1130 } 1289 }
1131 } 1290 }
1132 1291
1133 CancelRequest(label); 1292 CancelRequest(label);
1134 } 1293 }
1135 1294
1136 void MediaStreamManager::UseFakeDevice() { 1295 void MediaStreamManager::UseFakeDevice() {
1137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1296 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1138 video_capture_manager()->UseFakeDevice(); 1297 video_capture_manager()->UseFakeDevice();
1139 audio_input_device_manager()->UseFakeDevice(); 1298 audio_input_device_manager()->UseFakeDevice();
1140 } 1299 }
1141 1300
1142 void MediaStreamManager::UseFakeUI(scoped_ptr<FakeMediaStreamUIProxy> fake_ui) { 1301 void MediaStreamManager::UseFakeUI(scoped_ptr<FakeMediaStreamUIProxy> fake_ui) {
1143 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1302 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1144 use_fake_ui_ = true; 1303 use_fake_ui_ = true;
1145 fake_ui_ = fake_ui.Pass(); 1304 fake_ui_ = fake_ui.Pass();
1146 } 1305 }
1147 1306
1148 void MediaStreamManager::WillDestroyCurrentMessageLoop() { 1307 void MediaStreamManager::WillDestroyCurrentMessageLoop() {
1308 DVLOG(3) << "MediaStreamManager::WillDestroyCurrentMessageLoop()";
1149 DCHECK_EQ(base::MessageLoop::current(), io_loop_); 1309 DCHECK_EQ(base::MessageLoop::current(), io_loop_);
1150 DCHECK(requests_.empty()); 1310 DCHECK(requests_.empty());
1151 if (device_thread_) { 1311 if (device_thread_) {
1152 StopMonitoring(); 1312 StopMonitoring();
1153 1313
1154 video_capture_manager_->Unregister(); 1314 video_capture_manager_->Unregister();
1155 audio_input_device_manager_->Unregister(); 1315 audio_input_device_manager_->Unregister();
1156 device_thread_.reset(); 1316 device_thread_.reset();
1157 } 1317 }
1158 1318
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 } 1400 }
1241 1401
1242 // Always do enumeration even though some enumeration is in progress, 1402 // Always do enumeration even though some enumeration is in progress,
1243 // because those enumeration commands could be sent before these devices 1403 // because those enumeration commands could be sent before these devices
1244 // change. 1404 // change.
1245 ++active_enumeration_ref_count_[stream_type]; 1405 ++active_enumeration_ref_count_[stream_type];
1246 GetDeviceManager(stream_type)->EnumerateDevices(stream_type); 1406 GetDeviceManager(stream_type)->EnumerateDevices(stream_type);
1247 } 1407 }
1248 1408
1249 } // namespace content 1409 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698