Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Unified Diff: components/update_client/persisted_data.cc

Issue 1899043002: Implement ping_freshness for update_client. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/update_client/persisted_data.h ('k') | components/update_client/persisted_data_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..673ba1e6b16254a8bb9005a2141390bd5c4f637a 100644
--- a/components/update_client/persisted_data.cc
+++ b/components/update_client/persisted_data.cc
@@ -7,7 +7,9 @@
#include <string>
#include <vector>
+#include "base/guid.h"
#include "base/macros.h"
+#include "base/strings/stringprintf.h"
#include "base/threading/thread_checker.h"
#include "base/values.h"
#include "components/prefs/pref_registry_simple.h"
@@ -35,13 +37,28 @@ int PersistedData::GetDateLastRollCall(const std::string& id) const {
pref_service_->GetDictionary(kPersistedDataPreference);
// We assume ids do not contain '.' characters.
DCHECK_EQ(std::string::npos, id.find('.'));
- if (!dict->GetInteger("apps." + id + ".dlrc", &dlrc))
+ if (!dict->GetInteger(base::StringPrintf("apps.%s.dlrc", id.c_str()), &dlrc))
return kDateLastRollCallUnknown;
return dlrc;
}
+std::string PersistedData::GetPingFreshness(const std::string& id) const {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ if (!pref_service_)
+ return std::string();
+ std::string freshness;
+ 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(base::StringPrintf("apps.%s.pf", id.c_str()),
+ &freshness))
+ return std::string();
+ return base::StringPrintf("{%s}", freshness.c_str());
+}
+
void PersistedData::SetDateLastRollCall(const std::vector<std::string>& ids,
- int datenum) const {
+ int datenum) {
DCHECK(thread_checker_.CalledOnValidThread());
if (!pref_service_ || datenum < 0)
return;
@@ -49,7 +66,9 @@ void PersistedData::SetDateLastRollCall(const std::vector<std::string>& ids,
for (auto id : ids) {
// We assume ids do not contain '.' characters.
DCHECK_EQ(std::string::npos, id.find('.'));
- update->SetInteger("apps." + id + ".dlrc", datenum);
+ update->SetInteger(base::StringPrintf("apps.%s.dlrc", id.c_str()), datenum);
+ update->SetString(base::StringPrintf("apps.%s.pf", id.c_str()),
+ base::GenerateGUID());
}
}
« no previous file with comments | « components/update_client/persisted_data.h ('k') | components/update_client/persisted_data_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698