Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_DESKTOP_ENGAGEMENT_SERVICE_H_ | |
| 6 #define CHROME_BROWSER_METRICS_DESKTOP_ENGAGEMENT_DESKTOP_ENGAGEMENT_SERVICE_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/macros.h" | |
| 12 #include "base/memory/weak_ptr.h" | |
| 13 #include "base/time/time.h" | |
| 14 #include "base/timer/timer.h" | |
| 15 | |
| 16 // Class for tracking and recording user engagement based on browser visibility, | |
| 17 // audio and user interaction. | |
| 18 class DesktopEngagementService { | |
| 19 public: | |
| 20 static void Initialize(); | |
|
Alexei Svitkine (slow)
2016/07/26 19:20:37
Comment on all the functions please and the member
gayane -on leave until 09-2017
2016/07/26 21:41:19
Done.
| |
| 21 static bool IsInitialized(); | |
| 22 static DesktopEngagementService* Get(); | |
| 23 | |
| 24 void OnUserEvent(); | |
| 25 | |
| 26 void OnVisibilityChanged(bool visible); | |
| 27 | |
| 28 void OnAudioStart(); | |
| 29 void OnAudioEnd(); | |
| 30 | |
| 31 private: | |
| 32 friend class MockDesktopEngagementService; | |
| 33 | |
| 34 DesktopEngagementService(); | |
| 35 ~DesktopEngagementService(); | |
| 36 | |
| 37 virtual void OnTimerFired(); | |
| 38 void StartTimer(base::TimeDelta duration); | |
| 39 | |
| 40 void StartSession(); | |
| 41 void EndSession(); | |
| 42 | |
| 43 void InitInactivityTimeout(); | |
| 44 | |
| 45 base::TimeTicks session_start_; | |
| 46 base::TimeTicks last_user_event_; | |
| 47 | |
| 48 bool is_visible_ = false; | |
| 49 bool in_session_ = false; | |
| 50 bool is_audio_playing_ = false; | |
| 51 bool is_first_session_ = true; | |
| 52 base::TimeDelta inactivity_timeout_; | |
| 53 | |
| 54 base::OneShotTimer timer_; | |
| 55 | |
| 56 base::WeakPtrFactory<DesktopEngagementService> weak_factory_; | |
| 57 | |
| 58 DISALLOW_COPY_AND_ASSIGN(DesktopEngagementService); | |
| 59 }; | |
| 60 | |
| 61 #endif // CHROME_BROWSER_METRICS_DESKTOP_ENGAGEMENT_DESKTOP_ENGAGEMENT_SERVICE_ H_ | |
| OLD | NEW |