summaryrefslogtreecommitdiffstats
path: root/content/browser/media/capture/window_activity_tracker_aura.cc
diff options
context:
space:
mode:
authorisheriff <isheriff@chromium.org>2016-03-25 18:11:38 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-26 01:12:54 +0000
commit76bb611f077321a06f5df9a22e414bb99722c479 (patch)
treef82e2c8fbfc6fc0f2ce8661e56a6de20d0e8bc1d /content/browser/media/capture/window_activity_tracker_aura.cc
parent934f67a68da2054e526e13648c5452e2cf79c211 (diff)
downloadchromium_src-76bb611f077321a06f5df9a22e414bb99722c479.zip
chromium_src-76bb611f077321a06f5df9a22e414bb99722c479.tar.gz
chromium_src-76bb611f077321a06f5df9a22e414bb99722c479.tar.bz2
cast: Add window activity tracker for mac
This adds window activity detector for mac which enables the following features to be enabled on tab mirroring: - Low latency interactive mode will be turned on when user is interactive with non-animating content - Frame subscriber will enable frame capture in response to mouse events resulting in smooth rendering of mouse while mirroring BUG=567735 Review URL: https://codereview.chromium.org/1835493002 Cr-Commit-Position: refs/heads/master@{#383431}
Diffstat (limited to 'content/browser/media/capture/window_activity_tracker_aura.cc')
-rw-r--r--content/browser/media/capture/window_activity_tracker_aura.cc46
1 files changed, 14 insertions, 32 deletions
diff --git a/content/browser/media/capture/window_activity_tracker_aura.cc b/content/browser/media/capture/window_activity_tracker_aura.cc
index 035c0ca..bc139aa 100644
--- a/content/browser/media/capture/window_activity_tracker_aura.cc
+++ b/content/browser/media/capture/window_activity_tracker_aura.cc
@@ -11,21 +11,15 @@
namespace content {
-namespace {
-// The time period within which a triggered UI event is considered
-// currently active.
-const int kTimePeriodUiEventMicros = 100000; // 100 ms
-
-// Minimum number of user interactions before we consider the user to be in
-// interactive mode. The goal is to prevent user interactions to launch
-// animated content from causing target playout time flip-flop.
-const int kMinUserInteractions = 5;
-} // namespace
+// static
+scoped_ptr<WindowActivityTracker> WindowActivityTracker::Create(
+ gfx::NativeView window) {
+ return scoped_ptr<WindowActivityTracker>(
+ new WindowActivityTrackerAura(window));
+}
WindowActivityTrackerAura::WindowActivityTrackerAura(aura::Window* window)
: window_(window),
- last_time_ui_event_detected_(base::TimeTicks()),
- ui_events_count_(0),
weak_factory_(this) {
if (window_) {
window_->AddObserver(this);
@@ -44,28 +38,16 @@ base::WeakPtr<WindowActivityTracker> WindowActivityTrackerAura::GetWeakPtr() {
return weak_factory_.GetWeakPtr();
}
-bool WindowActivityTrackerAura::IsUiInteractionActive() const {
- return ui_events_count_ > kMinUserInteractions;
-}
-
-void WindowActivityTrackerAura::RegisterMouseInteractionObserver(
- const base::Closure& observer) {
- mouse_interaction_observer_ = observer;
-}
-
-void WindowActivityTrackerAura::Reset() {
- ui_events_count_ = 0;
- last_time_ui_event_detected_ = base::TimeTicks();
-}
-
void WindowActivityTrackerAura::OnEvent(ui::Event* event) {
- if (!mouse_interaction_observer_.is_null() && event->IsMouseEvent())
- mouse_interaction_observer_.Run();
- if (base::TimeTicks::Now() - last_time_ui_event_detected_ >
- base::TimeDelta::FromMicroseconds(kTimePeriodUiEventMicros)) {
- ui_events_count_++;
+ switch (event->type()) {
+ case ui::ET_MOUSE_PRESSED:
+ case ui::ET_MOUSE_RELEASED:
+ case ui::ET_MOUSE_MOVED:
+ WindowActivityTracker::OnMouseActivity();
+ break;
+ default:
+ break;
}
- last_time_ui_event_detected_ = base::TimeTicks::Now();
}
void WindowActivityTrackerAura::OnWindowDestroying(aura::Window* window) {