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

Side by Side 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, 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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.
4
5 #ifndef CHROME_BROWSER_METRICS_DESKTOP_ENGAGEMENT_CHROME_VISIBILITY_OBSERVER_H_
6 #define CHROME_BROWSER_METRICS_DESKTOP_ENGAGEMENT_CHROME_VISIBILITY_OBSERVER_H_
7
8 #include "base/memory/weak_ptr.h"
9 #include "chrome/browser/ui/browser_list_observer.h"
10
11 namespace metrics {
12
13 // Observer for tracking browser visibility events.
14 class ChromeVisibilityObserver : public chrome::BrowserListObserver {
15 public:
16 ChromeVisibilityObserver();
17 ~ChromeVisibilityObserver() override;
18
19 // Initialize |ChromeVisibilityObserver| instance which observes |BrowserList|
20 // for browser visibility changes.
21 static void Initialize();
22
23 private:
24 // Notifies |DesktopEngagementService| of visibility changes. Overridden by
25 // tests.
26 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.
27 // Cancels visibility change in case when the browser becomes visible after a
28 // short gap.
29 void CancelVisibilityChange();
30
31 // chrome::BrowserListObserver:
32 void OnBrowserSetLastActive(Browser* browser) override;
33 void OnBrowserNoLongerActive(Browser* browser) override;
34 void OnBrowserRemoved(Browser* browser) override;
35
36 // Sets |visibility_gap_timeout_| based on variation params.
37 void InitVisibilityGapTimeout();
38
39 // Timeout interval for waiting after loss of visibility. This allows merging
40 // two visibility session if they happened very shortly after each other, for
41 // example, when user switching between two browser windows.
42 base::TimeDelta visibility_gap_timeout_;
43
44 base::WeakPtrFactory<ChromeVisibilityObserver> weak_factory_;
45
46 DISALLOW_COPY_AND_ASSIGN(ChromeVisibilityObserver);
47 };
48
49 } // namespace metrics
50
51 #endif // CHROME_BROWSER_METRICS_DESKTOP_ENGAGEMENT_CHROME_VISIBILITY_OBSERVER_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698