| 341 | } |
| 342 | |
| 343 | UsageStats::UsageStats() |
| 344 | : m_firstLaunch("US_FirstLaunch") |
| 345 | , m_lastBackground("US_LastBackground") |
| 346 | , m_totalForeground("US_TotalForeground") |
| 347 | , m_sessions("US_SessionsCount") |
| 348 | , m_ss(StringStorage::Instance()) |
| 349 | { |
| 350 | std::string str; |
| 351 | uint64_t val; |
| 352 | if (m_ss.GetValue(m_totalForeground, str) && FromString(str, val)) |
| 353 | m_totalForegroundTime = val; |
| 354 | |
| 355 | if (m_ss.GetValue(m_sessions, str) && FromString(str, val)) |
| 356 | m_sessionsCount = val; |
| 357 | |
| 358 | if (!m_ss.GetValue(m_firstLaunch, str)) |
| 359 | { |
| 360 | auto const fileTime = Platform::GetFileCreationTime(GetPlatform().SettingsPathForFile(SETTINGS_FILE_NAME)); |
| 361 | if (fileTime > 0) |
| 362 | { |
| 363 | // Check that file wasn't created on this first launch (1 hour threshold). |
| 364 | uint64_t const first = base::TimeTToSecondsSinceEpoch(fileTime); |
| 365 | uint64_t const curr = TimeSinceEpoch(); |
| 366 | if (curr >= first + 3600 /* 1 hour */) |
| 367 | m_ss.SetValue(m_firstLaunch, ToString(first)); |
| 368 | } |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | uint64_t UsageStats::TimeSinceEpoch() |
| 373 | { |
nothing calls this directly
no test coverage detected