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

Unified Diff: content/browser/media/capture/desktop_capture_device_aura.cc

Issue 974513002: content: Split out VideoCaptureMachine from DesktopCaptureDeviceAura (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/media/capture/desktop_capture_device_aura.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(
« no previous file with comments | « content/browser/media/capture/desktop_capture_device_aura.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698