| 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_SERVICE_H_ |
| 6 #define CHROME_BROWSER_METRICS_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 DesktopEngagementService { |
| 17 public: |
| 18 static void Initialize(); |
| 19 static bool IsInitialized(); |
| 20 static DesktopEngagementService* Get(); |
| 21 |
| 22 void OnUserEvent(); |
| 23 |
| 24 void OnVisibilityChanged(bool visible); |
| 25 |
| 26 void OnAudioStart(); |
| 27 void OnAudioEnd(); |
| 28 |
| 29 private: |
| 30 friend class MockDesktopEngagementService; |
| 31 |
| 32 DesktopEngagementService(); |
| 33 ~DesktopEngagementService(); |
| 34 |
| 35 virtual void OnTimerFired(); |
| 36 void StartTimer(base::TimeDelta duration); |
| 37 |
| 38 void StartSession(); |
| 39 void EndSession(); |
| 40 |
| 41 base::TimeDelta GetActivityInterval(); |
| 42 |
| 43 base::TimeTicks session_start_; |
| 44 base::TimeTicks last_user_event_; |
| 45 |
| 46 bool is_visible_ = false; |
| 47 bool in_session_ = false; |
| 48 bool is_audio_playing_ = false; |
| 49 bool is_first_session_ = true; |
| 50 bool activity_interval_seconds_testing_ = 0; |
| 51 |
| 52 base::OneShotTimer timer_; |
| 53 |
| 54 base::WeakPtrFactory<DesktopEngagementService> weak_factory_; |
| 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(DesktopEngagementService); |
| 57 }; |
| 58 |
| 59 #endif // CHROME_BROWSER_METRICS_DESKTOP_ENGAGEMENT_SERVICE_H_ |
| OLD | NEW |