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

Side by Side Diff: chrome/browser/metrics/desktop_session_duration/chrome_visibility_observer.h

Issue 2939943004: Fix duplicate logging of ActiveBrowserChanged action on views. (Closed)
Patch Set: Fix ChromeVisibilityObserverBrowserTest on windows. Created 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/metrics/desktop_session_duration/chrome_visibility_observer_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_METRICS_DESKTOP_SESSION_DURATION_CHROME_VISIBILITY_OBSERV ER_H_ 5 #ifndef CHROME_BROWSER_METRICS_DESKTOP_SESSION_DURATION_CHROME_VISIBILITY_OBSERV ER_H_
6 #define CHROME_BROWSER_METRICS_DESKTOP_SESSION_DURATION_CHROME_VISIBILITY_OBSERV ER_H_ 6 #define CHROME_BROWSER_METRICS_DESKTOP_SESSION_DURATION_CHROME_VISIBILITY_OBSERV ER_H_
7 7
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "chrome/browser/ui/browser_list_observer.h" 10 #include "chrome/browser/ui/browser_list_observer.h"
11 11
12 namespace metrics { 12 namespace metrics {
13 // Observer for tracking browser visibility events. 13 // Observer for tracking browser visibility events.
14 class ChromeVisibilityObserver : public chrome::BrowserListObserver { 14 class ChromeVisibilityObserver : public chrome::BrowserListObserver {
15 public: 15 public:
16 ChromeVisibilityObserver(); 16 ChromeVisibilityObserver();
17 ~ChromeVisibilityObserver() override; 17 ~ChromeVisibilityObserver() override;
18 18
19 protected: 19 protected:
20 // Notifies |DesktopSessionDurationTracker| of visibility changes. Overridden 20 // Notifies |DesktopSessionDurationTracker| of visibility changes. Overridden
21 // by tests. 21 // by tests.
22 virtual void SendVisibilityChangeEvent(bool active, base::TimeDelta time_ago); 22 virtual void SendVisibilityChangeEvent(bool active, base::TimeDelta time_ago);
23 23
24 // chrome::BrowserListObserver:
25 // In protected section for test.
26 void OnBrowserRemoved(Browser* browser) override;
27
28 private: 24 private:
29 // Cancels visibility change in case when the browser becomes visible after a 25 // Cancels visibility change in case when the browser becomes visible after a
30 // short gap. 26 // short gap.
31 void CancelVisibilityChange(); 27 void CancelVisibilityChange();
32 28
33 // chrome::BrowserListObserver: 29 // chrome::BrowserListObserver:
34 void OnBrowserSetLastActive(Browser* browser) override; 30 void OnBrowserSetLastActive(Browser* browser) override;
35 void OnBrowserNoLongerActive(Browser* browser) override; 31 void OnBrowserNoLongerActive(Browser* browser) override;
32 void OnBrowserRemoved(Browser* browser) override;
36 33
37 // Sets |visibility_gap_timeout_| based on variation params. 34 // Sets |visibility_gap_timeout_| based on variation params.
38 void InitVisibilityGapTimeout(); 35 void InitVisibilityGapTimeout();
39 36
40 // Timeout interval for waiting after loss of visibility. This allows merging 37 // Timeout interval for waiting after loss of visibility. This allows merging
41 // two visibility session if they happened very shortly after each other, for 38 // two visibility session if they happened very shortly after each other, for
42 // example, when user switching between two browser windows. 39 // example, when user switching between two browser windows.
43 base::TimeDelta visibility_gap_timeout_; 40 base::TimeDelta visibility_gap_timeout_;
44 41
45 base::WeakPtrFactory<ChromeVisibilityObserver> weak_factory_; 42 base::WeakPtrFactory<ChromeVisibilityObserver> weak_factory_;
46 43
47 DISALLOW_COPY_AND_ASSIGN(ChromeVisibilityObserver); 44 DISALLOW_COPY_AND_ASSIGN(ChromeVisibilityObserver);
48 }; 45 };
49 46
50 } // namespace metrics 47 } // namespace metrics
51 48
52 #endif // CHROME_BROWSER_METRICS_DESKTOP_SESSION_DURATION_CHROME_VISIBILITY_OBS ERVER_H_ 49 #endif // CHROME_BROWSER_METRICS_DESKTOP_SESSION_DURATION_CHROME_VISIBILITY_OBS ERVER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/metrics/desktop_session_duration/chrome_visibility_observer_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698