-// Copyright 2014 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <string>
#include "base/compiler_specific.h"
-#include "base/macros.h"
+#include "base/functional/callback.h"
+#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/observer_list.h"
+#include "base/strings/string_piece.h"
#include "components/prefs/persistent_pref_store.h"
+#include "components/prefs/pref_name_set.h"
#include "components/prefs/prefs_export.h"
// Provides a unified PersistentPrefStore implementation that splits its storage
// method.
SegregatedPrefStore(scoped_refptr<PersistentPrefStore> default_pref_store,
scoped_refptr<PersistentPrefStore> selected_pref_store,
- std::set<std::string> selected_pref_names);
+ PrefNameSet selected_pref_names);
+
+ SegregatedPrefStore(const SegregatedPrefStore&) = delete;
+ SegregatedPrefStore& operator=(const SegregatedPrefStore&) = delete;
// PrefStore implementation
void AddObserver(Observer* observer) override;
void RemoveObserver(Observer* observer) override;
bool HasObservers() const override;
bool IsInitializationComplete() const override;
- bool GetValue(const std::string& key,
+ bool GetValue(base::StringPiece key,
const base::Value** result) const override;
- std::unique_ptr<base::DictionaryValue> GetValues() const override;
+ base::Value::Dict GetValues() const override;
// WriteablePrefStore implementation
void SetValue(const std::string& key,
- std::unique_ptr<base::Value> value,
+ base::Value value,
uint32_t flags) override;
void RemoveValue(const std::string& key, uint32_t flags) override;
void RemoveValuesByPrefixSilently(const std::string& prefix) override;
bool GetMutableValue(const std::string& key, base::Value** result) override;
void ReportValueChanged(const std::string& key, uint32_t flags) override;
void SetValueSilently(const std::string& key,
- std::unique_ptr<base::Value> value,
+ base::Value value,
uint32_t flags) override;
bool ReadOnly() const override;
PrefReadError GetReadError() const override;
base::OnceClosure reply_callback = base::OnceClosure(),
base::OnceClosure synchronous_done_callback =
base::OnceClosure()) override;
- void CommitPendingWriteSynchronously() override;
void SchedulePendingLossyWrites() override;
- void ClearMutableValues() override;
void OnStoreDeletionFromDisk() override;
protected:
public:
explicit UnderlyingPrefStoreObserver(SegregatedPrefStore* outer);
+ UnderlyingPrefStoreObserver(const UnderlyingPrefStoreObserver&) = delete;
+ UnderlyingPrefStoreObserver& operator=(const UnderlyingPrefStoreObserver&) =
+ delete;
+
// PrefStore::Observer implementation
void OnPrefValueChanged(const std::string& key) override;
void OnInitializationCompleted(bool succeeded) override;
bool initialization_succeeded() const { return initialization_succeeded_; }
private:
- SegregatedPrefStore* const outer_;
+ const raw_ptr<SegregatedPrefStore> outer_;
bool initialization_succeeded_ = false;
-
- DISALLOW_COPY_AND_ASSIGN(UnderlyingPrefStoreObserver);
};
// Returns true only if all underlying PrefStores have initialized
// Returns |selected_pref_store| if |key| is selected and
// |default_pref_store| otherwise.
- PersistentPrefStore* StoreForKey(const std::string& key);
- const PersistentPrefStore* StoreForKey(const std::string& key) const;
+ PersistentPrefStore* StoreForKey(base::StringPiece key);
+ const PersistentPrefStore* StoreForKey(base::StringPiece key) const;
const scoped_refptr<PersistentPrefStore> default_pref_store_;
const scoped_refptr<PersistentPrefStore> selected_pref_store_;
- const std::set<std::string> selected_preference_names_;
+ const PrefNameSet selected_preference_names_;
std::unique_ptr<PersistentPrefStore::ReadErrorDelegate> read_error_delegate_;
base::ObserverList<PrefStore::Observer, true>::Unchecked observers_;
UnderlyingPrefStoreObserver default_observer_;
UnderlyingPrefStoreObserver selected_observer_;
-
- DISALLOW_COPY_AND_ASSIGN(SegregatedPrefStore);
};
#endif // COMPONENTS_PREFS_SEGREGATED_PREF_STORE_H_