Chromium Code Reviews| Index: components/update_client/persisted_data.cc |
| diff --git a/components/update_client/persisted_data.cc b/components/update_client/persisted_data.cc |
| index 0894dba0d0d333108d2ebcd4ef9ceb9b44ed910b..ad3744f5de5f51310c519f9386f06f2ff3db6b01 100644 |
| --- a/components/update_client/persisted_data.cc |
| +++ b/components/update_client/persisted_data.cc |
| @@ -7,6 +7,7 @@ |
| #include <string> |
| #include <vector> |
| +#include "base/guid.h" |
| #include "base/macros.h" |
| #include "base/threading/thread_checker.h" |
| #include "base/values.h" |
| @@ -16,6 +17,7 @@ |
| const char kPersistedDataPreference[] = "updateclientdata"; |
| const int kDateLastRollCallUnknown = -2; |
| +const std::string kPingFreshnessUnknown = ""; |
| namespace update_client { |
| @@ -40,6 +42,20 @@ int PersistedData::GetDateLastRollCall(const std::string& id) const { |
| return dlrc; |
| } |
| +std::string PersistedData::GetPingFreshness(const std::string& id) const { |
| + DCHECK(thread_checker_.CalledOnValidThread()); |
| + if (!pref_service_) |
| + return kPingFreshnessUnknown; |
| + std::string freshness = kPingFreshnessUnknown; |
|
Sorin Jianu
2016/04/15 20:26:53
Is there a need to define kPingFreshnessUnknown at
waffles
2016/04/15 21:54:20
Done.
|
| + const base::DictionaryValue* dict = |
| + pref_service_->GetDictionary(kPersistedDataPreference); |
| + // We assume ids do not contain '.' characters. |
| + DCHECK_EQ(std::string::npos, id.find('.')); |
| + if (!dict->GetString("apps." + id + ".pf", &freshness)) |
| + return kPingFreshnessUnknown; |
| + return "{" + freshness + "}"; |
|
Sorin Jianu
2016/04/15 20:26:53
if we need to format I suggest stringprintf, since
waffles
2016/04/15 21:54:20
Done.
|
| +} |
| + |
| void PersistedData::SetDateLastRollCall(const std::vector<std::string>& ids, |
| int datenum) const { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| @@ -50,6 +66,7 @@ void PersistedData::SetDateLastRollCall(const std::vector<std::string>& ids, |
| // We assume ids do not contain '.' characters. |
| DCHECK_EQ(std::string::npos, id.find('.')); |
| update->SetInteger("apps." + id + ".dlrc", datenum); |
| + update->SetString("apps." + id + ".pf", base::GenerateGUID()); |
| } |
| } |