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

Unified Diff: components/update_client/persisted_data.h

Issue 1861383004: Add module for counting date-last-roll-call and persisting those counts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another test fix. 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/configurator.h ('k') | components/update_client/persisted_data.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/update_client/persisted_data.h
diff --git a/components/update_client/persisted_data.h b/components/update_client/persisted_data.h
new file mode 100644
index 0000000000000000000000000000000000000000..d4673b4f373a339cac41ae8c63d3440e20b5af0d
--- /dev/null
+++ b/components/update_client/persisted_data.h
@@ -0,0 +1,60 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_UPDATE_CLIENT_PERSISTED_DATA_H_
+#define COMPONENTS_UPDATE_CLIENT_PERSISTED_DATA_H_
+
+#include <string>
+#include <vector>
+
+#include "base/macros.h"
+#include "base/threading/thread_checker.h"
+#include "base/values.h"
+
+class PrefRegistrySimple;
+class PrefService;
+
+namespace update_client {
+
+// A PersistedData is a wrapper layer around a PrefService, designed to maintain
+// update data that outlives the browser process and isn't exposed outside of
+// update_client.
+//
+// The public methods of this class should be called only on the thread that
+// initializes it - which also has to match the thread the PrefService has been
+// initialized on.
+class PersistedData {
+ public:
+ // Constructs a provider that uses the specified |pref_service|.
+ // The associated preferences are assumed to already be registered.
+ // The |pref_service| must outlive the entire update_client.
+ explicit PersistedData(PrefService* pref_service);
+
+ ~PersistedData();
+
+ // Returns the DateLastRollCall (the server-localized calendar date number the
+ // |id| was last checked by this client on) for the specified |id|.
+ // -2 indicates that there is no recorded date number for the |id|.
+ int GetDateLastRollCall(const std::string& id) const;
+
+ // Records the DateLastRollCall for the specified |ids|. |datenum| must be a
+ // non-negative integer: calls with a negative |datenum| are simply ignored.
+ // Calls to SetDateLastRollCall that occur prior to the persisted data store
+ // has been fully initialized are ignored.
+ void SetDateLastRollCall(const std::vector<std::string>& ids,
+ int datenum) const;
+
+ // This is called only via update_client's RegisterUpdateClientPreferences.
+ static void RegisterPrefs(PrefRegistrySimple* registry);
+
+ private:
+ base::ThreadChecker thread_checker_;
+ PrefService* pref_service_;
+
+ DISALLOW_COPY_AND_ASSIGN(PersistedData);
+};
+
+} // namespace update_client
+
+#endif // COMPONENTS_UPDATE_CLIENT_PERSISTED_DATA_H_
« no previous file with comments | « components/update_client/configurator.h ('k') | components/update_client/persisted_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698