OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_UPDATE_CLIENT_PERSISTED_DATA_H_ |
| 6 #define COMPONENTS_UPDATE_CLIENT_PERSISTED_DATA_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/threading/thread_checker.h" |
| 14 #include "base/values.h" |
| 15 |
| 16 class PrefRegistrySimple; |
| 17 class PrefService; |
| 18 |
| 19 namespace update_client { |
| 20 |
| 21 // A PersistedData is a wrapper layer around a PrefService, designed to maintain |
| 22 // update data that outlives the browser process and isn't exposed outside of |
| 23 // update_client. |
| 24 // |
| 25 // The public methods of this class should be called only on the thread that |
| 26 // initializes it - which also has to match the thread the PrefService has been |
| 27 // initialized on. |
| 28 class PersistedData : public base::RefCountedThreadSafe<PersistedData> { |
| 29 public: |
| 30 // Constructs a provider that uses the specified |prefService|. |
| 31 // The associated preferences are assumed to already be registered. |
| 32 // The prefService must outlive the entire update_client. |
| 33 PersistedData(PrefService* prefService); |
| 34 |
| 35 // Returns the DateLastRollCall of the specified |id|. -2 indicates that there |
| 36 // is no record of the app. |
| 37 int DateLastRollCall(const std::string& id) const; |
| 38 |
| 39 // Records the DateLastRollCall for the specified |ids|. |datenum| must be a |
| 40 // non-negative integer: calls with a negative |datenum| are simply ignored. |
| 41 // Calls to SetDateLastRollCall that occur prior to the persisted data store |
| 42 // has been fully initialized are ignored. |
| 43 void SetDateLastRollCall(const std::vector<std::string>& ids, int datenum); |
| 44 |
| 45 private: |
| 46 friend class base::RefCountedThreadSafe<PersistedData>; |
| 47 |
| 48 ~PersistedData(); |
| 49 |
| 50 base::ThreadChecker thread_checker_; |
| 51 PrefService* pref_service_; |
| 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(PersistedData); |
| 54 }; |
| 55 |
| 56 // This is called only via update_client's RegisterUpdateClientPreferences. |
| 57 void RegisterPersistedDataPreferences(PrefRegistrySimple* registry); |
| 58 |
| 59 } // namespace update_client |
| 60 |
| 61 #endif // COMPONENTS_UPDATE_CLIENT_PERSISTED_DATA_H_ |
OLD | NEW |