Let PrefRegistry::OnPrefRegistered take a std::string_view.
This CL is part of transitioning PrefRegistry to use std::string_view. The CL contains no functional changes and incurs no extra (string) copies in production code. Bug: 348307659 Change-Id: I03e2546cce47f8b286efa708b4555830cabe93ee Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5643972 Reviewed-by: Dominic Battré <battre@chromium.org> Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com> Commit-Queue: Jan Keitel <jkeitel@google.com> Cr-Commit-Position: refs/heads/main@{#1317289}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
cf4f59176d
commit
eea1209516
components
pref_registry
prefs
sync_preferences
@ -4,6 +4,8 @@
|
||||
|
||||
#include "components/pref_registry/pref_registry_syncable.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/values.h"
|
||||
@ -32,7 +34,7 @@ void PrefRegistrySyncable::SetSyncableRegistrationCallback(
|
||||
callback_ = std::move(cb);
|
||||
}
|
||||
|
||||
void PrefRegistrySyncable::OnPrefRegistered(const std::string& path,
|
||||
void PrefRegistrySyncable::OnPrefRegistered(std::string_view path,
|
||||
uint32_t flags) {
|
||||
// Tests that |flags| does not contain both SYNCABLE_PREF and
|
||||
// SYNCABLE_PRIORITY_PREF flags at the same time.
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/functional/callback.h"
|
||||
#include "build/chromeos_buildflags.h"
|
||||
@ -64,7 +64,7 @@ class PrefRegistrySyncable : public PrefRegistrySimple {
|
||||
};
|
||||
|
||||
using SyncableRegistrationCallback =
|
||||
base::RepeatingCallback<void(const std::string& path, uint32_t flags)>;
|
||||
base::RepeatingCallback<void(std::string_view path, uint32_t flags)>;
|
||||
|
||||
PrefRegistrySyncable();
|
||||
|
||||
@ -88,8 +88,7 @@ class PrefRegistrySyncable : public PrefRegistrySimple {
|
||||
~PrefRegistrySyncable() override;
|
||||
|
||||
// PrefRegistrySimple overrides.
|
||||
void OnPrefRegistered(const std::string& path,
|
||||
uint32_t flags) override;
|
||||
void OnPrefRegistered(std::string_view path, uint32_t flags) override;
|
||||
|
||||
SyncableRegistrationCallback callback_;
|
||||
};
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include "components/prefs/pref_registry.h"
|
||||
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "base/check_op.h"
|
||||
@ -80,5 +82,4 @@ void PrefRegistry::RegisterForeignPref(const std::string& path) {
|
||||
DCHECK(inserted);
|
||||
}
|
||||
|
||||
void PrefRegistry::OnPrefRegistered(const std::string& path,
|
||||
uint32_t flags) {}
|
||||
void PrefRegistry::OnPrefRegistered(std::string_view path, uint32_t flags) {}
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "base/memory/ref_counted.h"
|
||||
@ -100,8 +102,7 @@ class COMPONENTS_PREFS_EXPORT PrefRegistry
|
||||
uint32_t flags);
|
||||
|
||||
// Allows subclasses to hook into pref registration.
|
||||
virtual void OnPrefRegistered(const std::string& path,
|
||||
uint32_t flags);
|
||||
virtual void OnPrefRegistered(std::string_view path, uint32_t flags);
|
||||
|
||||
scoped_refptr<DefaultPrefStore> defaults_;
|
||||
|
||||
|
@ -280,10 +280,9 @@ void PrefServiceSyncable::RemoveSyncedPrefObserver(
|
||||
#endif
|
||||
}
|
||||
|
||||
void PrefServiceSyncable::AddRegisteredSyncablePreference(
|
||||
const std::string& path,
|
||||
uint32_t flags) {
|
||||
DCHECK(FindPreference(path));
|
||||
void PrefServiceSyncable::AddRegisteredSyncablePreference(std::string_view path,
|
||||
uint32_t flags) {
|
||||
DCHECK(FindPreference(std::string(path)));
|
||||
if (flags & user_prefs::PrefRegistrySyncable::SYNCABLE_PREF) {
|
||||
pref_sync_associator_.RegisterPref(path);
|
||||
return;
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "base/functional/callback_forward.h"
|
||||
@ -122,7 +123,7 @@ class PrefServiceSyncable : public PrefService,
|
||||
|
||||
void ConnectAssociatorsAndRegisterPreferences();
|
||||
|
||||
void AddRegisteredSyncablePreference(const std::string& path, uint32_t flags);
|
||||
void AddRegisteredSyncablePreference(std::string_view path, uint32_t flags);
|
||||
|
||||
// PrefServiceForAssociator:
|
||||
base::Value::Type GetRegisteredPrefType(
|
||||
|
Reference in New Issue
Block a user