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

Side by Side Diff: chrome/browser/metrics/desktop_session/desktop_session_service.h

Issue 2333113002: Rename DesktopEngagement* to DesktopSessionDuration*. (Closed)
Patch Set: Created 4 years, 3 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
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_ENGAGEMENT_DESKTOP_ENGAGEMENT_SERVICE_H_ 5 #ifndef CHROME_BROWSER_METRICS_DESKTOP_SESSION_DESKTOP_SESSION_SERVICE_H_
6 #define CHROME_BROWSER_METRICS_DESKTOP_ENGAGEMENT_DESKTOP_ENGAGEMENT_SERVICE_H_ 6 #define CHROME_BROWSER_METRICS_DESKTOP_SESSION_DESKTOP_SESSION_SERVICE_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "base/timer/timer.h" 11 #include "base/timer/timer.h"
12 #include "chrome/browser/metrics/desktop_engagement/audible_contents_tracker.h" 12 #include "chrome/browser/metrics/desktop_session/audible_contents_tracker.h"
13 #include "chrome/browser/metrics/desktop_engagement/chrome_visibility_observer.h " 13 #include "chrome/browser/metrics/desktop_session/chrome_visibility_observer.h"
14 14
15 namespace metrics { 15 namespace metrics {
16 16
17 // Class for tracking and recording user engagement based on browser visibility, 17 // Class for tracking and recording session length on desktop based on browser
18 // audio and user interaction. 18 // visibility, audio and user interaction.
19 class DesktopEngagementService : public AudibleContentsTracker::Observer { 19 class DesktopSessionService : public AudibleContentsTracker::Observer {
sky 2016/09/14 00:00:12 This name is easily confused with session restore.
20 public: 20 public:
21 // Creates the |DesktopEngagementService| instance and initializes the 21 // Creates the |DesktopSessionService| instance and initializes the
22 // observes that notify to it. 22 // observers that notify to it.
23 static void Initialize(); 23 static void Initialize();
24 24
25 // Returns true if the |DesktopEngagementService| instance has been created. 25 // Returns true if the |DesktopSessionService| instance has been created.
26 static bool IsInitialized(); 26 static bool IsInitialized();
27 27
28 // Returns the |DesktopEngagementService| instance. 28 // Returns the |DesktopSessionService| instance.
29 static DesktopEngagementService* Get(); 29 static DesktopSessionService* Get();
30 30
31 // Called when user interaction with the browser is caught. 31 // Called when user interaction with the browser is caught.
32 void OnUserEvent(); 32 void OnUserEvent();
33 33
34 // Called when visibility of the browser changes. 34 // Called when visibility of the browser changes.
35 void OnVisibilityChanged(bool visible); 35 void OnVisibilityChanged(bool visible);
36 36
37 bool is_visible() const { return is_visible_; } 37 bool is_visible() const { return is_visible_; }
38 bool in_session() const { return in_session_; } 38 bool in_session() const { return in_session_; }
39 bool is_audio_playing() const { return is_audio_playing_; } 39 bool is_audio_playing() const { return is_audio_playing_; }
40 40
41 void SetInactivityTimeoutForTesting(int seconds) { 41 void SetInactivityTimeoutForTesting(int seconds) {
42 inactivity_timeout_ = base::TimeDelta::FromSeconds(seconds); 42 inactivity_timeout_ = base::TimeDelta::FromSeconds(seconds);
43 } 43 }
44 44
45 protected: 45 protected:
46 DesktopEngagementService(); 46 DesktopSessionService();
47 ~DesktopEngagementService() override; 47 ~DesktopSessionService() override;
48 48
49 // AudibleContentsTracker::Observer 49 // AudibleContentsTracker::Observer
50 void OnAudioStart() override; 50 void OnAudioStart() override;
51 void OnAudioEnd() override; 51 void OnAudioEnd() override;
52 52
53 // Decides whether session should be ended. Called when timer for inactivity 53 // Decides whether session should be ended. Called when timer for inactivity
54 // timeout was fired. Overridden by tests. 54 // timeout was fired. Overridden by tests.
55 virtual void OnTimerFired(); 55 virtual void OnTimerFired();
56 56
57 private: 57 private:
(...skipping 22 matching lines...) Expand all
80 bool is_first_session_ = true; 80 bool is_first_session_ = true;
81 81
82 // Timeout for waiting for user interaction. 82 // Timeout for waiting for user interaction.
83 base::TimeDelta inactivity_timeout_; 83 base::TimeDelta inactivity_timeout_;
84 84
85 base::OneShotTimer timer_; 85 base::OneShotTimer timer_;
86 86
87 ChromeVisibilityObserver visibility_observer_; 87 ChromeVisibilityObserver visibility_observer_;
88 AudibleContentsTracker audio_tracker_; 88 AudibleContentsTracker audio_tracker_;
89 89
90 base::WeakPtrFactory<DesktopEngagementService> weak_factory_; 90 base::WeakPtrFactory<DesktopSessionService> weak_factory_;
91 91
92 DISALLOW_COPY_AND_ASSIGN(DesktopEngagementService); 92 DISALLOW_COPY_AND_ASSIGN(DesktopSessionService);
93 }; 93 };
94 94
95 } // namespace metrics 95 } // namespace metrics
96 96
97 #endif // CHROME_BROWSER_METRICS_DESKTOP_ENGAGEMENT_DESKTOP_ENGAGEMENT_SERVICE_ H_ 97 #endif // CHROME_BROWSER_METRICS_DESKTOP_SESSION_DESKTOP_SESSION_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698