| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_CHROMEOS_SESSION_LENGTH_LIMITER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_SESSION_LENGTH_LIMITER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_SESSION_LENGTH_LIMITER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_SESSION_LENGTH_LIMITER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 virtual const base::TimeTicks GetCurrentTime() const = 0; | 30 virtual const base::TimeTicks GetCurrentTime() const = 0; |
| 31 virtual void StopSession() = 0; | 31 virtual void StopSession() = 0; |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 // Registers preferences. | 34 // Registers preferences. |
| 35 static void RegisterPrefs(PrefRegistrySimple* registry); | 35 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 36 | 36 |
| 37 SessionLengthLimiter(Delegate* delegate, bool browser_restarted); | 37 SessionLengthLimiter(Delegate* delegate, bool browser_restarted); |
| 38 ~SessionLengthLimiter() override; | 38 ~SessionLengthLimiter() override; |
| 39 | 39 |
| 40 // Returns the duration between |session_start_time_| and now if there is a |
| 41 // valid |session_start_time_|. Otherwise, returns 0. |
| 42 base::TimeDelta GetSessionDuration() const; |
| 43 |
| 40 // ui::UserActivityObserver: | 44 // ui::UserActivityObserver: |
| 41 void OnUserActivity(const ui::Event* event) override; | 45 void OnUserActivity(const ui::Event* event) override; |
| 42 | 46 |
| 43 private: | 47 private: |
| 44 // Attempt to restore the session start time and the flag indicating user | 48 // Attempt to restore the session start time and the flag indicating user |
| 45 // activity from local state. Return |true| if the restore is successful. | 49 // activity from local state. Return |true| if the restore is successful. |
| 46 bool RestoreStateAfterCrash(); | 50 bool RestoreStateAfterCrash(); |
| 47 | 51 |
| 48 // Update the session start time if possible: | 52 // Update the session start time if possible: |
| 49 // * If instructed to wait for initial user activity, the session start time | 53 // * If instructed to wait for initial user activity, the session start time |
| (...skipping 16 matching lines...) Expand all Loading... |
| 66 std::unique_ptr<base::OneShotTimer> timer_; | 70 std::unique_ptr<base::OneShotTimer> timer_; |
| 67 base::TimeTicks session_start_time_; | 71 base::TimeTicks session_start_time_; |
| 68 bool user_activity_seen_; | 72 bool user_activity_seen_; |
| 69 | 73 |
| 70 DISALLOW_COPY_AND_ASSIGN(SessionLengthLimiter); | 74 DISALLOW_COPY_AND_ASSIGN(SessionLengthLimiter); |
| 71 }; | 75 }; |
| 72 | 76 |
| 73 } // namespace chromeos | 77 } // namespace chromeos |
| 74 | 78 |
| 75 #endif // CHROME_BROWSER_CHROMEOS_SESSION_LENGTH_LIMITER_H_ | 79 #endif // CHROME_BROWSER_CHROMEOS_SESSION_LENGTH_LIMITER_H_ |
| OLD | NEW |