Commit 2640f0a9 authored by Henrique Grandinetti's avatar Henrique Grandinetti Committed by Commit Bot

Implement TimeLimitProcessor.

Bug: 823536
Change-Id: If7441ec8bff5fc95af03eb07955ee94b21f46208
Reviewed-on: https://chromium-review.googlesource.com/1095375
Commit-Queue: Henrique Grandinetti <hgrandinetti@google.com>
Reviewed-by: default avatarAlexander Alekseev <alemate@chromium.org>
Reviewed-by: default avatarJacob Dufault <jdufault@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568246}
parent c9829db7
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "base/values.h" #include "base/values.h"
namespace chromeos { namespace chromeos {
namespace usage_time_limit {
namespace internal { namespace internal {
enum class Weekday { enum class Weekday {
...@@ -27,11 +28,8 @@ enum class Weekday { ...@@ -27,11 +28,8 @@ enum class Weekday {
kCount, kCount,
}; };
class TimeWindowLimitEntry { struct TimeWindowLimitEntry {
public:
TimeWindowLimitEntry(); TimeWindowLimitEntry();
TimeWindowLimitEntry(TimeWindowLimitEntry&&);
TimeWindowLimitEntry& operator=(TimeWindowLimitEntry&&);
bool IsOvernight() const; bool IsOvernight() const;
...@@ -41,9 +39,6 @@ class TimeWindowLimitEntry { ...@@ -41,9 +39,6 @@ class TimeWindowLimitEntry {
base::TimeDelta ends_at; base::TimeDelta ends_at;
// Last time this entry was updated. // Last time this entry was updated.
base::Time last_updated; base::Time last_updated;
private:
DISALLOW_COPY_AND_ASSIGN(TimeWindowLimitEntry);
}; };
class TimeWindowLimit { class TimeWindowLimit {
...@@ -59,17 +54,11 @@ class TimeWindowLimit { ...@@ -59,17 +54,11 @@ class TimeWindowLimit {
DISALLOW_COPY_AND_ASSIGN(TimeWindowLimit); DISALLOW_COPY_AND_ASSIGN(TimeWindowLimit);
}; };
class TimeUsageLimitEntry { struct TimeUsageLimitEntry {
public:
TimeUsageLimitEntry(); TimeUsageLimitEntry();
TimeUsageLimitEntry(TimeUsageLimitEntry&&);
TimeUsageLimitEntry& operator=(TimeUsageLimitEntry&&);
base::TimeDelta usage_quota; base::TimeDelta usage_quota;
base::Time last_updated; base::Time last_updated;
private:
DISALLOW_COPY_AND_ASSIGN(TimeUsageLimitEntry);
}; };
class TimeUsageLimit { class TimeUsageLimit {
...@@ -80,7 +69,7 @@ class TimeUsageLimit { ...@@ -80,7 +69,7 @@ class TimeUsageLimit {
TimeUsageLimit& operator=(TimeUsageLimit&&); TimeUsageLimit& operator=(TimeUsageLimit&&);
std::unordered_map<Weekday, base::Optional<TimeUsageLimitEntry>> entries; std::unordered_map<Weekday, base::Optional<TimeUsageLimitEntry>> entries;
base::TimeDelta reset_at; base::TimeDelta resets_at;
private: private:
DISALLOW_COPY_AND_ASSIGN(TimeUsageLimit); DISALLOW_COPY_AND_ASSIGN(TimeUsageLimit);
...@@ -111,8 +100,6 @@ Weekday WeekdayShift(Weekday current_day, int shift); ...@@ -111,8 +100,6 @@ Weekday WeekdayShift(Weekday current_day, int shift);
} // namespace internal } // namespace internal
namespace usage_time_limit {
enum class ActivePolicies { enum class ActivePolicies {
kNoActivePolicy, kNoActivePolicy,
kOverride, kOverride,
...@@ -122,7 +109,7 @@ enum class ActivePolicies { ...@@ -122,7 +109,7 @@ enum class ActivePolicies {
struct State { struct State {
// Whether the device is currently locked. // Whether the device is currently locked.
bool is_locked; bool is_locked = false;
// Which policy is responsible for the current state. // Which policy is responsible for the current state.
// If it is locked, one of [ override, fixed_limit, usage_limit ] // If it is locked, one of [ override, fixed_limit, usage_limit ]
...@@ -130,12 +117,18 @@ struct State { ...@@ -130,12 +117,18 @@ struct State {
ActivePolicies active_policy; ActivePolicies active_policy;
// Whether time_usage_limit is currently active. // Whether time_usage_limit is currently active.
bool is_time_usage_limit_enabled; bool is_time_usage_limit_enabled = false;
// Remaining screen usage quota. Only available if // Remaining screen usage quota. Only available if
// is_time_limit_enabled = true // is_time_limit_enabled = true
base::TimeDelta remaining_usage; base::TimeDelta remaining_usage;
// When the time usage limit started being enforced. Only available when
// is_time_usage_limit_enabled = true and remaining_usage is 0, which means
// that the time usage limit is enforced, and therefore should have a start
// time.
base::Time time_usage_limit_started;
// Next epoch time that time limit state could change. This could be the // Next epoch time that time limit state could change. This could be the
// start time of the next fixed window limit, the end time of the current // start time of the next fixed window limit, the end time of the current
// fixed limit, the earliest time a usage limit could be reached, or the // fixed limit, the earliest time a usage limit could be reached, or the
...@@ -146,7 +139,7 @@ struct State { ...@@ -146,7 +139,7 @@ struct State {
ActivePolicies next_state_active_policy; ActivePolicies next_state_active_policy;
// Last time the state changed. // Last time the state changed.
base::Time last_state_changed; base::Time last_state_changed = base::Time();
}; };
// Returns the current state of the user session with the given usage time limit // Returns the current state of the user session with the given usage time limit
...@@ -165,4 +158,4 @@ base::Time GetExpectedResetTime( ...@@ -165,4 +158,4 @@ base::Time GetExpectedResetTime(
} // namespace usage_time_limit } // namespace usage_time_limit
} // namespace chromeos } // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_CHILD_ACCOUNTS_USAGE_TIME_LIMIT_PROCESSOR_H_ #endif // CHROME_BROWSER_CHROMEOS_CHILD_ACCOUNTS_USAGE_TIME_LIMIT_PROCESSOR_H_
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment