Add long running gmail memory benchmark for background tab.
[chromium-blink-merge.git] / content / browser / media / capture / desktop_capture_device_aura.cc
blob8ecc610807ee29a6829825fa81f192e17cc00287
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/browser/media/capture/desktop_capture_device_aura.h"
7 #include "base/logging.h"
8 #include "base/timer/timer.h"
9 #include "content/browser/media/capture/aura_window_capture_machine.h"
10 #include "content/public/browser/browser_thread.h"
11 #include "ui/aura/window.h"
13 namespace content {
15 namespace {
17 void SetCaptureSource(AuraWindowCaptureMachine* machine,
18 const DesktopMediaID& source) {
19 DCHECK_CURRENTLY_ON(BrowserThread::UI);
21 aura::Window* window = DesktopMediaID::GetAuraWindowById(source);
22 machine->SetWindow(window);
25 } // namespace
27 DesktopCaptureDeviceAura::DesktopCaptureDeviceAura(
28 const DesktopMediaID& source) {
29 AuraWindowCaptureMachine* machine = new AuraWindowCaptureMachine();
30 core_.reset(new media::ScreenCaptureDeviceCore(make_scoped_ptr(machine)));
31 // |core_| owns |machine| and deletes it on UI thread so passing the raw
32 // pointer to the UI thread is safe here.
33 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
34 base::Bind(&SetCaptureSource, machine, source));
37 DesktopCaptureDeviceAura::~DesktopCaptureDeviceAura() {
38 DVLOG(2) << "DesktopCaptureDeviceAura@" << this << " destroying.";
41 // static
42 media::VideoCaptureDevice* DesktopCaptureDeviceAura::Create(
43 const DesktopMediaID& source) {
44 return new DesktopCaptureDeviceAura(source);
47 void DesktopCaptureDeviceAura::AllocateAndStart(
48 const media::VideoCaptureParams& params,
49 scoped_ptr<Client> client) {
50 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString();
51 core_->AllocateAndStart(params, client.Pass());
54 void DesktopCaptureDeviceAura::StopAndDeAllocate() {
55 core_->StopAndDeAllocate();
58 } // namespace content