Chromium Code Reviews| Index: content/browser/media/capture/desktop_capture_device_aura.cc |
| diff --git a/content/browser/media/capture/desktop_capture_device_aura.cc b/content/browser/media/capture/desktop_capture_device_aura.cc |
| index 37979613dddf0572340bda84df472ae3df7c2033..741e4b8062a67bde891c60c623fd93c041e6b329 100644 |
| --- a/content/browser/media/capture/desktop_capture_device_aura.cc |
| +++ b/content/browser/media/capture/desktop_capture_device_aura.cc |
| @@ -95,7 +95,7 @@ class DesktopVideoCaptureMachine |
| public ui::CompositorObserver, |
| public base::SupportsWeakPtr<DesktopVideoCaptureMachine> { |
| public: |
| - DesktopVideoCaptureMachine(const DesktopMediaID& source); |
| + DesktopVideoCaptureMachine(aura::Window* window); |
| ~DesktopVideoCaptureMachine() override; |
| // VideoCaptureFrameSource overrides. |
| @@ -158,9 +158,6 @@ class DesktopVideoCaptureMachine |
| // The timer that kicks off period captures. |
| base::Timer timer_; |
| - // The id of the window being captured. |
| - DesktopMediaID window_id_; |
| - |
| // Makes all the decisions about which frames to copy, and how. |
| scoped_refptr<ThreadSafeCaptureOracle> oracle_proxy_; |
| @@ -182,11 +179,13 @@ class DesktopVideoCaptureMachine |
| DISALLOW_COPY_AND_ASSIGN(DesktopVideoCaptureMachine); |
| }; |
| -DesktopVideoCaptureMachine::DesktopVideoCaptureMachine( |
| - const DesktopMediaID& source) |
| - : desktop_window_(NULL), |
| - timer_(true, true), |
| - window_id_(source) {} |
| +DesktopVideoCaptureMachine::DesktopVideoCaptureMachine(aura::Window* window) |
| + : desktop_window_(window), |
| + timer_(true, true) { |
| + IncrementDesktopCaptureCounter(window->IsRootWindow() |
| + ? SCREEN_CAPTURER_CREATED |
| + : WINDOW_CAPTURER_CREATED); |
| +} |
| DesktopVideoCaptureMachine::~DesktopVideoCaptureMachine() {} |
| @@ -195,10 +194,6 @@ bool DesktopVideoCaptureMachine::Start( |
| const media::VideoCaptureParams& params) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| - desktop_window_ = content::DesktopMediaID::GetAuraWindowById(window_id_); |
| - if (!desktop_window_) |
| - return false; |
| - |
| // If the associated layer is already destroyed then return failure. |
| ui::Layer* layer = desktop_window_->layer(); |
| if (!layer) |
| @@ -322,7 +317,7 @@ void DesktopVideoCaptureMachine::DidCopyOutput( |
| // The two UMA_ blocks must be put in its own scope since it creates a static |
| // variable which expected constant histogram name. |
| - if (window_id_.type == DesktopMediaID::TYPE_SCREEN) { |
| + if (desktop_window_->IsRootWindow()) { |
| UMA_HISTOGRAM_TIMES(kUmaScreenCaptureTime, capture_time); |
| } else { |
| UMA_HISTOGRAM_TIMES(kUmaWindowCaptureTime, capture_time); |
| @@ -330,7 +325,7 @@ void DesktopVideoCaptureMachine::DidCopyOutput( |
| if (first_call) { |
| first_call = false; |
| - if (window_id_.type == DesktopMediaID::TYPE_SCREEN) { |
| + if (desktop_window_->IsRootWindow()) { |
| IncrementDesktopCaptureCounter(succeeded ? FIRST_SCREEN_CAPTURE_SUCCEEDED |
| : FIRST_SCREEN_CAPTURE_FAILED); |
| } else { |
| @@ -510,10 +505,9 @@ void DesktopVideoCaptureMachine::OnCompositingEnded( |
| } // namespace |
| -DesktopCaptureDeviceAura::DesktopCaptureDeviceAura( |
| - const DesktopMediaID& source) |
| +DesktopCaptureDeviceAura::DesktopCaptureDeviceAura(aura::Window* window) |
| : core_(new ContentVideoCaptureDeviceCore(scoped_ptr<VideoCaptureMachine>( |
| - new DesktopVideoCaptureMachine(source)))) {} |
| + new DesktopVideoCaptureMachine(window)))) {} |
| DesktopCaptureDeviceAura::~DesktopCaptureDeviceAura() { |
| DVLOG(2) << "DesktopCaptureDeviceAura@" << this << " destroying."; |
| @@ -522,10 +516,8 @@ DesktopCaptureDeviceAura::~DesktopCaptureDeviceAura() { |
| // static |
| media::VideoCaptureDevice* DesktopCaptureDeviceAura::Create( |
| const DesktopMediaID& source) { |
| - IncrementDesktopCaptureCounter(source.type == DesktopMediaID::TYPE_SCREEN |
| - ? SCREEN_CAPTURER_CREATED |
| - : WINDOW_CAPTURER_CREATED); |
| - return new DesktopCaptureDeviceAura(source); |
| + aura::Window* window = content::DesktopMediaID::GetAuraWindowById(source); |
|
Sergey Ulanov
2015/03/02 21:58:58
DesktopMediaID::GetAuraWindowById() is not thread-
|
| + return new DesktopCaptureDeviceAura(window); |
| } |
| void DesktopCaptureDeviceAura::AllocateAndStart( |