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

Unified Diff: chrome/browser/metrics/desktop_engagement/chrome_visibility_observer.h

Issue 2142983002: Add desktop engagement metrics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments and fix mac bot Created 4 years, 5 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: chrome/browser/metrics/desktop_engagement/chrome_visibility_observer.h
diff --git a/chrome/browser/metrics/desktop_engagement/chrome_visibility_observer.h b/chrome/browser/metrics/desktop_engagement/chrome_visibility_observer.h
new file mode 100644
index 0000000000000000000000000000000000000000..3135c6c37cf5da02e026bfae55f3af5aec04d7ae
--- /dev/null
+++ b/chrome/browser/metrics/desktop_engagement/chrome_visibility_observer.h
@@ -0,0 +1,51 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_METRICS_DESKTOP_ENGAGEMENT_CHROME_VISIBILITY_OBSERVER_H_
+#define CHROME_BROWSER_METRICS_DESKTOP_ENGAGEMENT_CHROME_VISIBILITY_OBSERVER_H_
+
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/ui/browser_list_observer.h"
+
+namespace metrics {
+
+// Observer for tracking browser visibility events.
+class ChromeVisibilityObserver : public chrome::BrowserListObserver {
+ public:
+ ChromeVisibilityObserver();
+ ~ChromeVisibilityObserver() override;
+
+ // Initialize |ChromeVisibilityObserver| instance which observes |BrowserList|
+ // for browser visibility changes.
+ static void Initialize();
+
+ private:
+ // Notifies |DesktopEngagementService| of visibility changes. Overridden by
+ // tests.
+ virtual void SendVisibilityChangeEvent(bool active);
Alexei Svitkine (slow) 2016/07/26 22:00:40 I think having virtual functions that are private
gayane -on leave until 09-2017 2016/07/27 21:10:24 Done.
+ // Cancels visibility change in case when the browser becomes visible after a
+ // short gap.
+ void CancelVisibilityChange();
+
+ // chrome::BrowserListObserver:
+ void OnBrowserSetLastActive(Browser* browser) override;
+ void OnBrowserNoLongerActive(Browser* browser) override;
+ void OnBrowserRemoved(Browser* browser) override;
+
+ // Sets |visibility_gap_timeout_| based on variation params.
+ void InitVisibilityGapTimeout();
+
+ // Timeout interval for waiting after loss of visibility. This allows merging
+ // two visibility session if they happened very shortly after each other, for
+ // example, when user switching between two browser windows.
+ base::TimeDelta visibility_gap_timeout_;
+
+ base::WeakPtrFactory<ChromeVisibilityObserver> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ChromeVisibilityObserver);
+};
+
+} // namespace metrics
+
+#endif // CHROME_BROWSER_METRICS_DESKTOP_ENGAGEMENT_CHROME_VISIBILITY_OBSERVER_H_

Powered by Google App Engine
This is Rietveld 408576698