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

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

Issue 252393002: Adds UMA histograms for desktop capture device. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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
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 2c7d196531b121795f84848105a6603edba4bf54..86bc271dab6f22b2242bae6fff42474d9f20bf06 100644
--- a/content/browser/media/capture/desktop_capture_device_aura.cc
+++ b/content/browser/media/capture/desktop_capture_device_aura.cc
@@ -5,11 +5,13 @@
#include "content/browser/media/capture/desktop_capture_device_aura.h"
#include "base/logging.h"
+#include "base/metrics/histogram.h"
#include "base/timer/timer.h"
#include "cc/output/copy_output_request.h"
#include "cc/output/copy_output_result.h"
#include "content/browser/compositor/image_transport_factory.h"
#include "content/browser/media/capture/content_video_capture_device_core.h"
+#include "content/browser/media/capture/desktop_capture_device_uma_types.h"
#include "content/common/gpu/client/gl_helper.h"
#include "content/public/browser/browser_thread.h"
#include "media/base/video_util.h"
@@ -129,6 +131,14 @@ class DesktopVideoCaptureMachine
const ThreadSafeCaptureOracle::CaptureFrameCallback& capture_frame_cb,
scoped_ptr<cc::CopyOutputResult> result);
+ // A helper which does the real work for DidCopyOutput. Returns true if
+ // succeeded.
+ bool ProcessCopyOutputResponse(
+ scoped_refptr<media::VideoFrame> video_frame,
+ base::TimeTicks start_time,
+ const ThreadSafeCaptureOracle::CaptureFrameCallback& capture_frame_cb,
+ scoped_ptr<cc::CopyOutputResult> result);
+
// Helper function to update cursor state.
// |region_in_frame| defines the desktop bound in the captured frame.
// Returns the current cursor position in captured frame.
@@ -292,8 +302,37 @@ void DesktopVideoCaptureMachine::DidCopyOutput(
base::TimeTicks start_time,
const ThreadSafeCaptureOracle::CaptureFrameCallback& capture_frame_cb,
scoped_ptr<cc::CopyOutputResult> result) {
+ static bool first_call = true;
+
+ bool succeeded = ProcessCopyOutputResponse(
+ video_frame, start_time, capture_frame_cb, result.Pass());
+
+ base::TimeDelta capture_time = base::TimeTicks::Now() - start_time;
+ UMA_HISTOGRAM_TIMES(
+ window_id_.type == DesktopMediaID::TYPE_SCREEN ? kUmaScreenCaptureTime
+ : kUmaWindowCaptureTime,
+ capture_time);
+
+ if (first_call) {
+ first_call = false;
+ if (window_id_.type == DesktopMediaID::TYPE_SCREEN) {
+ IncrementDesktopCaptureCounter(succeeded ? FIRST_SCREEN_CAPTURE_SUCCEEDED
+ : FIRST_SCREEN_CAPTURE_FAILED);
+ } else {
+ IncrementDesktopCaptureCounter(succeeded
+ ? FIRST_WINDOW_CAPTURE_SUCCEEDED
+ : FIRST_WINDOW_CAPTURE_SUCCEEDED);
+ }
+ }
+}
+
+bool DesktopVideoCaptureMachine::ProcessCopyOutputResponse(
+ scoped_refptr<media::VideoFrame> video_frame,
+ base::TimeTicks start_time,
+ const ThreadSafeCaptureOracle::CaptureFrameCallback& capture_frame_cb,
+ scoped_ptr<cc::CopyOutputResult> result) {
if (result->IsEmpty() || result->size().IsEmpty() || !desktop_layer_)
- return;
+ return false;
// Compute the dest size we want after the letterboxing resize. Make the
// coordinates and sizes even because we letterbox in YUV space
@@ -309,19 +348,19 @@ void DesktopVideoCaptureMachine::DidCopyOutput(
region_in_frame.width() & ~1,
region_in_frame.height() & ~1);
if (region_in_frame.IsEmpty())
- return;
+ return false;
ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
GLHelper* gl_helper = factory->GetGLHelper();
if (!gl_helper)
- return;
+ return false;
cc::TextureMailbox texture_mailbox;
scoped_ptr<cc::SingleReleaseCallback> release_callback;
result->TakeTexture(&texture_mailbox, &release_callback);
DCHECK(texture_mailbox.IsTexture());
if (!texture_mailbox.IsTexture())
- return;
+ return false;
gfx::Rect result_rect(result->size());
if (!yuv_readback_pipeline_ ||
@@ -350,6 +389,7 @@ void DesktopVideoCaptureMachine::DidCopyOutput(
scaled_cursor_bitmap_,
cursor_position_in_frame,
base::Passed(&release_callback)));
+ return true;
}
gfx::Point DesktopVideoCaptureMachine::UpdateCursorState(
@@ -432,6 +472,9 @@ DesktopCaptureDeviceAura::~DesktopCaptureDeviceAura() {
// static
media::VideoCaptureDevice* DesktopCaptureDeviceAura::Create(
const DesktopMediaID& source) {
+ IncrementDesktopCaptureCounter(source.type == DesktopMediaID::TYPE_SCREEN
+ ? SCREEN_CAPTURER_CREATED
+ : WINDOW_CATPTURER_CREATED);
return new DesktopCaptureDeviceAura(source);
}

Powered by Google App Engine
This is Rietveld 408576698