Convert base::StringPiece to std::string_view in //components 3/5
The changes of this CL are made using the following script. Script: https://issues.chromium.org/issues/40506050#comment343 Bug: 40506050 Change-Id: I7b21541a0723d312206c786d3af570f552ceef4e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5498922 Auto-Submit: Helmut Januschka <helmut@januschka.com> Commit-Queue: Helmut Januschka <helmut@januschka.com> Reviewed-by: Nico Weber <thakis@chromium.org> Cr-Commit-Position: refs/heads/main@{#1295637}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
68ba09c5a4
commit
3ae90009a0
components
prefs
default_pref_store.ccdefault_pref_store.hin_memory_pref_store.ccin_memory_pref_store.hjson_pref_store.ccjson_pref_store.hoverlay_user_pref_store.ccoverlay_user_pref_store.hpref_name_set.hpref_service.ccpref_service.hpref_store.hpref_value_map.ccpref_value_map.hpref_value_store.ccpref_value_store.hsegregated_pref_store.ccsegregated_pref_store.htesting_pref_store.cctesting_pref_store.hvalue_map_pref_store.ccvalue_map_pref_store.h
printing
safe_browsing
content
browser
renderer
core
safe_search_api
search_engines
android
keyword_table.ccsearch_engine_choice
search_host_to_urls_map.ccsearch_host_to_urls_map.htemplate_url.cctemplate_url.htemplate_url_data.cctemplate_url_data.htemplate_url_data_unittest.cctemplate_url_data_util.ccsearch_provider_logos
segmentation_platform
embedder
default_model
internal
data_collection
database
execution
processing
metrics
segmentation_platform_service_test_base.ccsegmentation_ukm_helper_unittest.ccselection
stats.ccpublic
sessions
shared_highlighting
signin
core
browser
internal
identity_manager
public
speech
@ -5,17 +5,17 @@
|
||||
#include "components/prefs/default_pref_store.h"
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "base/check.h"
|
||||
#include "base/observer_list.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
|
||||
using base::Value;
|
||||
|
||||
DefaultPrefStore::DefaultPrefStore() {}
|
||||
|
||||
bool DefaultPrefStore::GetValue(base::StringPiece key,
|
||||
bool DefaultPrefStore::GetValue(std::string_view key,
|
||||
const Value** result) const {
|
||||
return prefs_.GetValue(key, result);
|
||||
}
|
||||
|
@ -7,9 +7,9 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/observer_list.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/values.h"
|
||||
#include "components/prefs/pref_store.h"
|
||||
#include "components/prefs/pref_value_map.h"
|
||||
@ -26,7 +26,7 @@ class COMPONENTS_PREFS_EXPORT DefaultPrefStore : public PrefStore {
|
||||
DefaultPrefStore& operator=(const DefaultPrefStore&) = delete;
|
||||
|
||||
// PrefStore implementation:
|
||||
bool GetValue(base::StringPiece key,
|
||||
bool GetValue(std::string_view key,
|
||||
const base::Value** result) const override;
|
||||
base::Value::Dict GetValues() const override;
|
||||
void AddObserver(PrefStore::Observer* observer) override;
|
||||
|
@ -6,17 +6,17 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "base/observer_list.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/values.h"
|
||||
|
||||
InMemoryPrefStore::InMemoryPrefStore() {}
|
||||
|
||||
InMemoryPrefStore::~InMemoryPrefStore() {}
|
||||
|
||||
bool InMemoryPrefStore::GetValue(base::StringPiece key,
|
||||
bool InMemoryPrefStore::GetValue(std::string_view key,
|
||||
const base::Value** value) const {
|
||||
return prefs_.GetValue(key, value);
|
||||
}
|
||||
|
@ -6,11 +6,12 @@
|
||||
#define COMPONENTS_PREFS_IN_MEMORY_PREF_STORE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/observer_list.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/values.h"
|
||||
#include "components/prefs/persistent_pref_store.h"
|
||||
#include "components/prefs/pref_value_map.h"
|
||||
@ -27,7 +28,7 @@ class COMPONENTS_PREFS_EXPORT InMemoryPrefStore : public PersistentPrefStore {
|
||||
InMemoryPrefStore& operator=(const InMemoryPrefStore&) = delete;
|
||||
|
||||
// PrefStore implementation.
|
||||
bool GetValue(base::StringPiece key,
|
||||
bool GetValue(std::string_view key,
|
||||
const base::Value** result) const override;
|
||||
base::Value::Dict GetValues() const override;
|
||||
void AddObserver(PrefStore::Observer* observer) override;
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "base/feature_list.h"
|
||||
@ -27,7 +28,6 @@
|
||||
#include "base/observer_list.h"
|
||||
#include "base/ranges/algorithm.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/task/sequenced_task_runner.h"
|
||||
#include "base/time/default_clock.h"
|
||||
@ -172,7 +172,7 @@ JsonPrefStore::JsonPrefStore(
|
||||
DCHECK(!path_.empty());
|
||||
}
|
||||
|
||||
bool JsonPrefStore::GetValue(base::StringPiece key,
|
||||
bool JsonPrefStore::GetValue(std::string_view key,
|
||||
const base::Value** result) const {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/files/file_path.h"
|
||||
@ -20,7 +21,6 @@
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/observer_list.h"
|
||||
#include "base/sequence_checker.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/task/thread_pool.h"
|
||||
#include "base/values.h"
|
||||
#include "components/prefs/persistent_pref_store.h"
|
||||
@ -76,7 +76,7 @@ class COMPONENTS_PREFS_EXPORT JsonPrefStore final
|
||||
JsonPrefStore& operator=(const JsonPrefStore&) = delete;
|
||||
|
||||
// PrefStore overrides:
|
||||
bool GetValue(base::StringPiece key,
|
||||
bool GetValue(std::string_view key,
|
||||
const base::Value** result) const override;
|
||||
base::Value::Dict GetValues() const override;
|
||||
void AddObserver(PrefStore::Observer* observer) override;
|
||||
|
@ -7,12 +7,12 @@
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/observer_list.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/values.h"
|
||||
#include "components/prefs/in_memory_pref_store.h"
|
||||
|
||||
@ -76,7 +76,7 @@ bool OverlayUserPrefStore::IsInitializationComplete() const {
|
||||
ephemeral_user_pref_store_->IsInitializationComplete();
|
||||
}
|
||||
|
||||
bool OverlayUserPrefStore::GetValue(base::StringPiece key,
|
||||
bool OverlayUserPrefStore::GetValue(std::string_view key,
|
||||
const base::Value** result) const {
|
||||
// If the |key| shall NOT be stored in the ephemeral store, there must not
|
||||
// be an entry.
|
||||
@ -241,6 +241,6 @@ void OverlayUserPrefStore::OnInitializationCompleted(bool ephemeral,
|
||||
}
|
||||
|
||||
bool OverlayUserPrefStore::ShallBeStoredInPersistent(
|
||||
base::StringPiece key) const {
|
||||
std::string_view key) const {
|
||||
return persistent_names_set_.find(key) != persistent_names_set_.end();
|
||||
}
|
||||
|
@ -9,10 +9,10 @@
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/observer_list.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/values.h"
|
||||
#include "components/prefs/persistent_pref_store.h"
|
||||
#include "components/prefs/pref_name_set.h"
|
||||
@ -45,7 +45,7 @@ class COMPONENTS_PREFS_EXPORT OverlayUserPrefStore
|
||||
void RemoveObserver(PrefStore::Observer* observer) override;
|
||||
bool HasObservers() const override;
|
||||
bool IsInitializationComplete() const override;
|
||||
bool GetValue(base::StringPiece key,
|
||||
bool GetValue(std::string_view key,
|
||||
const base::Value** result) const override;
|
||||
base::Value::Dict GetValues() const override;
|
||||
|
||||
@ -85,7 +85,7 @@ class COMPONENTS_PREFS_EXPORT OverlayUserPrefStore
|
||||
|
||||
// Returns true if |key| corresponds to a preference that shall be stored in
|
||||
// persistent PrefStore.
|
||||
bool ShallBeStoredInPersistent(base::StringPiece key) const;
|
||||
bool ShallBeStoredInPersistent(std::string_view key) const;
|
||||
|
||||
base::ObserverList<PrefStore::Observer, true>::Unchecked observers_;
|
||||
std::unique_ptr<ObserverAdapter> ephemeral_pref_store_observer_;
|
||||
|
@ -8,9 +8,10 @@
|
||||
#include <functional>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
// String set that allows transparent lookup by string-comparable types like
|
||||
// `base::StringPiece` without requiring conversion to `std::string`.
|
||||
// `std::string_view` without requiring conversion to `std::string`.
|
||||
using PrefNameSet = std::set<std::string, std::less<>>;
|
||||
|
||||
#endif // COMPONENTS_PREFS_PREF_NAME_SET_H_
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "base/check_op.h"
|
||||
@ -21,7 +22,6 @@
|
||||
#include "base/metrics/histogram.h"
|
||||
#include "base/notreached.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/task/sequenced_task_runner.h"
|
||||
#include "base/values.h"
|
||||
@ -188,23 +188,23 @@ void PrefService::SchedulePendingLossyWrites() {
|
||||
user_pref_store_->SchedulePendingLossyWrites();
|
||||
}
|
||||
|
||||
bool PrefService::GetBoolean(base::StringPiece path) const {
|
||||
bool PrefService::GetBoolean(std::string_view path) const {
|
||||
return GetValue(path).GetBool();
|
||||
}
|
||||
|
||||
int PrefService::GetInteger(base::StringPiece path) const {
|
||||
int PrefService::GetInteger(std::string_view path) const {
|
||||
return GetValue(path).GetInt();
|
||||
}
|
||||
|
||||
double PrefService::GetDouble(base::StringPiece path) const {
|
||||
double PrefService::GetDouble(std::string_view path) const {
|
||||
return GetValue(path).GetDouble();
|
||||
}
|
||||
|
||||
const std::string& PrefService::GetString(base::StringPiece path) const {
|
||||
const std::string& PrefService::GetString(std::string_view path) const {
|
||||
return GetValue(path).GetString();
|
||||
}
|
||||
|
||||
base::FilePath PrefService::GetFilePath(base::StringPiece path) const {
|
||||
base::FilePath PrefService::GetFilePath(std::string_view path) const {
|
||||
const base::Value& value = GetValue(path);
|
||||
std::optional<base::FilePath> result = base::ValueToFilePath(value);
|
||||
DCHECK(result);
|
||||
@ -319,17 +319,17 @@ bool PrefService::IsUserModifiablePreference(
|
||||
return pref && pref->IsUserModifiable();
|
||||
}
|
||||
|
||||
const base::Value& PrefService::GetValue(base::StringPiece path) const {
|
||||
const base::Value& PrefService::GetValue(std::string_view path) const {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
return *GetPreferenceValue(path);
|
||||
}
|
||||
|
||||
const base::Value::Dict& PrefService::GetDict(base::StringPiece path) const {
|
||||
const base::Value::Dict& PrefService::GetDict(std::string_view path) const {
|
||||
const base::Value& value = GetValue(path);
|
||||
return value.GetDict();
|
||||
}
|
||||
|
||||
const base::Value::List& PrefService::GetList(base::StringPiece path) const {
|
||||
const base::Value::List& PrefService::GetList(std::string_view path) const {
|
||||
const base::Value& value = GetValue(path);
|
||||
return value.GetList();
|
||||
}
|
||||
@ -445,7 +445,7 @@ void PrefService::SetDouble(const std::string& path, double value) {
|
||||
SetUserPrefValue(path, base::Value(value));
|
||||
}
|
||||
|
||||
void PrefService::SetString(const std::string& path, base::StringPiece value) {
|
||||
void PrefService::SetString(const std::string& path, std::string_view value) {
|
||||
SetUserPrefValue(path, base::Value(value));
|
||||
}
|
||||
|
||||
@ -659,7 +659,7 @@ bool PrefService::Preference::IsStandaloneBrowserModifiable() const {
|
||||
#endif
|
||||
|
||||
const base::Value* PrefService::GetPreferenceValue(
|
||||
base::StringPiece path) const {
|
||||
std::string_view path) const {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
|
||||
const base::Value* default_value = nullptr;
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
@ -24,7 +25,6 @@
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/sequence_checker.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/time/time.h"
|
||||
#include "base/values.h"
|
||||
#include "build/build_config.h"
|
||||
@ -243,25 +243,25 @@ class COMPONENTS_PREFS_EXPORT PrefService {
|
||||
// If the path is valid and the value at the end of the path matches the type
|
||||
// specified, it will return the specified value. Otherwise, the default
|
||||
// value (set when the pref was registered) will be returned.
|
||||
bool GetBoolean(base::StringPiece path) const;
|
||||
int GetInteger(base::StringPiece path) const;
|
||||
double GetDouble(base::StringPiece path) const;
|
||||
const std::string& GetString(base::StringPiece path) const;
|
||||
base::FilePath GetFilePath(base::StringPiece path) const;
|
||||
bool GetBoolean(std::string_view path) const;
|
||||
int GetInteger(std::string_view path) const;
|
||||
double GetDouble(std::string_view path) const;
|
||||
const std::string& GetString(std::string_view path) const;
|
||||
base::FilePath GetFilePath(std::string_view path) const;
|
||||
|
||||
// Returns the branch if it exists, or the registered default value otherwise.
|
||||
// `path` must point to a registered preference (DCHECK).
|
||||
const base::Value& GetValue(base::StringPiece path) const;
|
||||
const base::Value& GetValue(std::string_view path) const;
|
||||
|
||||
// Returns the branch if it exists, or the registered default value otherwise.
|
||||
// `path` must point to a registered preference whose value and registered
|
||||
// default are of type `base::Value::Type::DICT (DCHECK).
|
||||
const base::Value::Dict& GetDict(base::StringPiece path) const;
|
||||
const base::Value::Dict& GetDict(std::string_view path) const;
|
||||
|
||||
// Returns the branch if it exists, or the registered default value otherwise.
|
||||
// `path` must point to a registered preference whose value and registered
|
||||
// default are of type `base::Value::Type::LIST (DCHECK).
|
||||
const base::Value::List& GetList(base::StringPiece path) const;
|
||||
const base::Value::List& GetList(std::string_view path) const;
|
||||
|
||||
// Removes a user pref and restores the pref to its default value.
|
||||
void ClearPref(const std::string& path);
|
||||
@ -280,7 +280,7 @@ class COMPONENTS_PREFS_EXPORT PrefService {
|
||||
void SetBoolean(const std::string& path, bool value);
|
||||
void SetInteger(const std::string& path, int value);
|
||||
void SetDouble(const std::string& path, double value);
|
||||
void SetString(const std::string& path, base::StringPiece value);
|
||||
void SetString(const std::string& path, std::string_view value);
|
||||
void SetDict(const std::string& path, base::Value::Dict dict);
|
||||
void SetList(const std::string& path, base::Value::List list);
|
||||
void SetFilePath(const std::string& path, const base::FilePath& value);
|
||||
@ -516,7 +516,7 @@ class COMPONENTS_PREFS_EXPORT PrefService {
|
||||
// not need to find or create a Preference object to get the
|
||||
// value (GetValue() calls back though the preference service to
|
||||
// actually get the value.).
|
||||
const base::Value* GetPreferenceValue(base::StringPiece path) const;
|
||||
const base::Value* GetPreferenceValue(std::string_view path) const;
|
||||
|
||||
const scoped_refptr<PrefRegistry> pref_registry_;
|
||||
|
||||
|
@ -7,9 +7,9 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/values.h"
|
||||
#include "components/prefs/prefs_export.h"
|
||||
|
||||
@ -50,7 +50,7 @@ class COMPONENTS_PREFS_EXPORT PrefStore : public base::RefCounted<PrefStore> {
|
||||
// Get the value for a given preference |key| and stores it in |*result|.
|
||||
// |*result| is only modified if the return value is true and if |result|
|
||||
// is not NULL. Ownership of the |*result| value remains with the PrefStore.
|
||||
virtual bool GetValue(base::StringPiece key,
|
||||
virtual bool GetValue(std::string_view key,
|
||||
const base::Value** result) const = 0;
|
||||
|
||||
// Get all the values.
|
||||
|
@ -5,19 +5,20 @@
|
||||
#include "components/prefs/pref_value_map.h"
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/values.h"
|
||||
|
||||
PrefValueMap::PrefValueMap() {}
|
||||
|
||||
PrefValueMap::~PrefValueMap() {}
|
||||
|
||||
bool PrefValueMap::GetValue(base::StringPiece key,
|
||||
bool PrefValueMap::GetValue(std::string_view key,
|
||||
const base::Value** value) const {
|
||||
auto it = prefs_.find(key);
|
||||
if (it == prefs_.end())
|
||||
@ -29,7 +30,7 @@ bool PrefValueMap::GetValue(base::StringPiece key,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PrefValueMap::GetValue(base::StringPiece key, base::Value** value) {
|
||||
bool PrefValueMap::GetValue(std::string_view key, base::Value** value) {
|
||||
auto it = prefs_.find(key);
|
||||
if (it == prefs_.end())
|
||||
return false;
|
||||
|
@ -7,9 +7,9 @@
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/values.h"
|
||||
#include "components/prefs/prefs_export.h"
|
||||
|
||||
@ -30,8 +30,8 @@ class COMPONENTS_PREFS_EXPORT PrefValueMap {
|
||||
// Gets the value for |key| and stores it in |value|. Ownership remains with
|
||||
// the map. Returns true if a value is present. If not, |value| is not
|
||||
// touched.
|
||||
bool GetValue(base::StringPiece key, const base::Value** value) const;
|
||||
bool GetValue(base::StringPiece key, base::Value** value);
|
||||
bool GetValue(std::string_view key, const base::Value** value) const;
|
||||
bool GetValue(std::string_view key, base::Value** value);
|
||||
|
||||
// Sets a new |value| for |key|. Returns true if the value changed.
|
||||
bool SetValue(const std::string& key, base::Value value);
|
||||
|
@ -5,10 +5,11 @@
|
||||
#include "components/prefs/pref_value_store.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "components/prefs/pref_notifier.h"
|
||||
#include "components/prefs/pref_observer.h"
|
||||
|
||||
@ -116,7 +117,7 @@ PrefValueStore::PrefStoreType PrefValueStore::ControllingPrefStoreForPref(
|
||||
return INVALID_STORE;
|
||||
}
|
||||
|
||||
bool PrefValueStore::GetValue(base::StringPiece name,
|
||||
bool PrefValueStore::GetValue(std::string_view name,
|
||||
base::Value::Type type,
|
||||
const base::Value** out_value) const {
|
||||
// Check the |PrefStore|s in order of their priority from highest to lowest,
|
||||
@ -244,7 +245,7 @@ bool PrefValueStore::PrefValueInStoreRange(
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PrefValueStore::GetValueFromStore(base::StringPiece name,
|
||||
bool PrefValueStore::GetValueFromStore(std::string_view name,
|
||||
PrefValueStore::PrefStoreType store_type,
|
||||
const base::Value** out_value) const {
|
||||
// Only return true if we find a value and it is the correct type, so stale
|
||||
@ -260,7 +261,7 @@ bool PrefValueStore::GetValueFromStore(base::StringPiece name,
|
||||
}
|
||||
|
||||
bool PrefValueStore::GetValueFromStoreWithType(
|
||||
base::StringPiece name,
|
||||
std::string_view name,
|
||||
base::Value::Type type,
|
||||
PrefStoreType store,
|
||||
const base::Value** out_value) const {
|
||||
|
@ -9,13 +9,13 @@
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
#include "base/functional/callback.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/values.h"
|
||||
#include "components/prefs/pref_store.h"
|
||||
#include "components/prefs/prefs_export.h"
|
||||
@ -120,7 +120,7 @@ class COMPONENTS_PREFS_EXPORT PrefValueStore {
|
||||
// a non-matching |type| are silently skipped. Returns true if a valid value
|
||||
// was found in any of the available PrefStores. Most callers should use
|
||||
// Preference::GetValue() instead of calling this method directly.
|
||||
bool GetValue(base::StringPiece name,
|
||||
bool GetValue(std::string_view name,
|
||||
base::Value::Type type,
|
||||
const base::Value** out_value) const;
|
||||
|
||||
@ -221,12 +221,12 @@ class COMPONENTS_PREFS_EXPORT PrefValueStore {
|
||||
PrefStoreType last_checked_store) const;
|
||||
|
||||
// Get a value from the specified |store|.
|
||||
bool GetValueFromStore(base::StringPiece name,
|
||||
bool GetValueFromStore(std::string_view name,
|
||||
PrefStoreType store,
|
||||
const base::Value** out_value) const;
|
||||
|
||||
// Get a value from the specified |store| if its |type| matches.
|
||||
bool GetValueFromStoreWithType(base::StringPiece name,
|
||||
bool GetValueFromStoreWithType(std::string_view name,
|
||||
base::Value::Type type,
|
||||
PrefStoreType store,
|
||||
const base::Value** out_value) const;
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "components/prefs/segregated_pref_store.h"
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "base/barrier_closure.h"
|
||||
@ -12,7 +13,6 @@
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/notreached.h"
|
||||
#include "base/observer_list.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/values.h"
|
||||
#include "components/prefs/pref_name_set.h"
|
||||
|
||||
@ -87,7 +87,7 @@ bool SegregatedPrefStore::IsInitializationSuccessful() const {
|
||||
selected_observer_.initialization_succeeded();
|
||||
}
|
||||
|
||||
bool SegregatedPrefStore::GetValue(base::StringPiece key,
|
||||
bool SegregatedPrefStore::GetValue(std::string_view key,
|
||||
const base::Value** result) const {
|
||||
return StoreForKey(key)->GetValue(key, result);
|
||||
}
|
||||
@ -214,14 +214,14 @@ SegregatedPrefStore::~SegregatedPrefStore() {
|
||||
selected_pref_store_->RemoveObserver(&selected_observer_);
|
||||
}
|
||||
|
||||
PersistentPrefStore* SegregatedPrefStore::StoreForKey(base::StringPiece key) {
|
||||
PersistentPrefStore* SegregatedPrefStore::StoreForKey(std::string_view key) {
|
||||
return (base::Contains(selected_preference_names_, key) ? selected_pref_store_
|
||||
: default_pref_store_)
|
||||
.get();
|
||||
}
|
||||
|
||||
const PersistentPrefStore* SegregatedPrefStore::StoreForKey(
|
||||
base::StringPiece key) const {
|
||||
std::string_view key) const {
|
||||
return (base::Contains(selected_preference_names_, key) ? selected_pref_store_
|
||||
: default_pref_store_)
|
||||
.get();
|
||||
|
@ -10,13 +10,13 @@
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/compiler_specific.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"
|
||||
@ -54,7 +54,7 @@ class COMPONENTS_PREFS_EXPORT SegregatedPrefStore : public PersistentPrefStore {
|
||||
void RemoveObserver(Observer* observer) override;
|
||||
bool HasObservers() const override;
|
||||
bool IsInitializationComplete() const override;
|
||||
bool GetValue(base::StringPiece key,
|
||||
bool GetValue(std::string_view key,
|
||||
const base::Value** result) const override;
|
||||
base::Value::Dict GetValues() const override;
|
||||
|
||||
@ -114,8 +114,8 @@ class COMPONENTS_PREFS_EXPORT SegregatedPrefStore : public PersistentPrefStore {
|
||||
|
||||
// Returns |selected_pref_store| if |key| is selected and
|
||||
// |default_pref_store| otherwise.
|
||||
PersistentPrefStore* StoreForKey(base::StringPiece key);
|
||||
const PersistentPrefStore* StoreForKey(base::StringPiece key) const;
|
||||
PersistentPrefStore* StoreForKey(std::string_view key);
|
||||
const PersistentPrefStore* StoreForKey(std::string_view key) const;
|
||||
|
||||
const scoped_refptr<PersistentPrefStore> default_pref_store_;
|
||||
const scoped_refptr<PersistentPrefStore> selected_pref_store_;
|
||||
|
@ -6,11 +6,11 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "base/json/json_writer.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/values.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
@ -74,7 +74,7 @@ TestingPrefStore::TestingPrefStore()
|
||||
init_complete_(false),
|
||||
committed_(true) {}
|
||||
|
||||
bool TestingPrefStore::GetValue(base::StringPiece key,
|
||||
bool TestingPrefStore::GetValue(std::string_view key,
|
||||
const base::Value** value) const {
|
||||
return prefs_.GetValue(key, value);
|
||||
}
|
||||
|
@ -8,10 +8,10 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/observer_list.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/values.h"
|
||||
#include "components/prefs/persistent_pref_store.h"
|
||||
#include "components/prefs/pref_value_map.h"
|
||||
@ -27,7 +27,7 @@ class TestingPrefStore : public PersistentPrefStore {
|
||||
TestingPrefStore& operator=(const TestingPrefStore&) = delete;
|
||||
|
||||
// Overridden from PrefStore.
|
||||
bool GetValue(base::StringPiece key,
|
||||
bool GetValue(std::string_view key,
|
||||
const base::Value** result) const override;
|
||||
base::Value::Dict GetValues() const override;
|
||||
void AddObserver(PrefStore::Observer* observer) override;
|
||||
|
@ -6,15 +6,15 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "base/observer_list.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/values.h"
|
||||
|
||||
ValueMapPrefStore::ValueMapPrefStore() {}
|
||||
|
||||
bool ValueMapPrefStore::GetValue(base::StringPiece key,
|
||||
bool ValueMapPrefStore::GetValue(std::string_view key,
|
||||
const base::Value** value) const {
|
||||
return prefs_.GetValue(key, value);
|
||||
}
|
||||
|
@ -9,9 +9,9 @@
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/observer_list.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/values.h"
|
||||
#include "components/prefs/pref_value_map.h"
|
||||
#include "components/prefs/prefs_export.h"
|
||||
@ -27,8 +27,7 @@ class COMPONENTS_PREFS_EXPORT ValueMapPrefStore : public WriteablePrefStore {
|
||||
ValueMapPrefStore& operator=(const ValueMapPrefStore&) = delete;
|
||||
|
||||
// PrefStore overrides:
|
||||
bool GetValue(base::StringPiece key,
|
||||
const base::Value** value) const override;
|
||||
bool GetValue(std::string_view key, const base::Value** value) const override;
|
||||
base::Value::Dict GetValues() const override;
|
||||
void AddObserver(PrefStore::Observer* observer) override;
|
||||
void RemoveObserver(PrefStore::Observer* observer) override;
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "components/printing/browser/print_to_pdf/pdf_print_utils.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/numerics/safe_conversions.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_split.h"
|
||||
@ -35,13 +37,13 @@ static constexpr double kDefaultMarginInInches =
|
||||
} // namespace
|
||||
|
||||
absl::variant<printing::PageRanges, PdfPrintResult> TextPageRangesToPageRanges(
|
||||
base::StringPiece page_range_text) {
|
||||
std::string_view page_range_text) {
|
||||
printing::PageRanges page_ranges;
|
||||
for (const auto& range_string :
|
||||
base::SplitStringPiece(page_range_text, ",", base::TRIM_WHITESPACE,
|
||||
base::SPLIT_WANT_NONEMPTY)) {
|
||||
printing::PageRange range;
|
||||
if (range_string.find("-") == base::StringPiece::npos) {
|
||||
if (range_string.find("-") == std::string_view::npos) {
|
||||
if (!base::StringToUint(range_string, &range.from))
|
||||
return PdfPrintResult::kPageRangeSyntaxError;
|
||||
range.to = range.from;
|
||||
|
@ -7,8 +7,8 @@
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "components/printing/browser/print_to_pdf/pdf_print_result.h"
|
||||
#include "components/printing/common/print.mojom.h"
|
||||
#include "printing/page_range.h"
|
||||
@ -20,7 +20,7 @@ namespace print_to_pdf {
|
||||
// Converts textual representation of the page range to printing::PageRanges,
|
||||
// page range error is returned as the PdfPrintResult variant case.
|
||||
absl::variant<printing::PageRanges, PdfPrintResult> TextPageRangesToPageRanges(
|
||||
base::StringPiece page_range_text);
|
||||
std::string_view page_range_text);
|
||||
|
||||
// Converts print settings to printing::mojom::PrintPagesParamsPtr,
|
||||
// document error is returned as the string variant case.
|
||||
|
@ -8,13 +8,13 @@
|
||||
|
||||
#include <cmath>
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "build/build_config.h"
|
||||
#include "build/chromeos_buildflags.h"
|
||||
@ -559,7 +559,7 @@ class PrintRenderFrameHelperTestBase : public content::RenderViewTest {
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
||||
void OnPrintPagesInFrame(base::StringPiece frame_name) {
|
||||
void OnPrintPagesInFrame(std::string_view frame_name) {
|
||||
blink::WebFrame* frame =
|
||||
GetMainFrame()->FindFrameByName(blink::WebString::FromUTF8(frame_name));
|
||||
ASSERT_TRUE(frame);
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "components/safe_browsing/content/browser/browser_url_loader_throttle.h"
|
||||
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "base/functional/callback.h"
|
||||
@ -84,19 +85,19 @@ class MockThrottleDelegate : public blink::URLLoaderThrottle::Delegate {
|
||||
~MockThrottleDelegate() override = default;
|
||||
|
||||
void CancelWithError(int error_code,
|
||||
base::StringPiece custom_reason) override {
|
||||
std::string_view custom_reason) override {
|
||||
error_code_ = error_code;
|
||||
custom_reason_ = custom_reason;
|
||||
}
|
||||
void Resume() override { is_resumed_ = true; }
|
||||
|
||||
int GetErrorCode() { return error_code_; }
|
||||
base::StringPiece GetCustomReason() { return custom_reason_; }
|
||||
std::string_view GetCustomReason() { return custom_reason_; }
|
||||
bool IsResumed() { return is_resumed_; }
|
||||
|
||||
private:
|
||||
int error_code_ = 0;
|
||||
base::StringPiece custom_reason_ = "";
|
||||
std::string_view custom_reason_ = "";
|
||||
bool is_resumed_ = false;
|
||||
};
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
|
||||
@ -147,7 +148,7 @@ void PhishingTermFeatureExtractor::ExtractFeaturesWithTimeout() {
|
||||
if (state_->iterator->IsWord()) {
|
||||
const size_t start = state_->iterator->prev();
|
||||
const size_t length = state_->iterator->pos() - start;
|
||||
HandleWord(base::StringPiece16(page_text_->data() + start, length));
|
||||
HandleWord(std::u16string_view(page_text_->data() + start, length));
|
||||
++num_words;
|
||||
}
|
||||
|
||||
@ -175,7 +176,7 @@ void PhishingTermFeatureExtractor::ExtractFeaturesWithTimeout() {
|
||||
RunCallback(true);
|
||||
}
|
||||
|
||||
void PhishingTermFeatureExtractor::HandleWord(const base::StringPiece16& word) {
|
||||
void PhishingTermFeatureExtractor::HandleWord(std::u16string_view word) {
|
||||
// First, extract shingle hashes.
|
||||
const std::string& word_lower = base::UTF16ToUTF8(base::i18n::ToLower(word));
|
||||
state_->current_shingle.append(word_lower + " ");
|
||||
|
@ -22,12 +22,12 @@
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "base/functional/callback.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/time/tick_clock.h"
|
||||
|
||||
namespace safe_browsing {
|
||||
@ -118,7 +118,7 @@ class PhishingTermFeatureExtractor {
|
||||
void ExtractFeaturesWithTimeout();
|
||||
|
||||
// Handles a single word in the page text.
|
||||
void HandleWord(const base::StringPiece16& word);
|
||||
void HandleWord(std::u16string_view word);
|
||||
|
||||
// Runs |done_callback_| and then clears all internal state.
|
||||
void RunCallback(bool success);
|
||||
|
@ -6,10 +6,10 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "base/metrics/histogram_macros.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/string_split.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/timer/elapsed_timer.h"
|
||||
@ -103,7 +103,7 @@ void PhishingUrlFeatureExtractor::SplitStringIntoLongAlphanumTokens(
|
||||
// Split on common non-alphanumerics.
|
||||
// TODO(bryner): Split on all(?) non-alphanumerics and handle %XX properly.
|
||||
static const char kTokenSeparators[] = ".,\\/_-|=%:!&";
|
||||
for (const base::StringPiece& token :
|
||||
for (std::string_view token :
|
||||
base::SplitStringPiece(full, kTokenSeparators, base::KEEP_WHITESPACE,
|
||||
base::SPLIT_WANT_NONEMPTY)) {
|
||||
// Copy over only the splits that are 3 or more chars long.
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "components/safe_browsing/content/renderer/renderer_url_loader_throttle.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/test/metrics/histogram_tester.h"
|
||||
#include "base/test/scoped_feature_list.h"
|
||||
#include "base/test/task_environment.h"
|
||||
@ -63,7 +65,7 @@ class MockThrottleDelegate : public blink::URLLoaderThrottle::Delegate {
|
||||
~MockThrottleDelegate() override = default;
|
||||
|
||||
void CancelWithError(int error_code,
|
||||
base::StringPiece custom_reason) override {}
|
||||
std::string_view custom_reason) override {}
|
||||
void Resume() override {}
|
||||
};
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "components/safe_browsing/core/browser/db/hash_prefix_map.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/debug/crash_logging.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
@ -31,7 +33,7 @@ std::string GenerateExtension(PrefixSize size) {
|
||||
}
|
||||
|
||||
// Returns true if |hash_prefix| with PrefixSize |size| exists in |prefixes|.
|
||||
bool HashPrefixMatches(base::StringPiece prefix,
|
||||
bool HashPrefixMatches(std::string_view prefix,
|
||||
HashPrefixesView prefixes,
|
||||
PrefixSize size,
|
||||
size_t start,
|
||||
@ -216,9 +218,9 @@ ApplyUpdateResult InMemoryHashPrefixMap::IsValid() const {
|
||||
}
|
||||
|
||||
HashPrefixStr InMemoryHashPrefixMap::GetMatchingHashPrefix(
|
||||
base::StringPiece full_hash) {
|
||||
std::string_view full_hash) {
|
||||
for (const auto& [size, prefixes] : map_) {
|
||||
base::StringPiece hash_prefix = full_hash.substr(0, size);
|
||||
std::string_view hash_prefix = full_hash.substr(0, size);
|
||||
if (HashPrefixMatches(hash_prefix, prefixes, size, 0,
|
||||
prefixes.size() / size)) {
|
||||
return std::string(hash_prefix);
|
||||
@ -467,7 +469,7 @@ ApplyUpdateResult MmapHashPrefixMap::IsValid() const {
|
||||
}
|
||||
|
||||
HashPrefixStr MmapHashPrefixMap::GetMatchingHashPrefix(
|
||||
base::StringPiece full_hash) {
|
||||
std::string_view full_hash) {
|
||||
for (const auto& kv : map_) {
|
||||
HashPrefixStr matching_prefix = kv.second.Matches(full_hash);
|
||||
if (!matching_prefix.empty())
|
||||
@ -605,7 +607,7 @@ bool MmapHashPrefixMap::FileInfo::Finalize(HashFile* hash_file) {
|
||||
}
|
||||
|
||||
HashPrefixStr MmapHashPrefixMap::FileInfo::Matches(
|
||||
base::StringPiece full_hash) const {
|
||||
std::string_view full_hash) const {
|
||||
HashPrefixStr hash_prefix(full_hash.substr(0, prefix_size_));
|
||||
HashPrefixesView prefixes = GetView();
|
||||
|
||||
@ -626,8 +628,8 @@ HashPrefixStr MmapHashPrefixMap::FileInfo::Matches(
|
||||
}
|
||||
|
||||
// TODO(crbug.com/40062772): Remove crash logging.
|
||||
base::StringPiece start_prefix = prefixes.substr(0, prefix_size_);
|
||||
base::StringPiece end_prefix =
|
||||
std::string_view start_prefix = prefixes.substr(0, prefix_size_);
|
||||
std::string_view end_prefix =
|
||||
prefixes.substr(prefix_size_ * (end - 1), prefix_size_);
|
||||
SCOPED_CRASH_KEY_STRING64(
|
||||
"SafeBrowsing", "prefix_match",
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "base/files/memory_mapped_file.h"
|
||||
@ -70,7 +71,7 @@ enum ApplyUpdateResult {
|
||||
// The sorted list of hash prefixes.
|
||||
using HashPrefixes = std::string;
|
||||
|
||||
using HashPrefixesView = base::StringPiece;
|
||||
using HashPrefixesView = std::string_view;
|
||||
using HashPrefixMapView = std::unordered_map<PrefixSize, HashPrefixesView>;
|
||||
|
||||
// Set a common sense limit on the store file size we try to read.
|
||||
@ -123,7 +124,7 @@ class HashPrefixMap {
|
||||
virtual ApplyUpdateResult IsValid() const = 0;
|
||||
|
||||
// Returns a hash prefix if it matches the prefixes stored in this map.
|
||||
virtual HashPrefixStr GetMatchingHashPrefix(base::StringPiece full_hash) = 0;
|
||||
virtual HashPrefixStr GetMatchingHashPrefix(std::string_view full_hash) = 0;
|
||||
|
||||
// Migrates the file format between the different types of HashPrefixMap.
|
||||
enum class MigrateResult { kUnknown, kSuccess, kFailure, kNotNeeded };
|
||||
@ -153,7 +154,7 @@ class InMemoryHashPrefixMap : public HashPrefixMap {
|
||||
std::unique_ptr<WriteSession> WriteToDisk(
|
||||
V4StoreFileFormat* file_format) override;
|
||||
ApplyUpdateResult IsValid() const override;
|
||||
HashPrefixStr GetMatchingHashPrefix(base::StringPiece full_hash) override;
|
||||
HashPrefixStr GetMatchingHashPrefix(std::string_view full_hash) override;
|
||||
MigrateResult MigrateFileFormat(const base::FilePath& store_path,
|
||||
V4StoreFileFormat* file_format) override;
|
||||
void GetPrefixInfo(google::protobuf::RepeatedPtrField<
|
||||
@ -184,7 +185,7 @@ class MmapHashPrefixMap : public HashPrefixMap {
|
||||
std::unique_ptr<WriteSession> WriteToDisk(
|
||||
V4StoreFileFormat* file_format) override;
|
||||
ApplyUpdateResult IsValid() const override;
|
||||
HashPrefixStr GetMatchingHashPrefix(base::StringPiece full_hash) override;
|
||||
HashPrefixStr GetMatchingHashPrefix(std::string_view full_hash) override;
|
||||
MigrateResult MigrateFileFormat(const base::FilePath& store_path,
|
||||
V4StoreFileFormat* file_format) override;
|
||||
void GetPrefixInfo(google::protobuf::RepeatedPtrField<
|
||||
@ -209,7 +210,7 @@ class MmapHashPrefixMap : public HashPrefixMap {
|
||||
|
||||
HashPrefixesView GetView() const;
|
||||
bool IsReadable() const { return file_.IsValid(); }
|
||||
HashPrefixStr Matches(base::StringPiece full_hash) const;
|
||||
HashPrefixStr Matches(std::string_view full_hash) const;
|
||||
BufferedFileWriter* GetOrCreateWriter(size_t buffer_size);
|
||||
|
||||
const std::string& GetExtensionForTesting() const;
|
||||
|
@ -4,9 +4,11 @@
|
||||
|
||||
#include "components/safe_browsing/core/browser/db/prefix_iterator.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
namespace safe_browsing {
|
||||
|
||||
PrefixIterator::PrefixIterator(base::StringPiece prefixes,
|
||||
PrefixIterator::PrefixIterator(std::string_view prefixes,
|
||||
size_t index,
|
||||
size_t size)
|
||||
: prefixes_(prefixes), index_(index), size_(size) {}
|
||||
|
@ -7,8 +7,8 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "components/safe_browsing/core/browser/db/v4_protocol_manager_util.h"
|
||||
|
||||
namespace safe_browsing {
|
||||
@ -19,16 +19,16 @@ namespace safe_browsing {
|
||||
class PrefixIterator {
|
||||
public:
|
||||
using iterator_category = std::random_access_iterator_tag;
|
||||
using value_type = base::StringPiece;
|
||||
using value_type = std::string_view;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
using pointer = base::StringPiece*;
|
||||
using reference = base::StringPiece&;
|
||||
using pointer = std::string_view*;
|
||||
using reference = std::string_view&;
|
||||
|
||||
PrefixIterator(base::StringPiece prefixes, size_t index, size_t size);
|
||||
PrefixIterator(std::string_view prefixes, size_t index, size_t size);
|
||||
PrefixIterator(const PrefixIterator& rhs);
|
||||
|
||||
base::StringPiece operator*() const { return GetPiece(index_); }
|
||||
base::StringPiece operator[](const int& rhs) const {
|
||||
std::string_view operator*() const { return GetPiece(index_); }
|
||||
std::string_view operator[](const int& rhs) const {
|
||||
return GetPiece(index_ + rhs);
|
||||
}
|
||||
|
||||
@ -86,11 +86,11 @@ class PrefixIterator {
|
||||
}
|
||||
|
||||
private:
|
||||
base::StringPiece GetPiece(size_t index) const {
|
||||
std::string_view GetPiece(size_t index) const {
|
||||
return prefixes_.substr(index * size_, size_);
|
||||
}
|
||||
|
||||
base::StringPiece prefixes_;
|
||||
std::string_view prefixes_;
|
||||
size_t index_;
|
||||
size_t size_;
|
||||
};
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "components/safe_browsing/core/browser/db/v4_protocol_manager_util.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/base64.h"
|
||||
#include "base/hash/hash.h"
|
||||
#include "base/hash/sha1.h"
|
||||
@ -458,12 +460,12 @@ void V4ProtocolManagerUtil::CanonicalizeUrl(const GURL& url,
|
||||
url::Parsed parsed = url::ParseStandardURL(url_unescaped_str);
|
||||
|
||||
// 3. In hostname, remove all leading and trailing dots.
|
||||
base::StringPiece host;
|
||||
std::string_view host;
|
||||
if (parsed.host.is_nonempty())
|
||||
host = base::StringPiece(url_unescaped_str.data() + parsed.host.begin,
|
||||
parsed.host.len);
|
||||
host = std::string_view(url_unescaped_str.data() + parsed.host.begin,
|
||||
parsed.host.len);
|
||||
|
||||
base::StringPiece host_without_end_dots =
|
||||
std::string_view host_without_end_dots =
|
||||
base::TrimString(host, ".", base::TrimPositions::TRIM_ALL);
|
||||
|
||||
// 4. In hostname, replace consecutive dots with a single dot.
|
||||
@ -471,10 +473,10 @@ void V4ProtocolManagerUtil::CanonicalizeUrl(const GURL& url,
|
||||
RemoveConsecutiveChars(host_without_end_dots, '.'));
|
||||
|
||||
// 5. In path, replace runs of consecutive slashes with a single slash.
|
||||
base::StringPiece path;
|
||||
std::string_view path;
|
||||
if (parsed.path.is_nonempty())
|
||||
path = base::StringPiece(url_unescaped_str.data() + parsed.path.begin,
|
||||
parsed.path.len);
|
||||
path = std::string_view(url_unescaped_str.data() + parsed.path.begin,
|
||||
parsed.path.len);
|
||||
std::string path_without_consecutive_slash(RemoveConsecutiveChars(path, '/'));
|
||||
|
||||
url::Replacements<char> hp_replacements;
|
||||
@ -516,7 +518,7 @@ void V4ProtocolManagerUtil::CanonicalizeUrl(const GURL& url,
|
||||
}
|
||||
|
||||
// static
|
||||
std::string V4ProtocolManagerUtil::RemoveConsecutiveChars(base::StringPiece str,
|
||||
std::string V4ProtocolManagerUtil::RemoveConsecutiveChars(std::string_view str,
|
||||
const char c) {
|
||||
std::string output;
|
||||
// Output is at most the length of the original string.
|
||||
|
@ -13,13 +13,13 @@
|
||||
#include <iosfwd>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include "base/containers/flat_set.h"
|
||||
#include "base/gtest_prod_util.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "components/safe_browsing/core/browser/db/safebrowsing.pb.h"
|
||||
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
|
||||
#include "url/gurl.h"
|
||||
@ -437,8 +437,7 @@ class V4ProtocolManagerUtil {
|
||||
static void GeneratePathsToCheck(const GURL& url,
|
||||
std::vector<std::string>* paths);
|
||||
|
||||
static std::string RemoveConsecutiveChars(base::StringPiece str,
|
||||
const char c);
|
||||
static std::string RemoveConsecutiveChars(std::string_view str, const char c);
|
||||
};
|
||||
|
||||
using StoresToCheck = std::unordered_set<ListIdentifier>;
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "base/base64.h"
|
||||
@ -17,7 +18,6 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/metrics/histogram_functions.h"
|
||||
#include "base/metrics/histogram_macros.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/task/sequenced_task_runner.h"
|
||||
#include "base/timer/elapsed_timer.h"
|
||||
@ -1002,10 +1002,10 @@ StoreWriteResult V4Store::WriteToDisk(V4StoreFileFormat* file_format) {
|
||||
}
|
||||
|
||||
HashPrefixStr V4Store::GetMatchingHashPrefix(const FullHashStr& full_hash) {
|
||||
return GetMatchingHashPrefix(base::StringPiece(full_hash));
|
||||
return GetMatchingHashPrefix(std::string_view(full_hash));
|
||||
}
|
||||
|
||||
HashPrefixStr V4Store::GetMatchingHashPrefix(base::StringPiece full_hash) {
|
||||
HashPrefixStr V4Store::GetMatchingHashPrefix(std::string_view full_hash) {
|
||||
// It should never be the case that more than one hash prefixes match a given
|
||||
// full hash. However, if that happens, this method returns any one of them.
|
||||
// It does not guarantee which one of those will be returned.
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "base/files/file_path.h"
|
||||
@ -303,9 +304,9 @@ class V4Store {
|
||||
size_t removals_count,
|
||||
HashPrefixMap* prefix_map_to_update);
|
||||
|
||||
// Same as the public GetMatchingHashPrefix method, but takes a StringPiece,
|
||||
// for performance reasons.
|
||||
HashPrefixStr GetMatchingHashPrefix(base::StringPiece full_hash);
|
||||
// Same as the public GetMatchingHashPrefix method, but takes a
|
||||
// std::string_view, for performance reasons.
|
||||
HashPrefixStr GetMatchingHashPrefix(std::string_view full_hash);
|
||||
|
||||
// Merges the prefix map from the old store (|old_hash_prefix_map|) and the
|
||||
// update (additions_map) to populate the prefix map for the current store.
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@ -51,7 +52,7 @@ TEST_F(V4StorePerftest, StressTest) {
|
||||
// Keep the full hashes as one big string to avoid tons of allocations /
|
||||
// deallocations in the test.
|
||||
std::string full_hashes(kNumPrefixes * kMaxHashPrefixLength, 0);
|
||||
base::StringPiece full_hashes_piece = base::StringPiece(full_hashes);
|
||||
std::string_view full_hashes_piece = std::string_view(full_hashes);
|
||||
std::vector<std::string> prefixes;
|
||||
for (size_t i = 0; i < kNumPrefixes; i++) {
|
||||
size_t index = i * kMaxHashPrefixLength;
|
||||
@ -69,7 +70,7 @@ TEST_F(V4StorePerftest, StressTest) {
|
||||
base::ElapsedTimer timer;
|
||||
for (size_t i = 0; i < kNumPrefixes; i++) {
|
||||
size_t index = i * kMaxHashPrefixLength;
|
||||
base::StringPiece full_hash =
|
||||
std::string_view full_hash =
|
||||
full_hashes_piece.substr(index, kMaxHashPrefixLength);
|
||||
matches += !store->GetMatchingHashPrefix(full_hash).empty();
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "components/safe_browsing/core/browser/verdict_cache_manager.h"
|
||||
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/base64.h"
|
||||
#include "base/command_line.h"
|
||||
@ -186,13 +187,13 @@ std::string GetCacheExpressionPath(const std::string& cache_expression) {
|
||||
// For example, return 0 for "/", since there is no path after the leading
|
||||
// slash; return 3 for "/abc/def/gh.html".
|
||||
size_t GetPathDepth(const std::string& cache_expression_path) {
|
||||
return base::SplitString(base::StringPiece(cache_expression_path), "/",
|
||||
return base::SplitString(std::string_view(cache_expression_path), "/",
|
||||
base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY)
|
||||
.size();
|
||||
}
|
||||
|
||||
size_t GetHostDepth(const std::string& hostname) {
|
||||
return base::SplitString(base::StringPiece(hostname), ".",
|
||||
return base::SplitString(std::string_view(hostname), ".",
|
||||
base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY)
|
||||
.size();
|
||||
}
|
||||
@ -580,7 +581,7 @@ size_t VerdictCacheManager::GetStoredPhishGuardVerdictCount(
|
||||
content_settings_->GetSettingsForOneType(
|
||||
ContentSettingsType::PASSWORD_PROTECTION)) {
|
||||
for (auto item : source.setting_value.GetDict()) {
|
||||
if (item.first == base::StringPiece(kPasswordOnFocusCacheKey)) {
|
||||
if (item.first == std::string_view(kPasswordOnFocusCacheKey)) {
|
||||
stored_verdict_count_password_on_focus_.value() +=
|
||||
item.second.GetDict().size();
|
||||
} else {
|
||||
@ -606,7 +607,7 @@ size_t VerdictCacheManager::GetStoredRealTimeUrlCheckVerdictCount() {
|
||||
content_settings_->GetSettingsForOneType(
|
||||
ContentSettingsType::SAFE_BROWSING_URL_CHECK_DATA)) {
|
||||
for (auto item : source.setting_value.GetDict()) {
|
||||
if (item.first == base::StringPiece(kRealTimeUrlCacheKey)) {
|
||||
if (item.first == std::string_view(kRealTimeUrlCacheKey)) {
|
||||
stored_verdict_count_real_time_url_check_.value() +=
|
||||
item.second.GetDict().size();
|
||||
}
|
||||
|
@ -5,13 +5,13 @@
|
||||
#include "components/safe_search_api/safe_search_util.h"
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "base/check.h"
|
||||
#include "base/notreached.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/string_split.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "components/google/core/common/google_util.h"
|
||||
@ -24,11 +24,11 @@ namespace {
|
||||
// Returns whether a URL parameter, |first_parameter| (e.g. foo=bar), has the
|
||||
// same key as the the |second_parameter| (e.g. foo=baz). Both parameters
|
||||
// must be in key=value form.
|
||||
bool HasSameParameterKey(base::StringPiece first_parameter,
|
||||
base::StringPiece second_parameter) {
|
||||
bool HasSameParameterKey(std::string_view first_parameter,
|
||||
std::string_view second_parameter) {
|
||||
DCHECK(second_parameter.find("=") != std::string::npos);
|
||||
// Prefix for "foo=bar" is "foo=".
|
||||
base::StringPiece parameter_prefix =
|
||||
std::string_view parameter_prefix =
|
||||
second_parameter.substr(0, second_parameter.find("=") + 1);
|
||||
return base::StartsWith(first_parameter, parameter_prefix,
|
||||
base::CompareCase::INSENSITIVE_ASCII);
|
||||
@ -38,11 +38,11 @@ bool HasSameParameterKey(base::StringPiece first_parameter,
|
||||
// so that SafeSearch is active. |query| is the string to examine and the
|
||||
// return value is the |query| string modified such that SafeSearch is active.
|
||||
std::string AddSafeSearchParameters(const std::string& query) {
|
||||
std::vector<base::StringPiece> new_parameters;
|
||||
std::vector<std::string_view> new_parameters;
|
||||
std::string safe_parameter = safe_search_api::kSafeSearchSafeParameter;
|
||||
std::string ssui_parameter = safe_search_api::kSafeSearchSsuiParameter;
|
||||
|
||||
for (const base::StringPiece& param : base::SplitStringPiece(
|
||||
for (std::string_view param : base::SplitStringPiece(
|
||||
query, "&", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
|
||||
if (!HasSameParameterKey(param, safe_parameter) &&
|
||||
!HasSameParameterKey(param, ssui_parameter)) {
|
||||
|
@ -4,12 +4,12 @@
|
||||
|
||||
#include "components/search_engines/android/template_url_service_android.h"
|
||||
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "base/android/jni_android.h"
|
||||
#include "base/android/jni_string.h"
|
||||
#include "base/functional/callback_forward.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/test/metrics/histogram_tester.h"
|
||||
#include "base/test/scoped_feature_list.h"
|
||||
#include "components/search_engines/search_engine_choice/search_engine_choice_utils.h"
|
||||
@ -78,12 +78,12 @@ class TemplateUrlServiceAndroidUnitTest
|
||||
}
|
||||
|
||||
base::android::ScopedJavaLocalRef<jstring> ToLocalJavaString(
|
||||
base::StringPiece str) {
|
||||
std::string_view str) {
|
||||
return base::android::ConvertUTF8ToJavaString(env_, str);
|
||||
}
|
||||
|
||||
base::android::ScopedJavaLocalRef<jstring> ToLocalJavaString(
|
||||
base::StringPiece16 str) {
|
||||
std::u16string_view str) {
|
||||
return base::android::ConvertUTF16ToJavaString(env_, str);
|
||||
}
|
||||
|
||||
|
@ -8,13 +8,13 @@
|
||||
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string_view>
|
||||
#include <tuple>
|
||||
|
||||
#include "base/json/json_reader.h"
|
||||
#include "base/json/json_writer.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/string_split.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
@ -43,7 +43,7 @@ const char kBuiltinKeywordCountry[] = "Builtin Keyword Country";
|
||||
const char kStarterPackKeywordVersion[] = "Starter Pack Keyword Version";
|
||||
|
||||
const std::string ColumnsForVersion(int version, bool concatenated) {
|
||||
std::vector<base::StringPiece> columns;
|
||||
std::vector<std::string_view> columns;
|
||||
|
||||
columns.push_back("id");
|
||||
columns.push_back("short_name");
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "components/search_engines/search_engine_choice/search_engine_choice_service.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "base/check_deref.h"
|
||||
@ -1436,7 +1437,7 @@ struct RepromptTestParam {
|
||||
std::optional<RepromptResult> wildcard_result;
|
||||
std::optional<RepromptResult> country_result;
|
||||
// Version of the choice.
|
||||
const base::StringPiece choice_version;
|
||||
const std::string_view choice_version;
|
||||
// The reprompt params, as sent by the server. Use `CURRENT_VERSION` for the
|
||||
// current Chrome version, and `FUTURE_VERSION` for a future version.
|
||||
const char* param_dict;
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "components/search_engines/search_host_to_urls_map.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/ranges/algorithm.h"
|
||||
#include "components/search_engines/template_url.h"
|
||||
@ -53,8 +54,7 @@ void SearchHostToURLsMap::Remove(const TemplateURL* template_url) {
|
||||
host_to_urls_map_.erase(set_with_url);
|
||||
}
|
||||
|
||||
TemplateURL* SearchHostToURLsMap::GetTemplateURLForHost(
|
||||
base::StringPiece host) {
|
||||
TemplateURL* SearchHostToURLsMap::GetTemplateURLForHost(std::string_view host) {
|
||||
DCHECK(initialized_);
|
||||
|
||||
HostToURLsMap::const_iterator iter = host_to_urls_map_.find(host);
|
||||
@ -71,7 +71,7 @@ TemplateURL* SearchHostToURLsMap::GetTemplateURLForHost(
|
||||
}
|
||||
|
||||
SearchHostToURLsMap::TemplateURLSet* SearchHostToURLsMap::GetURLsForHost(
|
||||
base::StringPiece host) {
|
||||
std::string_view host) {
|
||||
DCHECK(initialized_);
|
||||
|
||||
auto urls_for_host = host_to_urls_map_.find(host);
|
||||
|
@ -8,10 +8,10 @@
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/containers/flat_set.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "components/search_engines/template_url.h"
|
||||
|
||||
// Holds the host to template url mappings for the search providers. WARNING:
|
||||
@ -42,11 +42,11 @@ class SearchHostToURLsMap {
|
||||
|
||||
// Returns the best TemplateURL found with a URL using the specified |host|,
|
||||
// or nullptr if there are no such TemplateURLs
|
||||
TemplateURL* GetTemplateURLForHost(base::StringPiece host);
|
||||
TemplateURL* GetTemplateURLForHost(std::string_view host);
|
||||
|
||||
// Return the TemplateURLSet for the given the |host| or NULL if there are
|
||||
// none.
|
||||
TemplateURLSet* GetURLsForHost(base::StringPiece host);
|
||||
TemplateURLSet* GetURLsForHost(std::string_view host);
|
||||
|
||||
private:
|
||||
friend class SearchHostToURLsMapTest;
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "components/search_engines/template_url.h"
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
@ -26,7 +27,6 @@
|
||||
#include "base/strings/escape.h"
|
||||
#include "base/strings/strcat.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/string_split.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
@ -133,7 +133,7 @@ bool TryEncoding(const std::u16string& terms,
|
||||
// Finds the position of the search terms' parameter in the URL component.
|
||||
class SearchTermLocation {
|
||||
public:
|
||||
SearchTermLocation(const base::StringPiece& url_component,
|
||||
SearchTermLocation(std::string_view url_component,
|
||||
url::Parsed::ComponentType url_component_type)
|
||||
: found_(false) {
|
||||
if (url_component_type == url::Parsed::PATH) {
|
||||
@ -147,7 +147,7 @@ class SearchTermLocation {
|
||||
query.len = static_cast<int>(url_component.size());
|
||||
while (url::ExtractQueryKeyValue(url_component, &query, &key, &value)) {
|
||||
if (key.is_nonempty() && value.is_nonempty()) {
|
||||
const base::StringPiece value_string =
|
||||
const std::string_view value_string =
|
||||
url_component.substr(value.begin, value.len);
|
||||
if (TryMatchSearchParam(value_string, kSearchTermsParameterFull) ||
|
||||
TryMatchSearchParam(value_string,
|
||||
@ -172,11 +172,11 @@ class SearchTermLocation {
|
||||
private:
|
||||
// Returns true if the search term placeholder is present, and also assigns
|
||||
// the constant prefix/suffix found.
|
||||
bool TryMatchSearchParam(const base::StringPiece& value,
|
||||
const base::StringPiece& pattern) {
|
||||
bool TryMatchSearchParam(std::string_view value, std::string_view pattern) {
|
||||
size_t pos = value.find(pattern);
|
||||
if (pos == base::StringPiece::npos)
|
||||
if (pos == std::string_view::npos) {
|
||||
return false;
|
||||
}
|
||||
value_prefix_ = std::string(value.substr(0, pos));
|
||||
value_suffix_ = std::string(value.substr(pos + pattern.size()));
|
||||
return true;
|
||||
@ -552,7 +552,7 @@ const std::string& TemplateURLRef::GetSearchTermValueSuffix(
|
||||
}
|
||||
|
||||
std::u16string TemplateURLRef::SearchTermToString16(
|
||||
const base::StringPiece& term) const {
|
||||
std::string_view term) const {
|
||||
const std::vector<std::string>& encodings = owner_->input_encodings();
|
||||
std::u16string result;
|
||||
|
||||
@ -615,7 +615,7 @@ bool TemplateURLRef::ExtractSearchTermsFromURL(
|
||||
return false;
|
||||
}
|
||||
|
||||
base::StringPiece source;
|
||||
std::string_view source;
|
||||
url::Component position;
|
||||
|
||||
if (search_term_key_location_ == url::Parsed::PATH) {
|
||||
@ -650,8 +650,8 @@ bool TemplateURLRef::ExtractSearchTermsFromURL(
|
||||
|
||||
// If the query parameter does not contain the expected prefix and
|
||||
// suffix, then this is not a match.
|
||||
base::StringPiece search_term =
|
||||
base::StringPiece(source).substr(value.begin, value.len);
|
||||
std::string_view search_term =
|
||||
std::string_view(source).substr(value.begin, value.len);
|
||||
if (search_term.size() < (search_term_value_prefix_.size() +
|
||||
search_term_value_suffix_.size()) ||
|
||||
!base::StartsWith(search_term, search_term_value_prefix_) ||
|
||||
@ -702,7 +702,7 @@ bool TemplateURLRef::ParseParameter(size_t start,
|
||||
size_t length = end - start - 1;
|
||||
bool optional = false;
|
||||
// Make a copy of |url| that can be referenced in StringPieces below. |url| is
|
||||
// modified, so that can't be used in StringPiece.
|
||||
// modified, so that can't be used in std::string_view.
|
||||
const std::string original_url(*url);
|
||||
if (original_url[end - 1] == kOptional) {
|
||||
optional = true;
|
||||
@ -872,9 +872,9 @@ std::string TemplateURLRef::ParseURL(const std::string& url,
|
||||
// Handles the post parameters.
|
||||
const std::string& post_params_string = GetPostParamsString();
|
||||
if (!post_params_string.empty()) {
|
||||
for (const base::StringPiece& cur : base::SplitStringPiece(
|
||||
post_params_string, ",",
|
||||
base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
|
||||
for (std::string_view cur :
|
||||
base::SplitStringPiece(post_params_string, ",", base::TRIM_WHITESPACE,
|
||||
base::SPLIT_WANT_ALL)) {
|
||||
// The '=' delimiter is required and the name must be not empty.
|
||||
std::vector<std::string> parts = base::SplitString(
|
||||
cur, "=", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
|
||||
@ -949,7 +949,7 @@ void TemplateURLRef::ParsePath(const std::string& path) const {
|
||||
}
|
||||
|
||||
bool TemplateURLRef::PathIsEqual(const GURL& url) const {
|
||||
base::StringPiece path = url.path_piece();
|
||||
std::string_view path = url.path_piece();
|
||||
if (!path_wildcard_present_)
|
||||
return path == path_prefix_;
|
||||
return ((path.length() >= path_prefix_.length() + path_suffix_.length()) &&
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@ -380,7 +381,7 @@ class TemplateURLRef {
|
||||
const SearchTermsData& search_terms_data) const;
|
||||
|
||||
// Converts the specified term in our owner's encoding to a std::u16string.
|
||||
std::u16string SearchTermToString16(const base::StringPiece& term) const;
|
||||
std::u16string SearchTermToString16(std::string_view term) const;
|
||||
|
||||
// Returns true if this TemplateURLRef has a replacement term of
|
||||
// {google:baseURL} or {google:baseSuggestURL}.
|
||||
|
@ -4,9 +4,10 @@
|
||||
|
||||
#include "components/search_engines/template_url_data.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/check.h"
|
||||
#include "base/i18n/case_conversion.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
@ -62,25 +63,25 @@ TemplateURLData& TemplateURLData::operator=(const TemplateURLData& other) =
|
||||
TemplateURLData::TemplateURLData(
|
||||
std::u16string_view name,
|
||||
std::u16string_view keyword,
|
||||
base::StringPiece search_url,
|
||||
base::StringPiece suggest_url,
|
||||
base::StringPiece image_url,
|
||||
base::StringPiece image_translate_url,
|
||||
base::StringPiece new_tab_url,
|
||||
base::StringPiece contextual_search_url,
|
||||
base::StringPiece logo_url,
|
||||
base::StringPiece doodle_url,
|
||||
base::StringPiece search_url_post_params,
|
||||
base::StringPiece suggest_url_post_params,
|
||||
base::StringPiece image_url_post_params,
|
||||
base::StringPiece side_search_param,
|
||||
base::StringPiece side_image_search_param,
|
||||
base::StringPiece image_translate_source_language_param_key,
|
||||
base::StringPiece image_translate_target_language_param_key,
|
||||
std::string_view search_url,
|
||||
std::string_view suggest_url,
|
||||
std::string_view image_url,
|
||||
std::string_view image_translate_url,
|
||||
std::string_view new_tab_url,
|
||||
std::string_view contextual_search_url,
|
||||
std::string_view logo_url,
|
||||
std::string_view doodle_url,
|
||||
std::string_view search_url_post_params,
|
||||
std::string_view suggest_url_post_params,
|
||||
std::string_view image_url_post_params,
|
||||
std::string_view side_search_param,
|
||||
std::string_view side_image_search_param,
|
||||
std::string_view image_translate_source_language_param_key,
|
||||
std::string_view image_translate_target_language_param_key,
|
||||
std::vector<std::string> search_intent_params,
|
||||
base::StringPiece favicon_url,
|
||||
base::StringPiece encoding,
|
||||
base::StringPiece16 image_search_branding_label,
|
||||
std::string_view favicon_url,
|
||||
std::string_view encoding,
|
||||
std::u16string_view image_search_branding_label,
|
||||
const base::Value::List& alternate_urls_list,
|
||||
bool preconnect_to_search_url,
|
||||
bool prefetch_likely_navigations,
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define COMPONENTS_SEARCH_ENGINES_TEMPLATE_URL_DATA_H_
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "base/time/time.h"
|
||||
@ -31,29 +32,29 @@ struct TemplateURLData {
|
||||
// Note that unlike in the default constructor, |safe_for_autoreplace| will
|
||||
// be set to true. date_created and last_modified will be set to null time
|
||||
// value, instead of current time.
|
||||
// StringPiece in arguments is used to pass const char* pointer members
|
||||
// std::string_view in arguments is used to pass const char* pointer members
|
||||
// of PrepopulatedEngine structure which can be nullptr.
|
||||
TemplateURLData(std::u16string_view name,
|
||||
std::u16string_view keyword,
|
||||
base::StringPiece search_url,
|
||||
base::StringPiece suggest_url,
|
||||
base::StringPiece image_url,
|
||||
base::StringPiece image_translate_url,
|
||||
base::StringPiece new_tab_url,
|
||||
base::StringPiece contextual_search_url,
|
||||
base::StringPiece logo_url,
|
||||
base::StringPiece doodle_url,
|
||||
base::StringPiece search_url_post_params,
|
||||
base::StringPiece suggest_url_post_params,
|
||||
base::StringPiece image_url_post_params,
|
||||
base::StringPiece side_search_param,
|
||||
base::StringPiece side_image_search_param,
|
||||
base::StringPiece image_translate_source_language_param_key,
|
||||
base::StringPiece image_translate_target_language_param_key,
|
||||
std::string_view search_url,
|
||||
std::string_view suggest_url,
|
||||
std::string_view image_url,
|
||||
std::string_view image_translate_url,
|
||||
std::string_view new_tab_url,
|
||||
std::string_view contextual_search_url,
|
||||
std::string_view logo_url,
|
||||
std::string_view doodle_url,
|
||||
std::string_view search_url_post_params,
|
||||
std::string_view suggest_url_post_params,
|
||||
std::string_view image_url_post_params,
|
||||
std::string_view side_search_param,
|
||||
std::string_view side_image_search_param,
|
||||
std::string_view image_translate_source_language_param_key,
|
||||
std::string_view image_translate_target_language_param_key,
|
||||
std::vector<std::string> search_intent_params,
|
||||
base::StringPiece favicon_url,
|
||||
base::StringPiece encoding,
|
||||
base::StringPiece16 image_search_branding_label,
|
||||
std::string_view favicon_url,
|
||||
std::string_view encoding,
|
||||
std::u16string_view image_search_branding_label,
|
||||
const base::Value::List& alternate_urls_list,
|
||||
bool preconnect_to_search_url,
|
||||
bool prefetch_likely_navigations,
|
||||
|
@ -4,7 +4,8 @@
|
||||
|
||||
#include "components/search_engines/template_url_data.h"
|
||||
|
||||
#include "base/strings/string_piece.h"
|
||||
#include <string_view>
|
||||
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/values.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
@ -12,12 +13,12 @@
|
||||
TEST(TemplateURLDataTest, Trim) {
|
||||
TemplateURLData data(
|
||||
u" shortname ", u" keyword ", "https://cs.chromium.org",
|
||||
base::StringPiece(), base::StringPiece(), base::StringPiece(),
|
||||
base::StringPiece(), base::StringPiece(), base::StringPiece(),
|
||||
base::StringPiece(), base::StringPiece(), base::StringPiece(),
|
||||
base::StringPiece(), base::StringPiece(), base::StringPiece(),
|
||||
base::StringPiece(), base::StringPiece(), {}, base::StringPiece(),
|
||||
base::StringPiece(), base::StringPiece16(), base::Value::List(), false,
|
||||
std::string_view(), std::string_view(), std::string_view(),
|
||||
std::string_view(), std::string_view(), std::string_view(),
|
||||
std::string_view(), std::string_view(), std::string_view(),
|
||||
std::string_view(), std::string_view(), std::string_view(),
|
||||
std::string_view(), std::string_view(), {}, std::string_view(),
|
||||
std::string_view(), std::u16string_view(), base::Value::List(), false,
|
||||
false, 0);
|
||||
|
||||
EXPECT_EQ(u"shortname", data.short_name());
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <string_view>
|
||||
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/values.h"
|
||||
#include "components/search_engines/default_search_manager.h"
|
||||
@ -20,10 +19,10 @@
|
||||
|
||||
namespace {
|
||||
|
||||
// Converts the C-style string `str` to a base::StringPiece making sure to avoid
|
||||
// Converts the C-style string `str` to a std::string_view making sure to avoid
|
||||
// dereferencing nullptrs.
|
||||
base::StringPiece ToStringPiece(const char* str) {
|
||||
return str ? base::StringPiece(str) : base::StringPiece();
|
||||
std::string_view ToStringPiece(const char* str) {
|
||||
return str ? std::string_view(str) : std::string_view();
|
||||
}
|
||||
|
||||
std::u16string_view ToU16StringView(const char16_t* str) {
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/base64.h"
|
||||
#include "base/check.h"
|
||||
@ -19,7 +20,6 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/memory/ref_counted_memory.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/values.h"
|
||||
#include "components/google/core/common/google_util.h"
|
||||
@ -150,7 +150,7 @@ std::unique_ptr<EncodedLogo> ParseDoodleLogoResponse(
|
||||
base::Time response_time,
|
||||
bool* parsing_failed) {
|
||||
// The response may start with )]}'. Ignore this.
|
||||
base::StringPiece response_sp(*response);
|
||||
std::string_view response_sp(*response);
|
||||
if (base::StartsWith(response_sp, kResponsePreamble)) {
|
||||
response_sp.remove_prefix(strlen(kResponsePreamble));
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "base/files/file_util.h"
|
||||
@ -83,7 +84,7 @@ void SetTimeValue(base::Value::Dict& dict,
|
||||
dict.Set(key, base::NumberToString(internal_time_value));
|
||||
}
|
||||
|
||||
LogoType LogoTypeFromString(base::StringPiece type) {
|
||||
LogoType LogoTypeFromString(std::string_view type) {
|
||||
if (type == kSimpleType) {
|
||||
return LogoType::SIMPLE;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "base/base64.h"
|
||||
@ -19,7 +20,6 @@
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/task/single_thread_task_runner.h"
|
||||
@ -407,8 +407,8 @@ class LogoServiceImplTest : public ::testing::Test {
|
||||
void GetDecodedLogo(LogoCallback cached, LogoCallback fresh);
|
||||
void GetEncodedLogo(EncodedLogoCallback cached, EncodedLogoCallback fresh);
|
||||
|
||||
void AddSearchEngine(base::StringPiece keyword,
|
||||
base::StringPiece short_name,
|
||||
void AddSearchEngine(std::string_view keyword,
|
||||
std::string_view short_name,
|
||||
const std::string& url,
|
||||
GURL doodle_url,
|
||||
bool make_default);
|
||||
@ -501,8 +501,8 @@ void LogoServiceImplTest::GetEncodedLogo(EncodedLogoCallback cached,
|
||||
GetLogo(std::move(callbacks));
|
||||
}
|
||||
|
||||
void LogoServiceImplTest::AddSearchEngine(base::StringPiece keyword,
|
||||
base::StringPiece short_name,
|
||||
void LogoServiceImplTest::AddSearchEngine(std::string_view keyword,
|
||||
std::string_view short_name,
|
||||
const std::string& url,
|
||||
GURL doodle_url,
|
||||
bool make_default) {
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/metrics/metrics_hashes.h"
|
||||
@ -129,7 +130,7 @@ void DatabaseApiClients::AddSumGroupQuery(
|
||||
|
||||
// static
|
||||
void DatabaseApiClients::AddSumQuery(MetadataWriter& writer,
|
||||
base::StringPiece metric_name,
|
||||
std::string_view metric_name,
|
||||
int days) {
|
||||
std::string query = base::StringPrintf(
|
||||
"SELECT SUM(metric_value) FROM metrics WHERE metric_hash = '%" PRIX64
|
||||
|
@ -8,8 +8,8 @@
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "components/segmentation_platform/internal/metadata/metadata_writer.h"
|
||||
#include "components/segmentation_platform/public/config.h"
|
||||
#include "components/segmentation_platform/public/model_provider.h"
|
||||
@ -34,13 +34,13 @@ class DatabaseApiClients : public DefaultModelProvider {
|
||||
|
||||
// Helper to write a query to sum the `metric_name` for the past `days`.
|
||||
static void AddSumQuery(MetadataWriter& writer,
|
||||
base::StringPiece metric_name,
|
||||
std::string_view metric_name,
|
||||
int days);
|
||||
|
||||
// Helper to write a query to get the sum of metric values for a given
|
||||
// `event_name` and a collection of `metric_names` for the past `days`.
|
||||
static void AddSumGroupQuery(MetadataWriter& writer,
|
||||
base::StringPiece event_name,
|
||||
std::string_view event_name,
|
||||
const std::set<std::string>& metric_names,
|
||||
int days);
|
||||
|
||||
|
@ -3,10 +3,11 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "components/segmentation_platform/embedder/default_model/device_switcher_result_dispatcher.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/run_loop.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/test/gmock_callback_support.h"
|
||||
#include "base/test/gmock_move_support.h"
|
||||
#include "base/test/task_environment.h"
|
||||
@ -59,11 +60,10 @@ std::unique_ptr<DeviceInfo> CreateDeviceInfo(
|
||||
class MockFieldTrialRegister : public FieldTrialRegister {
|
||||
public:
|
||||
MOCK_METHOD2(RegisterFieldTrial,
|
||||
void(base::StringPiece trial_name,
|
||||
base::StringPiece group_name));
|
||||
void(std::string_view trial_name, std::string_view group_name));
|
||||
|
||||
MOCK_METHOD3(RegisterSubsegmentFieldTrialIfNeeded,
|
||||
void(base::StringPiece trial_name,
|
||||
void(std::string_view trial_name,
|
||||
proto::SegmentId segment_id,
|
||||
int subsegment_rank));
|
||||
};
|
||||
@ -123,7 +123,7 @@ TEST_F(DeviceSwitcherResultDispatcherTest, SegmentationFailed) {
|
||||
.WillOnce(RunOnceCallback<3>(result));
|
||||
|
||||
EXPECT_CALL(field_trial_register_,
|
||||
RegisterFieldTrial(_, base::StringPiece("Unselected")));
|
||||
RegisterFieldTrial(_, std::string_view("Unselected")));
|
||||
|
||||
// The DeviceSwitcherResultDispatcher will find the result returned by the
|
||||
// segmentation platform service.
|
||||
@ -150,7 +150,7 @@ TEST_F(DeviceSwitcherResultDispatcherTest, TestWaitForClassificationResult) {
|
||||
.WillOnce(RunOnceCallback<3>(result));
|
||||
|
||||
EXPECT_CALL(field_trial_register_,
|
||||
RegisterFieldTrial(_, base::StringPiece("test_label1")));
|
||||
RegisterFieldTrial(_, std::string_view("test_label1")));
|
||||
|
||||
// The DeviceSwitcherResultDispatcher will find the result returned by the
|
||||
// segmentation platform service.
|
||||
@ -178,11 +178,11 @@ TEST_F(DeviceSwitcherResultDispatcherTest, ResultRefreshedOnSyncConsent) {
|
||||
|
||||
EXPECT_CALL(field_trial_register_,
|
||||
RegisterFieldTrial(
|
||||
_, base::StringPiece(DeviceSwitcherModel::kNotSyncedLabel)));
|
||||
_, std::string_view(DeviceSwitcherModel::kNotSyncedLabel)));
|
||||
EXPECT_CALL(
|
||||
field_trial_register_,
|
||||
RegisterFieldTrial(
|
||||
_, base::StringPiece(DeviceSwitcherModel::kAndroidPhoneLabel)));
|
||||
_, std::string_view(DeviceSwitcherModel::kAndroidPhoneLabel)));
|
||||
|
||||
// The DeviceSwitcherResultDispatcher will find the result returned by the
|
||||
// segmentation platform service.
|
||||
@ -246,7 +246,7 @@ TEST_F(DeviceSwitcherResultDispatcherTest,
|
||||
.WillRepeatedly(MoveArg<3>(&callback));
|
||||
|
||||
EXPECT_CALL(field_trial_register_,
|
||||
RegisterFieldTrial(_, base::StringPiece("test_label1")));
|
||||
RegisterFieldTrial(_, std::string_view("test_label1")));
|
||||
|
||||
// The DeviceSwitcherResultDispatcher will wait for the result returned by the
|
||||
// segmentation platform service.
|
||||
|
3
components/segmentation_platform/internal/data_collection/training_data_collector_impl_unittest.cc
3
components/segmentation_platform/internal/data_collection/training_data_collector_impl_unittest.cc
@ -5,6 +5,7 @@
|
||||
#include "components/segmentation_platform/internal/data_collection/training_data_collector_impl.h"
|
||||
|
||||
#include <map>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/functional/callback_helpers.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
@ -361,7 +362,7 @@ class TrainingDataCollectorImplTest
|
||||
|
||||
// TODO(xingliu): Share this test code with SegmentationUkmHelperTest, or test
|
||||
// with mock SegmentationUkmHelperTest.
|
||||
void ExpectUkm(std::vector<base::StringPiece> metric_names,
|
||||
void ExpectUkm(std::vector<std::string_view> metric_names,
|
||||
std::vector<int64_t> expected_values) {
|
||||
const auto& entries = test_recorder_.GetEntriesByName(
|
||||
Segmentation_ModelExecution::kEntryName);
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "components/segmentation_platform/internal/database/ukm_database.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
namespace segmentation_platform {
|
||||
|
||||
UkmDatabase::CustomSqlQuery::CustomSqlQuery() = default;
|
||||
@ -11,7 +13,7 @@ UkmDatabase::CustomSqlQuery::CustomSqlQuery() = default;
|
||||
UkmDatabase::CustomSqlQuery::CustomSqlQuery(CustomSqlQuery&&) = default;
|
||||
|
||||
UkmDatabase::CustomSqlQuery::CustomSqlQuery(
|
||||
const base::StringPiece& query,
|
||||
std::string_view query,
|
||||
const std::vector<processing::ProcessedValue>& bind_values)
|
||||
: query(query), bind_values(bind_values) {}
|
||||
|
||||
|
@ -7,10 +7,10 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "base/functional/callback.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/time/time.h"
|
||||
#include "components/segmentation_platform/internal/database/ukm_types.h"
|
||||
#include "services/metrics/public/cpp/ukm_source_id.h"
|
||||
@ -73,7 +73,7 @@ class UkmDatabase {
|
||||
struct CustomSqlQuery {
|
||||
CustomSqlQuery();
|
||||
CustomSqlQuery(CustomSqlQuery&&);
|
||||
CustomSqlQuery(const base::StringPiece& query,
|
||||
CustomSqlQuery(std::string_view query,
|
||||
const std::vector<processing::ProcessedValue>& bind_values);
|
||||
~CustomSqlQuery();
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "components/segmentation_platform/internal/database/ukm_database_test_utils.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "components/segmentation_platform/internal/database/ukm_types.h"
|
||||
#include "sql/database.h"
|
||||
@ -59,7 +61,7 @@ bool operator==(const UrlMatcher& row1, const UrlMatcher& row2) {
|
||||
}
|
||||
|
||||
std::vector<UkmMetricsTable::MetricsRow> GetMetricsRowWithQuery(
|
||||
base::StringPiece query,
|
||||
std::string_view query,
|
||||
sql::Database& db) {
|
||||
sql::Statement statement(db.GetUniqueStatement(query.data()));
|
||||
std::vector<UkmMetricsTable::MetricsRow> rows;
|
||||
@ -109,7 +111,7 @@ void AssertUrlsInTable(sql::Database& db, const std::vector<UrlMatcher>& urls) {
|
||||
EXPECT_THAT(actual_rows, UnorderedElementsAreArray(urls));
|
||||
}
|
||||
|
||||
std::vector<UmaMetricEntry> GetUmaMetricsRowWithQuery(base::StringPiece query,
|
||||
std::vector<UmaMetricEntry> GetUmaMetricsRowWithQuery(std::string_view query,
|
||||
sql::Database& db) {
|
||||
sql::Statement statement(db.GetUniqueStatement(query.data()));
|
||||
std::vector<UmaMetricEntry> rows;
|
||||
|
@ -5,6 +5,8 @@
|
||||
#ifndef COMPONENTS_SEGMENTATION_PLATFORM_INTERNAL_DATABASE_UKM_DATABASE_TEST_UTILS_H_
|
||||
#define COMPONENTS_SEGMENTATION_PLATFORM_INTERNAL_DATABASE_UKM_DATABASE_TEST_UTILS_H_
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "components/segmentation_platform/internal/database/ukm_metrics_table.h"
|
||||
#include "components/segmentation_platform/internal/database/ukm_types.h"
|
||||
#include "url/gurl.h"
|
||||
@ -14,7 +16,7 @@ namespace segmentation_platform::test_util {
|
||||
// Runs a `SELECT * FROM metrics WHERE cond` type query and returns the metrics
|
||||
// rows.
|
||||
std::vector<UkmMetricsTable::MetricsRow> GetMetricsRowWithQuery(
|
||||
base::StringPiece query,
|
||||
std::string_view query,
|
||||
sql::Database& db);
|
||||
|
||||
// Gets all rows from metrics table.
|
||||
@ -41,7 +43,7 @@ std::vector<UmaMetricEntry> GetAllUmaMetrics(sql::Database& db);
|
||||
|
||||
// Runs a `SELECT * FROM uma_metrics WHERE cond` type query and returns the
|
||||
// metrics rows.
|
||||
std::vector<UmaMetricEntry> GetUmaMetricsRowWithQuery(base::StringPiece query,
|
||||
std::vector<UmaMetricEntry> GetUmaMetricsRowWithQuery(std::string_view query,
|
||||
sql::Database& db);
|
||||
|
||||
// Checks UMA rows are equal.
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "components/segmentation_platform/internal/execution/processing/custom_input_processor.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/rand_util.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/system/sys_info.h"
|
||||
@ -36,7 +38,7 @@ std::optional<int> GetArgAsInt(
|
||||
|
||||
// Perform string to int conversion, return empty value if the conversion
|
||||
// failed.
|
||||
if (!base::StringToInt(base::StringPiece(iter->second), &value)) {
|
||||
if (!base::StringToInt(std::string_view(iter->second), &value)) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "components/segmentation_platform/internal/metrics/field_trial_recorder.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "components/prefs/pref_registry_simple.h"
|
||||
#include "components/prefs/testing_pref_service.h"
|
||||
#include "components/segmentation_platform/internal/constants.h"
|
||||
@ -34,11 +36,10 @@ proto::ClientResult CreateClientResult(proto::PredictionResult pred_result) {
|
||||
class MockFieldTrialRegister : public FieldTrialRegister {
|
||||
public:
|
||||
MOCK_METHOD2(RegisterFieldTrial,
|
||||
void(base::StringPiece trial_name,
|
||||
base::StringPiece group_name));
|
||||
void(std::string_view trial_name, std::string_view group_name));
|
||||
|
||||
MOCK_METHOD3(RegisterSubsegmentFieldTrialIfNeeded,
|
||||
void(base::StringPiece trial_name,
|
||||
void(std::string_view trial_name,
|
||||
proto::SegmentId segment_id,
|
||||
int subsegment_rank));
|
||||
};
|
||||
@ -75,8 +76,8 @@ TEST_F(FieldTrialRecorderTest, RecordUnselectedFieldTrial) {
|
||||
std::make_unique<CachedResultProvider>(result_prefs_.get(), configs_);
|
||||
|
||||
EXPECT_CALL(field_trial_register_,
|
||||
RegisterFieldTrial(base::StringPiece("Segmentation_test_key"),
|
||||
base::StringPiece("Unselected")));
|
||||
RegisterFieldTrial(std::string_view("Segmentation_test_key"),
|
||||
std::string_view("Unselected")));
|
||||
|
||||
field_trial_recorder_->RecordFieldTrialAtStartup(
|
||||
configs_, cached_result_provider_.get());
|
||||
@ -92,8 +93,8 @@ TEST_F(FieldTrialRecorderTest, RecordFieldTrial) {
|
||||
std::make_unique<CachedResultProvider>(result_prefs_.get(), configs_);
|
||||
|
||||
EXPECT_CALL(field_trial_register_,
|
||||
RegisterFieldTrial(base::StringPiece("Segmentation_test_key"),
|
||||
base::StringPiece("High")));
|
||||
RegisterFieldTrial(std::string_view("Segmentation_test_key"),
|
||||
std::string_view("High")));
|
||||
|
||||
field_trial_recorder_->RecordFieldTrialAtStartup(
|
||||
configs_, cached_result_provider_.get());
|
||||
@ -110,8 +111,8 @@ TEST_F(FieldTrialRecorderTest, RecordFieldTrialForNonClassification) {
|
||||
std::make_unique<CachedResultProvider>(result_prefs_.get(), configs_);
|
||||
|
||||
EXPECT_CALL(field_trial_register_,
|
||||
RegisterFieldTrial(base::StringPiece("Segmentation_test_key"),
|
||||
base::StringPiece("Unselected")));
|
||||
RegisterFieldTrial(std::string_view("Segmentation_test_key"),
|
||||
std::string_view("Unselected")));
|
||||
|
||||
field_trial_recorder_->RecordFieldTrialAtStartup(
|
||||
configs_, cached_result_provider_.get());
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "components/segmentation_platform/internal/segmentation_platform_service_test_base.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/test/test_simple_task_runner.h"
|
||||
#include "base/time/time.h"
|
||||
#include "base/values.h"
|
||||
@ -27,10 +29,9 @@ using syncer::DeviceInfoTracker;
|
||||
class MockFieldTrialRegister : public FieldTrialRegister {
|
||||
public:
|
||||
MOCK_METHOD2(RegisterFieldTrial,
|
||||
void(base::StringPiece trial_name,
|
||||
base::StringPiece group_name));
|
||||
void(std::string_view trial_name, std::string_view group_name));
|
||||
MOCK_METHOD3(RegisterSubsegmentFieldTrialIfNeeded,
|
||||
void(base::StringPiece trial_name,
|
||||
void(std::string_view trial_name,
|
||||
proto::SegmentId segment_id,
|
||||
int subsegment_rank));
|
||||
};
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <cmath>
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/bit_cast.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
@ -90,8 +91,8 @@ class SegmentationUkmHelperTest : public testing::Test {
|
||||
SegmentationUkmHelper::GetInstance()->Initialize();
|
||||
}
|
||||
|
||||
void ExpectUkmMetrics(const base::StringPiece entry_name,
|
||||
const std::vector<base::StringPiece>& keys,
|
||||
void ExpectUkmMetrics(const std::string_view entry_name,
|
||||
const std::vector<std::string_view>& keys,
|
||||
const std::vector<int64_t>& values) {
|
||||
const auto& entries = test_recorder_.GetEntriesByName(entry_name);
|
||||
EXPECT_EQ(1u, entries.size());
|
||||
@ -104,7 +105,7 @@ class SegmentationUkmHelperTest : public testing::Test {
|
||||
}
|
||||
}
|
||||
|
||||
void ExpectEmptyUkmMetrics(const base::StringPiece entry_name) {
|
||||
void ExpectEmptyUkmMetrics(const std::string_view entry_name) {
|
||||
EXPECT_EQ(0u, test_recorder_.GetEntriesByName(entry_name).size());
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "components/segmentation_platform/internal/execution/model_execution_status.h"
|
||||
#include "components/segmentation_platform/internal/selection/segment_selector_impl.h"
|
||||
#include <string_view>
|
||||
|
||||
#include "base/run_loop.h"
|
||||
#include "base/test/simple_test_clock.h"
|
||||
@ -13,9 +11,11 @@
|
||||
#include "components/segmentation_platform/internal/database/segment_info_database.h"
|
||||
#include "components/segmentation_platform/internal/database/test_segment_info_database.h"
|
||||
#include "components/segmentation_platform/internal/execution/mock_model_provider.h"
|
||||
#include "components/segmentation_platform/internal/execution/model_execution_status.h"
|
||||
#include "components/segmentation_platform/internal/execution/model_executor_impl.h"
|
||||
#include "components/segmentation_platform/internal/execution/processing/mock_feature_list_query_processor.h"
|
||||
#include "components/segmentation_platform/internal/metadata/metadata_utils.h"
|
||||
#include "components/segmentation_platform/internal/selection/segment_selector_impl.h"
|
||||
#include "components/segmentation_platform/internal/selection/segmentation_result_prefs.h"
|
||||
#include "components/segmentation_platform/public/config.h"
|
||||
#include "components/segmentation_platform/public/field_trial_register.h"
|
||||
@ -39,11 +39,10 @@ using ::testing::NiceMock;
|
||||
class MockFieldTrialRegister : public FieldTrialRegister {
|
||||
public:
|
||||
MOCK_METHOD2(RegisterFieldTrial,
|
||||
void(base::StringPiece trial_name,
|
||||
base::StringPiece group_name));
|
||||
void(std::string_view trial_name, std::string_view group_name));
|
||||
|
||||
MOCK_METHOD3(RegisterSubsegmentFieldTrialIfNeeded,
|
||||
void(base::StringPiece trial_name,
|
||||
void(std::string_view trial_name,
|
||||
proto::SegmentId segment_id,
|
||||
int subsegment_rank));
|
||||
};
|
||||
@ -191,8 +190,8 @@ class SegmentSelectorTest : public testing::Test {
|
||||
void ExpectFieldTrials(const std::vector<std::string>& groups) {
|
||||
for (const std::string& group : groups) {
|
||||
EXPECT_CALL(field_trial_register_,
|
||||
RegisterFieldTrial(base::StringPiece("Segmentation_TestKey"),
|
||||
base::StringPiece(group)));
|
||||
RegisterFieldTrial(std::string_view("Segmentation_TestKey"),
|
||||
std::string_view(group)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -530,8 +529,8 @@ TEST_F(SegmentSelectorTest, SubsegmentRecording) {
|
||||
// Previous selection result is not available at this time, so it should
|
||||
// record unselected.
|
||||
EXPECT_CALL(field_trial_register_,
|
||||
RegisterFieldTrial(base::StringPiece("Segmentation_TestKey"),
|
||||
base::StringPiece("Unselected")));
|
||||
RegisterFieldTrial(std::string_view("Segmentation_TestKey"),
|
||||
std::string_view("Unselected")));
|
||||
SetUpWithConfig(std::move(config));
|
||||
|
||||
// Store model metadata, model scores and selection results.
|
||||
@ -564,8 +563,8 @@ TEST_F(SegmentSelectorTest, SubsegmentRecording) {
|
||||
prefs_->selection = from_history;
|
||||
|
||||
EXPECT_CALL(field_trial_register_,
|
||||
RegisterFieldTrial(base::StringPiece("Segmentation_TestKey"),
|
||||
base::StringPiece("Share")));
|
||||
RegisterFieldTrial(std::string_view("Segmentation_TestKey"),
|
||||
std::string_view("Share")));
|
||||
|
||||
// Construct a segment selector. It should read result from last session.
|
||||
segment_selector_ = std::make_unique<SegmentSelectorImpl>(
|
||||
@ -576,7 +575,7 @@ TEST_F(SegmentSelectorTest, SubsegmentRecording) {
|
||||
// When segment result is missing, unknown subsegment is recorded, otherwise
|
||||
// record metrics based on the subsegment mapping.
|
||||
base::RunLoop wait_for_subsegment;
|
||||
std::vector<std::tuple<base::StringPiece, SegmentId, int>> actual_calls;
|
||||
std::vector<std::tuple<std::string_view, SegmentId, int>> actual_calls;
|
||||
int call_count = 0;
|
||||
|
||||
EXPECT_CALL(field_trial_register_,
|
||||
@ -584,7 +583,7 @@ TEST_F(SegmentSelectorTest, SubsegmentRecording) {
|
||||
.Times(3)
|
||||
.WillRepeatedly(
|
||||
Invoke([&wait_for_subsegment, &actual_calls, &call_count](
|
||||
base::StringPiece trial, SegmentId id, int rank) {
|
||||
std::string_view trial, SegmentId id, int rank) {
|
||||
actual_calls.emplace_back(trial, id, rank);
|
||||
call_count++;
|
||||
if (call_count == 3)
|
||||
@ -598,12 +597,12 @@ TEST_F(SegmentSelectorTest, SubsegmentRecording) {
|
||||
EXPECT_THAT(
|
||||
actual_calls,
|
||||
testing::UnorderedElementsAre(
|
||||
std::make_tuple(base::StringPiece("Segmentation_TestKey_Share"),
|
||||
std::make_tuple(std::string_view("Segmentation_TestKey_Share"),
|
||||
segment_id0, 0),
|
||||
std::make_tuple(
|
||||
base::StringPiece("Segmentation_TestKey_NewTab"),
|
||||
std::string_view("Segmentation_TestKey_NewTab"),
|
||||
proto::SegmentId::OPTIMIZATION_TARGET_SEGMENTATION_NEW_TAB, 0),
|
||||
std::make_tuple(base::StringPiece("Segmentation_TestKey_FeedUser"),
|
||||
std::make_tuple(std::string_view("Segmentation_TestKey_FeedUser"),
|
||||
kSubsegmentEnabledTarget, 3)));
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "components/segmentation_platform/internal/stats.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/metrics/histogram_functions.h"
|
||||
@ -152,7 +154,7 @@ AdaptiveToolbarSegmentSwitch GetAdaptiveToolbarSegmentSwitch(
|
||||
|
||||
// Should map to ModelExecutionStatus variant string in
|
||||
// //tools/metrics/histograms/metadata/segmentation_platform/histograms.xml.
|
||||
std::optional<base::StringPiece> ModelExecutionStatusToHistogramVariant(
|
||||
std::optional<std::string_view> ModelExecutionStatusToHistogramVariant(
|
||||
ModelExecutionStatus status) {
|
||||
switch (status) {
|
||||
case ModelExecutionStatus::kSuccess:
|
||||
@ -411,7 +413,7 @@ void RecordModelExecutionDurationModel(SegmentId segment_id,
|
||||
base::TimeDelta duration) {
|
||||
ModelExecutionStatus status = success ? ModelExecutionStatus::kSuccess
|
||||
: ModelExecutionStatus::kExecutionError;
|
||||
std::optional<base::StringPiece> status_variant =
|
||||
std::optional<std::string_view> status_variant =
|
||||
ModelExecutionStatusToHistogramVariant(status);
|
||||
if (!status_variant)
|
||||
return;
|
||||
@ -425,7 +427,7 @@ void RecordModelExecutionDurationModel(SegmentId segment_id,
|
||||
void RecordModelExecutionDurationTotal(SegmentId segment_id,
|
||||
ModelExecutionStatus status,
|
||||
base::TimeDelta duration) {
|
||||
std::optional<base::StringPiece> status_variant =
|
||||
std::optional<std::string_view> status_variant =
|
||||
ModelExecutionStatusToHistogramVariant(status);
|
||||
if (!status_variant)
|
||||
return;
|
||||
|
@ -3,16 +3,18 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "components/segmentation_platform/public/database_client.h"
|
||||
#include "base/metrics/metrics_hashes.h"
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/metrics/metrics_hashes.h"
|
||||
|
||||
namespace segmentation_platform {
|
||||
|
||||
DatabaseClient::StructuredEvent::StructuredEvent() = default;
|
||||
|
||||
DatabaseClient::StructuredEvent::StructuredEvent(
|
||||
base::StringPiece event_name,
|
||||
std::string_view event_name,
|
||||
const std::map<std::string, uint64_t> values) {
|
||||
event_id = UkmEventHash::FromUnsafeValue(base::HashMetricName(event_name));
|
||||
for (const auto& it : values) {
|
||||
|
@ -7,9 +7,9 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/functional/callback_forward.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/time/time.h"
|
||||
#include "base/types/id_type.h"
|
||||
#include "components/segmentation_platform/public/model_provider.h"
|
||||
@ -48,7 +48,7 @@ class DatabaseClient {
|
||||
// metrics too) have to be registered in `DatabaseApiClients`.
|
||||
struct StructuredEvent {
|
||||
StructuredEvent();
|
||||
StructuredEvent(base::StringPiece event_name,
|
||||
StructuredEvent(std::string_view event_name,
|
||||
const std::map<std::string, uint64_t> values);
|
||||
~StructuredEvent();
|
||||
|
||||
|
@ -5,7 +5,8 @@
|
||||
#ifndef COMPONENTS_SEGMENTATION_PLATFORM_PUBLIC_FIELD_TRIAL_REGISTER_H_
|
||||
#define COMPONENTS_SEGMENTATION_PLATFORM_PUBLIC_FIELD_TRIAL_REGISTER_H_
|
||||
|
||||
#include "base/strings/string_piece.h"
|
||||
#include <string_view>
|
||||
|
||||
#include "components/segmentation_platform/public/proto/segmentation_platform.pb.h"
|
||||
|
||||
namespace segmentation_platform {
|
||||
@ -24,17 +25,16 @@ class FieldTrialRegister {
|
||||
// segmentation groups. Calling multiple times with same `trial_name`
|
||||
// will replace the existing group with the new one, but note that the
|
||||
// previous logs already closed / staged for upload will not be changed.
|
||||
virtual void RegisterFieldTrial(base::StringPiece trial_name,
|
||||
base::StringPiece group_name) = 0;
|
||||
virtual void RegisterFieldTrial(std::string_view trial_name,
|
||||
std::string_view group_name) = 0;
|
||||
|
||||
// Registers subsegments based on the `subsegment_rank` of the segment when
|
||||
// the subsegment mapping was provided by the segment. The `subsegment_rank`
|
||||
// should be computed based on the subsegment discrete mapping in the model
|
||||
// metadata.
|
||||
virtual void RegisterSubsegmentFieldTrialIfNeeded(
|
||||
base::StringPiece trial_name,
|
||||
proto::SegmentId segment_id,
|
||||
int subsegment_rank) = 0;
|
||||
virtual void RegisterSubsegmentFieldTrialIfNeeded(std::string_view trial_name,
|
||||
proto::SegmentId segment_id,
|
||||
int subsegment_rank) = 0;
|
||||
};
|
||||
|
||||
} // namespace segmentation_platform
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "components/segmentation_platform/public/input_context.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/values.h"
|
||||
|
||||
namespace segmentation_platform {
|
||||
@ -13,7 +15,7 @@ InputContext::InputContext() = default;
|
||||
InputContext::~InputContext() = default;
|
||||
|
||||
std::optional<processing::ProcessedValue> InputContext::GetMetadataArgument(
|
||||
base::StringPiece arg_name) const {
|
||||
std::string_view arg_name) const {
|
||||
auto it = metadata_args.find(arg_name);
|
||||
if (it == metadata_args.end()) {
|
||||
return std::nullopt;
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define COMPONENTS_SEGMENTATION_PLATFORM_PUBLIC_INPUT_CONTEXT_H_
|
||||
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/containers/flat_map.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
@ -33,7 +34,7 @@ struct InputContext : base::RefCounted<InputContext> {
|
||||
|
||||
// Returns the arg value from `metadata_args`.
|
||||
std::optional<processing::ProcessedValue> GetMetadataArgument(
|
||||
base::StringPiece arg_name) const;
|
||||
std::string_view arg_name) const;
|
||||
|
||||
base::Value ToDebugValue() const;
|
||||
|
||||
|
@ -3,7 +3,9 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "components/segmentation_platform/public/result.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <string_view>
|
||||
|
||||
namespace segmentation_platform {
|
||||
|
||||
@ -56,7 +58,7 @@ AnnotatedNumericResult& AnnotatedNumericResult::operator=(
|
||||
const AnnotatedNumericResult&) = default;
|
||||
|
||||
std::optional<float> AnnotatedNumericResult::GetResultForLabel(
|
||||
base::StringPiece label) const {
|
||||
std::string_view label) const {
|
||||
if (status != PredictionStatus::kSucceeded ||
|
||||
!result.output_config().predictor().has_generic_predictor()) {
|
||||
return std::nullopt;
|
||||
|
@ -7,10 +7,10 @@
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "base/functional/callback_helpers.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "components/segmentation_platform/public/proto/prediction_result.pb.h"
|
||||
#include "components/segmentation_platform/public/trigger.h"
|
||||
|
||||
@ -64,7 +64,7 @@ struct AnnotatedNumericResult {
|
||||
|
||||
// Returns the result for the given label. Null if the result failed to fetch
|
||||
// or if the label is not available in the output config.
|
||||
std::optional<float> GetResultForLabel(base::StringPiece label) const;
|
||||
std::optional<float> GetResultForLabel(std::string_view label) const;
|
||||
|
||||
// Various error codes such as model failed or insufficient data collection.
|
||||
PredictionStatus status;
|
||||
|
@ -5,8 +5,10 @@
|
||||
#include "components/sessions/core/command_storage_backend.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "base/feature_list.h"
|
||||
@ -333,8 +335,8 @@ SessionFileReader::CreateCommandFromEncrypted(const char* data,
|
||||
memset(nonce, 0, kNonceLength);
|
||||
memcpy(nonce, &command_counter_, sizeof(command_counter_));
|
||||
std::string plain_text;
|
||||
if (!aead_->Open(base::StringPiece(data, length),
|
||||
base::StringPiece(nonce, kNonceLength), base::StringPiece(),
|
||||
if (!aead_->Open(std::string_view(data, length),
|
||||
std::string_view(nonce, kNonceLength), std::string_view(),
|
||||
&plain_text)) {
|
||||
DVLOG(1) << "SessionFileReader::ReadCommand, decryption failed";
|
||||
return nullptr;
|
||||
@ -821,8 +823,8 @@ bool CommandStorageBackend::AppendEncryptedCommandToFile(
|
||||
command_size);
|
||||
|
||||
std::string cipher_text;
|
||||
aead_->Seal(base::StringPiece(&command_and_id.front(), command_and_id.size()),
|
||||
base::StringPiece(nonce, kNonceLength), base::StringPiece(),
|
||||
aead_->Seal(std::string_view(&command_and_id.front(), command_and_id.size()),
|
||||
std::string_view(nonce, kNonceLength), std::string_view(),
|
||||
&cipher_text);
|
||||
DCHECK_LE(cipher_text.size(), std::numeric_limits<size_type>::max());
|
||||
const size_type command_and_id_size =
|
||||
|
@ -9,8 +9,8 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "components/sessions/core/sessions_export.h"
|
||||
|
||||
namespace base {
|
||||
@ -52,8 +52,8 @@ class SESSIONS_EXPORT SessionCommand {
|
||||
// The contents of the command.
|
||||
char* contents() { return const_cast<char*>(contents_.c_str()); }
|
||||
const char* contents() const { return contents_.c_str(); }
|
||||
base::StringPiece contents_as_string_piece() const {
|
||||
return base::StringPiece(contents_);
|
||||
std::string_view contents_as_string_piece() const {
|
||||
return std::string_view(contents_);
|
||||
}
|
||||
// Identifier for the command.
|
||||
id_type id() const { return id_; }
|
||||
|
@ -2,10 +2,11 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
#include "components/shared_highlighting/core/common/disabled_sites.h"
|
||||
|
||||
#include <string_view>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "base/containers/fixed_flat_map.h"
|
||||
#include "base/feature_list.h"
|
||||
#include "base/strings/string_util.h"
|
||||
@ -31,7 +32,7 @@ bool ShouldOfferLinkToText(const GURL& url) {
|
||||
// against the RE stored in the value. For example, {"foo.com", ".*"} means
|
||||
// any page on the foo.com domain.
|
||||
static constexpr auto kBlocklist =
|
||||
base::MakeFixedFlatMap<base::StringPiece, base::StringPiece>(
|
||||
base::MakeFixedFlatMap<std::string_view, std::string_view>(
|
||||
{{"facebook.com", ".*"},
|
||||
// TODO(crbug.com/40736718): special case this to cover other Google
|
||||
// TLDs
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include <optional>
|
||||
#include <sstream>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/json/json_writer.h"
|
||||
#include "base/ranges/algorithm.h"
|
||||
@ -89,7 +90,7 @@ std::vector<std::string> ExtractTextFragments(std::string ref_string) {
|
||||
}
|
||||
|
||||
GURL RemoveFragmentSelectorDirectives(const GURL& url) {
|
||||
const std::vector<base::StringPiece> directive_parameter_names{
|
||||
const std::vector<std::string_view> directive_parameter_names{
|
||||
kTextDirectiveParameterName, kSelectorDirectiveParameterName};
|
||||
size_t start_pos = url.ref().find(kFragmentsUrlDelimiter);
|
||||
if (start_pos == std::string::npos)
|
||||
@ -108,7 +109,7 @@ GURL RemoveFragmentSelectorDirectives(const GURL& url) {
|
||||
base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
|
||||
if (base::ranges::none_of(
|
||||
directive_parameter_names,
|
||||
[&directive](const base::StringPiece& directive_parameter_name) {
|
||||
[&directive](std::string_view directive_parameter_name) {
|
||||
return base::StartsWith(directive, directive_parameter_name);
|
||||
})) {
|
||||
should_keep_directives.push_back(directive);
|
||||
|
@ -6,12 +6,13 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/metrics/histogram_functions.h"
|
||||
#include "base/ranges/algorithm.h"
|
||||
#include "base/strings/escape.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/string_split.h"
|
||||
#include "components/google/core/common/google_util.h"
|
||||
#include "components/signin/core/browser/chrome_connected_header_helper.h"
|
||||
@ -144,7 +145,7 @@ SigninHeaderHelper::ResponseHeaderDictionary
|
||||
SigninHeaderHelper::ParseAccountConsistencyResponseHeader(
|
||||
const std::string& header_value) {
|
||||
ResponseHeaderDictionary dictionary;
|
||||
for (const base::StringPiece& field :
|
||||
for (std::string_view field :
|
||||
base::SplitStringPiece(header_value, ",", base::TRIM_WHITESPACE,
|
||||
base::SPLIT_WANT_NONEMPTY)) {
|
||||
size_t delim = field.find_first_of('=');
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "components/signin/internal/identity_manager/account_capabilities_fetcher.h"
|
||||
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
|
||||
#include "account_capabilities_fetcher.h"
|
||||
#include "base/notreached.h"
|
||||
@ -28,7 +29,7 @@
|
||||
#include "components/signin/internal/identity_manager/account_capabilities_fetcher_android.h"
|
||||
#include "components/signin/public/android/test_support_jni_headers/AccountCapabilitiesFetcherTestUtil_jni.h"
|
||||
#else
|
||||
#include "base/strings/string_piece.h"
|
||||
|
||||
#include "base/strings/string_split.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "components/prefs/testing_pref_service.h"
|
||||
@ -147,10 +148,10 @@ std::string GenerateValidAccountCapabilitiesResponse(bool capability_value) {
|
||||
|
||||
void VerifyAccountCapabilitiesRequest(const network::ResourceRequest& request) {
|
||||
EXPECT_EQ(request.method, "POST");
|
||||
base::StringPiece request_string = request.request_body->elements()
|
||||
->at(0)
|
||||
.As<network::DataElementBytes>()
|
||||
.AsStringPiece();
|
||||
std::string_view request_string = request.request_body->elements()
|
||||
->at(0)
|
||||
.As<network::DataElementBytes>()
|
||||
.AsStringPiece();
|
||||
// The request body should look like:
|
||||
// "names=Name1&names=Name2&names=Name3"
|
||||
std::vector<std::string> requested_capabilities = base::SplitString(
|
||||
|
@ -5,8 +5,10 @@
|
||||
#include "components/signin/internal/identity_manager/account_tracker_service.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/check.h"
|
||||
#include "base/command_line.h"
|
||||
@ -22,7 +24,6 @@
|
||||
#include "base/notreached.h"
|
||||
#include "base/ranges/algorithm.h"
|
||||
#include "base/strings/strcat.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/string_split.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/task/task_traits.h"
|
||||
@ -126,12 +127,12 @@ void RemoveImage(const base::FilePath& image_path) {
|
||||
}
|
||||
|
||||
// Converts the capability service name into a nested Chrome pref path.
|
||||
std::string GetCapabilityPrefPath(base::StringPiece capability_name) {
|
||||
std::string GetCapabilityPrefPath(std::string_view capability_name) {
|
||||
return base::StrCat({"accountcapabilities.", capability_name});
|
||||
}
|
||||
|
||||
void SetAccountCapabilityState(base::Value::Dict& value,
|
||||
base::StringPiece capability_name,
|
||||
std::string_view capability_name,
|
||||
signin::Tribool state) {
|
||||
value.SetByDottedPath(GetCapabilityPrefPath(capability_name),
|
||||
static_cast<int>(state));
|
||||
@ -154,14 +155,14 @@ signin::Tribool ParseTribool(std::optional<int> int_value) {
|
||||
}
|
||||
|
||||
signin::Tribool FindAccountCapabilityState(const base::Value::Dict& dict,
|
||||
base::StringPiece name) {
|
||||
std::string_view name) {
|
||||
std::optional<int> capability =
|
||||
dict.FindIntByDottedPath(GetCapabilityPrefPath(name));
|
||||
return ParseTribool(capability);
|
||||
}
|
||||
|
||||
void GetString(const base::Value::Dict& dict,
|
||||
base::StringPiece key,
|
||||
std::string_view key,
|
||||
std::string& result) {
|
||||
if (const std::string* value = dict.FindString(key)) {
|
||||
result = *value;
|
||||
|
@ -4,13 +4,14 @@
|
||||
|
||||
#include "components/signin/internal/identity_manager/token_binding_helper.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/containers/flat_map.h"
|
||||
#include "base/containers/span.h"
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/functional/callback.h"
|
||||
#include "base/notreached.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "components/signin/public/base/session_binding_utils.h"
|
||||
#include "components/unexportable_keys/background_task_priority.h"
|
||||
#include "components/unexportable_keys/service_error.h"
|
||||
@ -74,7 +75,7 @@ void TokenBindingHelper::ClearAllKeys() {
|
||||
|
||||
void TokenBindingHelper::GenerateBindingKeyAssertion(
|
||||
const CoreAccountId& account_id,
|
||||
base::StringPiece challenge,
|
||||
std::string_view challenge,
|
||||
const GURL& destination_url,
|
||||
base::OnceCallback<void(std::string)> callback) {
|
||||
CHECK(callback);
|
||||
@ -119,7 +120,7 @@ TokenBindingHelper::BindingKeyData::operator=(BindingKeyData&& other) = default;
|
||||
TokenBindingHelper::BindingKeyData::~BindingKeyData() = default;
|
||||
|
||||
void TokenBindingHelper::SignAssertionToken(
|
||||
base::StringPiece challenge,
|
||||
std::string_view challenge,
|
||||
const GURL& destination_url,
|
||||
base::OnceCallback<void(std::string)> callback,
|
||||
unexportable_keys::ServiceErrorOr<unexportable_keys::UnexportableKeyId>
|
||||
|
@ -5,11 +5,12 @@
|
||||
#ifndef COMPONENTS_SIGNIN_INTERNAL_IDENTITY_MANAGER_TOKEN_BINDING_HELPER_H_
|
||||
#define COMPONENTS_SIGNIN_INTERNAL_IDENTITY_MANAGER_TOKEN_BINDING_HELPER_H_
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/containers/flat_map.h"
|
||||
#include "base/containers/span.h"
|
||||
#include "base/functional/callback_forward.h"
|
||||
#include "base/memory/raw_ref.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "components/unexportable_keys/service_error.h"
|
||||
#include "components/unexportable_keys/unexportable_key_id.h"
|
||||
|
||||
@ -59,7 +60,7 @@ class TokenBindingHelper {
|
||||
// string if the generation fails.
|
||||
void GenerateBindingKeyAssertion(
|
||||
const CoreAccountId& account_id,
|
||||
base::StringPiece challenge,
|
||||
std::string_view challenge,
|
||||
const GURL& destination_url,
|
||||
base::OnceCallback<void(std::string)> callback);
|
||||
|
||||
@ -85,7 +86,7 @@ class TokenBindingHelper {
|
||||
};
|
||||
|
||||
void SignAssertionToken(
|
||||
base::StringPiece challenge,
|
||||
std::string_view challenge,
|
||||
const GURL& destination_url,
|
||||
base::OnceCallback<void(std::string)> callback,
|
||||
unexportable_keys::ServiceErrorOr<unexportable_keys::UnexportableKeyId>
|
||||
|
@ -5,13 +5,13 @@
|
||||
#include "components/signin/public/base/session_binding_utils.h"
|
||||
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/base64url.h"
|
||||
#include "base/containers/span.h"
|
||||
#include "base/json/json_writer.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/strings/strcat.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/time/time.h"
|
||||
#include "base/values.h"
|
||||
#include "crypto/sha2.h"
|
||||
@ -40,7 +40,7 @@ std::string SignatureAlgorithmToString(
|
||||
}
|
||||
}
|
||||
|
||||
std::string Base64UrlEncode(base::StringPiece data) {
|
||||
std::string Base64UrlEncode(std::string_view data) {
|
||||
std::string output;
|
||||
base::Base64UrlEncode(data, base::Base64UrlEncodePolicy::OMIT_PADDING,
|
||||
&output);
|
||||
@ -48,7 +48,7 @@ std::string Base64UrlEncode(base::StringPiece data) {
|
||||
}
|
||||
|
||||
std::string Base64UrlEncode(base::span<const uint8_t> data) {
|
||||
return Base64UrlEncode(base::StringPiece(
|
||||
return Base64UrlEncode(std::string_view(
|
||||
reinterpret_cast<const char*>(data.data()), data.size()));
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ base::Value::Dict CreatePublicKeyInfo(base::span<const uint8_t> pubkey) {
|
||||
|
||||
std::optional<std::string> CreateHeaderAndPayloadWithCustomPayload(
|
||||
crypto::SignatureVerifier::SignatureAlgorithm algorithm,
|
||||
base::StringPiece schema,
|
||||
std::string_view schema,
|
||||
const base::Value::Dict& payload) {
|
||||
auto header = base::Value::Dict()
|
||||
.Set("alg", SignatureAlgorithmToString(algorithm))
|
||||
@ -116,8 +116,8 @@ std::optional<std::vector<uint8_t>> ConvertDERSignatureToRaw(
|
||||
} // namespace
|
||||
|
||||
std::optional<std::string> CreateKeyRegistrationHeaderAndPayloadForTokenBinding(
|
||||
base::StringPiece client_id,
|
||||
base::StringPiece auth_code,
|
||||
std::string_view client_id,
|
||||
std::string_view auth_code,
|
||||
const GURL& registration_url,
|
||||
crypto::SignatureVerifier::SignatureAlgorithm algorithm,
|
||||
base::span<const uint8_t> pubkey,
|
||||
@ -139,7 +139,7 @@ std::optional<std::string> CreateKeyRegistrationHeaderAndPayloadForTokenBinding(
|
||||
|
||||
std::optional<std::string>
|
||||
CreateKeyRegistrationHeaderAndPayloadForSessionBinding(
|
||||
base::StringPiece challenge,
|
||||
std::string_view challenge,
|
||||
const GURL& registration_url,
|
||||
crypto::SignatureVerifier::SignatureAlgorithm algorithm,
|
||||
base::span<const uint8_t> pubkey,
|
||||
@ -161,10 +161,10 @@ CreateKeyRegistrationHeaderAndPayloadForSessionBinding(
|
||||
std::optional<std::string> CreateKeyAssertionHeaderAndPayload(
|
||||
crypto::SignatureVerifier::SignatureAlgorithm algorithm,
|
||||
base::span<const uint8_t> pubkey,
|
||||
base::StringPiece client_id,
|
||||
base::StringPiece challenge,
|
||||
std::string_view client_id,
|
||||
std::string_view challenge,
|
||||
const GURL& destination_url,
|
||||
base::StringPiece name_space) {
|
||||
std::string_view name_space) {
|
||||
auto payload = base::Value::Dict()
|
||||
.Set("sub", client_id)
|
||||
.Set("aud", destination_url.spec())
|
||||
@ -176,7 +176,7 @@ std::optional<std::string> CreateKeyAssertionHeaderAndPayload(
|
||||
}
|
||||
|
||||
std::optional<std::string> AppendSignatureToHeaderAndPayload(
|
||||
base::StringPiece header_and_payload,
|
||||
std::string_view header_and_payload,
|
||||
crypto::SignatureVerifier::SignatureAlgorithm algorithm,
|
||||
base::span<const uint8_t> signature) {
|
||||
std::optional<std::vector<uint8_t>> signature_holder;
|
||||
|
@ -7,9 +7,9 @@
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/containers/span.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "crypto/signature_verifier.h"
|
||||
|
||||
class GURL;
|
||||
@ -22,15 +22,15 @@ namespace signin {
|
||||
|
||||
// Creates header and payload parts of a registration JWT.
|
||||
std::optional<std::string> CreateKeyRegistrationHeaderAndPayloadForTokenBinding(
|
||||
base::StringPiece client_id,
|
||||
base::StringPiece auth_code,
|
||||
std::string_view client_id,
|
||||
std::string_view auth_code,
|
||||
const GURL& registration_url,
|
||||
crypto::SignatureVerifier::SignatureAlgorithm algorithm,
|
||||
base::span<const uint8_t> pubkey,
|
||||
base::Time timestamp);
|
||||
std::optional<std::string>
|
||||
CreateKeyRegistrationHeaderAndPayloadForSessionBinding(
|
||||
base::StringPiece challenge,
|
||||
std::string_view challenge,
|
||||
const GURL& registration_url,
|
||||
crypto::SignatureVerifier::SignatureAlgorithm algorithm,
|
||||
base::span<const uint8_t> pubkey,
|
||||
@ -41,15 +41,15 @@ CreateKeyRegistrationHeaderAndPayloadForSessionBinding(
|
||||
std::optional<std::string> CreateKeyAssertionHeaderAndPayload(
|
||||
crypto::SignatureVerifier::SignatureAlgorithm algorithm,
|
||||
base::span<const uint8_t> pubkey,
|
||||
base::StringPiece client_id,
|
||||
base::StringPiece challenge,
|
||||
std::string_view client_id,
|
||||
std::string_view challenge,
|
||||
const GURL& destination_url,
|
||||
base::StringPiece name_space);
|
||||
std::string_view name_space);
|
||||
|
||||
// Appends `signature` generated by `algorithm` to provided `header_and_payload`
|
||||
// to form a complete JWT.
|
||||
std::optional<std::string> AppendSignatureToHeaderAndPayload(
|
||||
base::StringPiece header_and_payload,
|
||||
std::string_view header_and_payload,
|
||||
crypto::SignatureVerifier::SignatureAlgorithm algorithm,
|
||||
base::span<const uint8_t> signature);
|
||||
|
||||
|
@ -5,12 +5,12 @@
|
||||
#include "components/signin/public/base/session_binding_utils.h"
|
||||
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/base64url.h"
|
||||
#include "base/json/json_reader.h"
|
||||
#include "base/json/json_writer.h"
|
||||
#include "base/strings/strcat.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/string_split.h"
|
||||
#include "base/time/time.h"
|
||||
#include "base/value_iterators.h"
|
||||
@ -23,7 +23,7 @@ namespace signin {
|
||||
|
||||
namespace {
|
||||
|
||||
base::Value Base64UrlEncodedJsonToValue(base::StringPiece input) {
|
||||
base::Value Base64UrlEncodedJsonToValue(std::string_view input) {
|
||||
std::string json;
|
||||
EXPECT_TRUE(base::Base64UrlDecode(
|
||||
input, base::Base64UrlDecodePolicy::DISALLOW_PADDING, &json));
|
||||
@ -45,7 +45,7 @@ TEST(SessionBindingUtilsTest,
|
||||
base::Time::UnixEpoch() + base::Days(200) + base::Milliseconds(123));
|
||||
ASSERT_TRUE(result.has_value());
|
||||
|
||||
std::vector<base::StringPiece> header_and_payload = base::SplitStringPiece(
|
||||
std::vector<std::string_view> header_and_payload = base::SplitStringPiece(
|
||||
*result, ".", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
|
||||
ASSERT_EQ(header_and_payload.size(), 2U);
|
||||
base::Value actual_header =
|
||||
@ -82,7 +82,7 @@ TEST(SessionBindingUtilsTest,
|
||||
base::Time::UnixEpoch() + base::Days(200) + base::Milliseconds(123));
|
||||
ASSERT_TRUE(result.has_value());
|
||||
|
||||
std::vector<base::StringPiece> header_and_payload = base::SplitStringPiece(
|
||||
std::vector<std::string_view> header_and_payload = base::SplitStringPiece(
|
||||
*result, ".", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
|
||||
ASSERT_EQ(header_and_payload.size(), 2U);
|
||||
base::Value actual_header =
|
||||
@ -114,7 +114,7 @@ TEST(SessionBindingUtilsTest, CreateKeyAssertionHeaderAndPayload) {
|
||||
GURL("https://accounts.google.com/VerifyKey"), "test_namespace");
|
||||
ASSERT_TRUE(result.has_value());
|
||||
|
||||
std::vector<base::StringPiece> header_and_payload = base::SplitStringPiece(
|
||||
std::vector<std::string_view> header_and_payload = base::SplitStringPiece(
|
||||
*result, ".", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
|
||||
ASSERT_EQ(header_and_payload.size(), 2U);
|
||||
base::Value actual_header =
|
||||
@ -157,7 +157,7 @@ TEST(SessionBindingUtilsTest,
|
||||
0x02, 0x21, 0x00, 0xbc, 0xb5, 0xee, 0x42, 0xe2, 0x5a, 0x87, 0xae, 0x21,
|
||||
0x18, 0xda, 0x7e, 0x68, 0x65, 0x30, 0xbe, 0xe5, 0x69, 0x3d, 0xc5, 0x5f,
|
||||
0xd5, 0x62, 0x45, 0x3e, 0x8d, 0x0b, 0x05, 0x1a, 0x33, 0x79, 0x8d};
|
||||
constexpr base::StringPiece kRawSignatureBase64UrlEncoded =
|
||||
constexpr std::string_view kRawSignatureBase64UrlEncoded =
|
||||
"dKBvaysOgg4DO26Y_Imc8zC1VtMpibWCM1-dl_tlZJC8te5C4lqHriEY2n5oZTC-5Wk9xV_"
|
||||
"VYkU-jQsFGjN5jQ";
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@ -457,7 +458,7 @@ void IdentityTestEnvironment::ClearPrimaryAccount() {
|
||||
}
|
||||
|
||||
AccountInfo IdentityTestEnvironment::MakeAccountAvailable(
|
||||
base::StringPiece email,
|
||||
std::string_view email,
|
||||
SimpleAccountAvailabilityOptions options) {
|
||||
auto builder = CreateAccountAvailabilityOptionsBuilder();
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "base/functional/callback.h"
|
||||
@ -64,7 +65,7 @@ struct SimpleAccountAvailabilityOptions {
|
||||
bool set_cookie = false;
|
||||
|
||||
// If non-empty, the Gaia ID to use when adding the account.
|
||||
base::StringPiece gaia_id;
|
||||
std::string_view gaia_id;
|
||||
};
|
||||
|
||||
// Class that creates an IdentityManager for use in testing contexts and
|
||||
@ -199,7 +200,7 @@ class IdentityTestEnvironment : public IdentityManager::DiagnosticsObserver,
|
||||
// configuration options and requires obtaining a builder to construct the
|
||||
// options object. See `CreateAccountAvailabilityOptionsBuilder()`.
|
||||
AccountInfo MakeAccountAvailable(
|
||||
base::StringPiece email,
|
||||
std::string_view email,
|
||||
SimpleAccountAvailabilityOptions options = {});
|
||||
|
||||
AccountInfo MakeAccountAvailable(const AccountAvailabilityOptions& options);
|
||||
|
@ -5,11 +5,11 @@
|
||||
#include "components/signin/public/identity_manager/identity_test_utils.h"
|
||||
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "base/run_loop.h"
|
||||
#include "base/strings/strcat.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/uuid.h"
|
||||
#include "build/build_config.h"
|
||||
#include "build/chromeos_buildflags.h"
|
||||
@ -130,14 +130,14 @@ void CompareErrorStatusAndCallClosure(
|
||||
|
||||
// --- AccountAvailabilityOptions ----------------------------------------------
|
||||
|
||||
AccountAvailabilityOptions::AccountAvailabilityOptions(base::StringPiece email)
|
||||
AccountAvailabilityOptions::AccountAvailabilityOptions(std::string_view email)
|
||||
: email(email) {
|
||||
CHECK(!email.empty());
|
||||
}
|
||||
|
||||
AccountAvailabilityOptions::AccountAvailabilityOptions(
|
||||
base::StringPiece email,
|
||||
base::StringPiece gaia_id,
|
||||
std::string_view email,
|
||||
std::string_view gaia_id,
|
||||
std::optional<ConsentLevel> consent_level,
|
||||
std::optional<std::string> refresh_token,
|
||||
raw_ptr<network::TestURLLoaderFactory> url_loader_factory_for_cookies,
|
||||
@ -181,7 +181,7 @@ AccountAvailabilityOptionsBuilder& AccountAvailabilityOptionsBuilder::AsPrimary(
|
||||
}
|
||||
|
||||
AccountAvailabilityOptionsBuilder&
|
||||
AccountAvailabilityOptionsBuilder::WithGaiaId(base::StringPiece gaia_id) {
|
||||
AccountAvailabilityOptionsBuilder::WithGaiaId(std::string_view gaia_id) {
|
||||
CHECK(!gaia_id.empty());
|
||||
gaia_id_ = gaia_id;
|
||||
return *this;
|
||||
@ -197,7 +197,7 @@ AccountAvailabilityOptionsBuilder::WithCookie(bool with_cookie) {
|
||||
|
||||
AccountAvailabilityOptionsBuilder&
|
||||
AccountAvailabilityOptionsBuilder::WithRefreshToken(
|
||||
base::StringPiece refresh_token) {
|
||||
std::string_view refresh_token) {
|
||||
refresh_token_ = refresh_token;
|
||||
return *this;
|
||||
}
|
||||
@ -216,7 +216,7 @@ AccountAvailabilityOptionsBuilder::WithAccessPoint(
|
||||
}
|
||||
|
||||
AccountAvailabilityOptions AccountAvailabilityOptionsBuilder::Build(
|
||||
base::StringPiece email) {
|
||||
std::string_view email) {
|
||||
return AccountAvailabilityOptions(
|
||||
email, gaia_id_, primary_account_consent_level_, refresh_token_,
|
||||
with_cookie_ ? url_loader_factory_for_cookies_ : nullptr, access_point_);
|
||||
@ -562,7 +562,7 @@ void SetCookieAccounts(
|
||||
}
|
||||
|
||||
AccountInfo WithGeneratedUserInfo(const AccountInfo& base_account_info,
|
||||
base::StringPiece given_name) {
|
||||
std::string_view given_name) {
|
||||
CHECK(!given_name.empty())
|
||||
<< "A given name is needed to generate the Gaia info.";
|
||||
|
||||
|
@ -7,9 +7,9 @@
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/functional/callback_forward.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "build/build_config.h"
|
||||
#include "components/signin/public/base/consent_level.h"
|
||||
@ -169,7 +169,7 @@ struct AccountAvailabilityOptions {
|
||||
const signin_metrics::AccessPoint access_point =
|
||||
signin_metrics::AccessPoint::ACCESS_POINT_SETTINGS;
|
||||
|
||||
explicit AccountAvailabilityOptions(base::StringPiece email);
|
||||
explicit AccountAvailabilityOptions(std::string_view email);
|
||||
~AccountAvailabilityOptions();
|
||||
|
||||
private:
|
||||
@ -177,8 +177,8 @@ struct AccountAvailabilityOptions {
|
||||
|
||||
// For complex options, prefer using `AccountAvailabilityOptionsBuilder`.
|
||||
AccountAvailabilityOptions(
|
||||
base::StringPiece email,
|
||||
base::StringPiece gaia_id,
|
||||
std::string_view email,
|
||||
std::string_view gaia_id,
|
||||
std::optional<ConsentLevel> consent_level,
|
||||
std::optional<std::string> refresh_token,
|
||||
raw_ptr<network::TestURLLoaderFactory> url_loader_factory_for_cookies,
|
||||
@ -207,7 +207,7 @@ class AccountAvailabilityOptionsBuilder {
|
||||
AccountAvailabilityOptionsBuilder& AsPrimary(ConsentLevel);
|
||||
|
||||
// Provide a custom `gaia_id` to use for the new account.
|
||||
AccountAvailabilityOptionsBuilder& WithGaiaId(base::StringPiece gaia_id);
|
||||
AccountAvailabilityOptionsBuilder& WithGaiaId(std::string_view gaia_id);
|
||||
|
||||
// Whether to add the new account to the Gaia cookie. See
|
||||
// `signin::AddCookieAccount()` for more context.
|
||||
@ -219,7 +219,7 @@ class AccountAvailabilityOptionsBuilder {
|
||||
// NOTE: by default, the builder will auto-generate a refresh token. Call
|
||||
// `WithoutRefreshToken()` to avoid it.
|
||||
AccountAvailabilityOptionsBuilder& WithRefreshToken(
|
||||
base::StringPiece refresh_token);
|
||||
std::string_view refresh_token);
|
||||
|
||||
// Request that we should not attempt to set a refresh token for the account.
|
||||
AccountAvailabilityOptionsBuilder& WithoutRefreshToken();
|
||||
@ -227,7 +227,7 @@ class AccountAvailabilityOptionsBuilder {
|
||||
AccountAvailabilityOptionsBuilder& WithAccessPoint(
|
||||
signin_metrics::AccessPoint access_point);
|
||||
|
||||
AccountAvailabilityOptions Build(base::StringPiece email);
|
||||
AccountAvailabilityOptions Build(std::string_view email);
|
||||
|
||||
private:
|
||||
raw_ptr<network::TestURLLoaderFactory> url_loader_factory_for_cookies_ =
|
||||
@ -329,7 +329,7 @@ std::string GetTestGaiaIdForEmail(const std::string& email);
|
||||
//
|
||||
// The returned account info will be valid per `AccountInfo::IsValid()`.
|
||||
AccountInfo WithGeneratedUserInfo(const AccountInfo& base_account_info,
|
||||
base::StringPiece given_name);
|
||||
std::string_view given_name);
|
||||
|
||||
// Updates the persistent auth error set on |account_id| which must be a known
|
||||
// account, i.e., an account with a refresh token.
|
||||
|
@ -5,9 +5,9 @@
|
||||
#include "components/signin/public/identity_manager/identity_utils.h"
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
@ -20,8 +20,8 @@ namespace signin {
|
||||
|
||||
namespace {
|
||||
|
||||
bool IsUsernameAllowedByPattern(base::StringPiece username,
|
||||
base::StringPiece pattern) {
|
||||
bool IsUsernameAllowedByPattern(std::string_view username,
|
||||
std::string_view pattern) {
|
||||
if (pattern.empty())
|
||||
return true;
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "base/check_op.h"
|
||||
@ -88,7 +89,7 @@ void ChunkedByteBuffer::Append(const uint8_t* start, size_t length) {
|
||||
total_bytes_stored_ += length;
|
||||
}
|
||||
|
||||
void ChunkedByteBuffer::Append(base::StringPiece string) {
|
||||
void ChunkedByteBuffer::Append(std::string_view string) {
|
||||
Append(reinterpret_cast<const uint8_t*>(string.data()), string.size());
|
||||
}
|
||||
|
||||
|
@ -9,10 +9,9 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "base/strings/string_piece.h"
|
||||
|
||||
namespace speech {
|
||||
|
||||
// Models a chunk-oriented byte buffer. The term chunk is herein defined as an
|
||||
@ -38,7 +37,7 @@ class ChunkedByteBuffer {
|
||||
void Append(const uint8_t* start, size_t length);
|
||||
|
||||
// Appends bytes contained in the |string| to the buffer.
|
||||
void Append(base::StringPiece string);
|
||||
void Append(std::string_view string);
|
||||
|
||||
// Checks whether one or more complete chunks are available in the buffer.
|
||||
bool HasChunks() const;
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "components/speech/downstream_loader.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/functional/callback.h"
|
||||
#include "components/speech/downstream_loader_client.h"
|
||||
#include "services/network/public/mojom/url_response_head.mojom.h"
|
||||
@ -24,7 +26,7 @@ DownstreamLoader::DownstreamLoader(
|
||||
|
||||
DownstreamLoader::~DownstreamLoader() = default;
|
||||
|
||||
void DownstreamLoader::OnDataReceived(base::StringPiece string_piece,
|
||||
void DownstreamLoader::OnDataReceived(std::string_view string_piece,
|
||||
base::OnceClosure resume) {
|
||||
downstream_loader_client_->OnDownstreamDataReceived(string_piece);
|
||||
std::move(resume).Run();
|
||||
|
@ -6,10 +6,10 @@
|
||||
#define COMPONENTS_SPEECH_DOWNSTREAM_LOADER_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/functional/callback_forward.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "services/network/public/cpp/resource_request.h"
|
||||
#include "services/network/public/cpp/simple_url_loader.h"
|
||||
#include "services/network/public/cpp/simple_url_loader_stream_consumer.h"
|
||||
@ -30,7 +30,7 @@ class DownstreamLoader : public network::SimpleURLLoaderStreamConsumer {
|
||||
~DownstreamLoader() override;
|
||||
|
||||
// SimpleURLLoaderStreamConsumer implementation:
|
||||
void OnDataReceived(base::StringPiece string_piece,
|
||||
void OnDataReceived(std::string_view string_piece,
|
||||
base::OnceClosure resume) override;
|
||||
void OnComplete(bool success) override;
|
||||
void OnRetry(base::OnceClosure start_retry) override;
|
||||
|
@ -5,8 +5,6 @@
|
||||
#ifndef COMPONENTS_SPEECH_DOWNSTREAM_LOADER_CLIENT_H_
|
||||
#define COMPONENTS_SPEECH_DOWNSTREAM_LOADER_CLIENT_H_
|
||||
|
||||
#include "base/strings/string_piece.h"
|
||||
|
||||
namespace speech {
|
||||
|
||||
// An interface containing the callback functions required by consumers
|
||||
@ -25,8 +23,7 @@ class DownstreamLoaderClient {
|
||||
friend class DownstreamLoader;
|
||||
|
||||
// Executed when downstream data is received.
|
||||
virtual void OnDownstreamDataReceived(
|
||||
base::StringPiece new_response_data) = 0;
|
||||
virtual void OnDownstreamDataReceived(std::string_view new_response_data) = 0;
|
||||
|
||||
// Executed when downstream data is completed.
|
||||
// success: True on 2xx responses where the entire body was successfully
|
||||
|
Reference in New Issue
Block a user