OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/media/capture/desktop_capture_device.h" | 5 #include "content/browser/media/capture/desktop_capture_device.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
444 return result.Pass(); | 444 return result.Pass(); |
445 } | 445 } |
446 | 446 |
447 DesktopCaptureDevice::~DesktopCaptureDevice() { | 447 DesktopCaptureDevice::~DesktopCaptureDevice() { |
448 DCHECK(!core_); | 448 DCHECK(!core_); |
449 } | 449 } |
450 | 450 |
451 void DesktopCaptureDevice::AllocateAndStart( | 451 void DesktopCaptureDevice::AllocateAndStart( |
452 const media::VideoCaptureParams& params, | 452 const media::VideoCaptureParams& params, |
453 scoped_ptr<Client> client) { | 453 scoped_ptr<Client> client) { |
454 thread_.message_loop_proxy()->PostTask( | 454 thread_.task_runner()->PostTask( |
455 FROM_HERE, | 455 FROM_HERE, |
456 base::Bind(&Core::AllocateAndStart, base::Unretained(core_.get()), params, | 456 base::Bind(&Core::AllocateAndStart, base::Unretained(core_.get()), params, |
457 base::Passed(&client))); | 457 base::Passed(&client))); |
458 } | 458 } |
459 | 459 |
460 void DesktopCaptureDevice::StopAndDeAllocate() { | 460 void DesktopCaptureDevice::StopAndDeAllocate() { |
461 if (core_) { | 461 if (core_) { |
462 thread_.message_loop_proxy()->DeleteSoon(FROM_HERE, core_.release()); | 462 thread_.task_runner()->DeleteSoon(FROM_HERE, core_.release()); |
463 thread_.Stop(); | 463 thread_.Stop(); |
464 } | 464 } |
465 } | 465 } |
466 | 466 |
467 void DesktopCaptureDevice::SetNotificationWindowId( | 467 void DesktopCaptureDevice::SetNotificationWindowId( |
468 gfx::NativeViewId window_id) { | 468 gfx::NativeViewId window_id) { |
469 thread_.message_loop_proxy()->PostTask( | 469 // This may be called after the capturer has been stopped. |
470 FROM_HERE, | 470 if (core_) { |
Sergey Ulanov
2015/02/03 18:15:16
nit: This can be more readable with "if (!core_)\n
| |
471 base::Bind(&Core::SetNotificationWindowId, base::Unretained(core_.get()), | 471 thread_.task_runner()->PostTask( |
472 window_id)); | 472 FROM_HERE, |
473 base::Bind(&Core::SetNotificationWindowId, | |
474 base::Unretained(core_.get()), | |
475 window_id)); | |
476 } | |
473 } | 477 } |
474 | 478 |
475 DesktopCaptureDevice::DesktopCaptureDevice( | 479 DesktopCaptureDevice::DesktopCaptureDevice( |
476 scoped_ptr<webrtc::DesktopCapturer> capturer, | 480 scoped_ptr<webrtc::DesktopCapturer> capturer, |
477 DesktopMediaID::Type type) | 481 DesktopMediaID::Type type) |
478 : thread_("desktopCaptureThread") { | 482 : thread_("desktopCaptureThread") { |
479 #if defined(OS_WIN) | 483 #if defined(OS_WIN) |
480 // On Windows the thread must be a UI thread. | 484 // On Windows the thread must be a UI thread. |
481 base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_UI; | 485 base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_UI; |
482 #else | 486 #else |
483 base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_DEFAULT; | 487 base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_DEFAULT; |
484 #endif | 488 #endif |
485 | 489 |
486 thread_.StartWithOptions(base::Thread::Options(thread_type, 0)); | 490 thread_.StartWithOptions(base::Thread::Options(thread_type, 0)); |
487 | 491 |
488 core_.reset(new Core(thread_.message_loop_proxy(), capturer.Pass(), type)); | 492 core_.reset(new Core(thread_.task_runner(), capturer.Pass(), type)); |
489 } | 493 } |
490 | 494 |
491 } // namespace content | 495 } // namespace content |
OLD | NEW |