diff options
author | Sergey Magidovich <mgsergio@mapswithme.com> | 2016-05-30 19:03:40 +0300 |
---|---|---|
committer | Sergey Magidovich <mgsergio@mapswithme.com> | 2016-05-30 19:03:40 +0300 |
commit | e0b17934baa7c0d18e404eec2ca18a967eca7e81 (patch) | |
tree | e974d523033372fc9fd6ffab5a5f168dbe84ab2b /map/framework.hpp | |
parent | 82821e1ed30d9e923a08ea5a1fecaeabaac382ce (diff) |
Change interface for gui. Haven't been tested yet.
Diffstat (limited to 'map/framework.hpp')
-rw-r--r-- | map/framework.hpp | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/map/framework.hpp b/map/framework.hpp index b804ac06d8..418115350b 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -43,6 +43,7 @@ #include "base/thread_checker.hpp" #include "std/list.hpp" +#include "std/mutex.hpp" // TODO(mgsergio): remove when m_UserStatsMutex is gone. #include "std/shared_ptr.hpp" #include "std/target_os.hpp" #include "std/unique_ptr.hpp" @@ -675,15 +676,30 @@ private: public: //@{ - //User statistics. - editor::UserStats const * GetUserStats() const { return m_userStats.get(); } + // TODO(mgsergio): move mutexed logic out from framework. + // User statistics. + + // A callback type to be passed in UpdateUserStats. + using TOnStatsUpdated = function<void()>; + + // TODO(mgsergio): Comment to this function. + shared_ptr<editor::UserStats const> GetUserStats(string const & userName) const; + + // Reads user stats from server or gets it from cache calls reader on success. + void UpdateUserStats(string const & userName, TOnStatsUpdated const & fn); + +private: /// Sends a synchronous request to the server and updates user's stats. - /// @returns true on success. bool UpdateUserStats(string const & userName); - void DropUserStats() { m_userStats = nullptr; } -private: - unique_ptr<editor::UserStats> m_userStats; + bool LoadUserStatsFromSettings(); + /// Not thread-safe, use synchonization. + void SaveUserStatsToSettings(); + + shared_ptr<editor::UserStats> m_userStats; + string m_userName; + time_t m_latsUpdate{}; + mutable mutex m_userStatsMutex; //@} DECLARE_THREAD_CHECKER(m_threadChecker); |