use c++20 starts_/ends_-with //blink
Bug: 40256235 Change-Id: If297502ad749bd92360116c3bde90051d81176d0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5982559 Reviewed-by: danakj <danakj@chromium.org> Commit-Queue: Helmut Januschka <helmut@januschka.com> Reviewed-by: Chris Harrelson <chrishtr@chromium.org> Cr-Commit-Position: refs/heads/main@{#1378592}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
f61b382e28
commit
731c62b266
content/web_test/renderer
third_party/blink
common
interest_group
manifest
mime_util
service_worker
unique_name
renderer
modules
breakout_box
platform
image-decoders
media
network
scheduler
main_thread
@ -65,7 +65,7 @@ base::FilePath GetExternalWPTFilePath() {
|
||||
//
|
||||
// Note that this doesn't apply when the WPT tests are run by the python script.
|
||||
WebURL RewriteWPTAbsolutePath(std::string_view utf8_url) {
|
||||
if (!base::StartsWith(utf8_url, kFileScheme, base::CompareCase::SENSITIVE) ||
|
||||
if (!utf8_url.starts_with(kFileScheme) ||
|
||||
utf8_url.find("/web_tests/") != std::string::npos) {
|
||||
return WebURL(GURL(utf8_url));
|
||||
}
|
||||
@ -134,7 +134,7 @@ WebURL RewriteWebTestsURL(std::string_view utf8_url, bool is_wpt_mode) {
|
||||
static constexpr std::string_view kGenPrefix = "file:///gen/";
|
||||
|
||||
// Map "file:///gen/" to "file://<build directory>/gen/".
|
||||
if (base::StartsWith(utf8_url, kGenPrefix, base::CompareCase::SENSITIVE)) {
|
||||
if (utf8_url.starts_with(kGenPrefix)) {
|
||||
base::FilePath gen_directory_path =
|
||||
GetBuildDirectory().Append(FILE_PATH_LITERAL("gen/"));
|
||||
std::string new_url("file://");
|
||||
@ -145,8 +145,9 @@ WebURL RewriteWebTestsURL(std::string_view utf8_url, bool is_wpt_mode) {
|
||||
|
||||
static constexpr std::string_view kPrefix = "file:///tmp/web_tests/";
|
||||
|
||||
if (!base::StartsWith(utf8_url, kPrefix, base::CompareCase::SENSITIVE))
|
||||
if (!utf8_url.starts_with(kPrefix)) {
|
||||
return WebURL(GURL(utf8_url));
|
||||
}
|
||||
|
||||
std::string new_url("file://");
|
||||
new_url.append(GetWebTestsFilePath().AsUTF8Unsafe());
|
||||
|
@ -32,7 +32,7 @@ namespace {
|
||||
bool AreBuyerPrioritySignalsValid(
|
||||
const base::flat_map<std::string, double>& buyer_priority_signals) {
|
||||
for (const auto& priority_signal : buyer_priority_signals) {
|
||||
if (base::StartsWith(priority_signal.first, "browserSignals.")) {
|
||||
if (priority_signal.first.starts_with("browserSignals.")) {
|
||||
return false;
|
||||
}
|
||||
if (!std::isfinite(priority_signal.second)) {
|
||||
|
@ -48,8 +48,7 @@ BLINK_COMMON_EXPORT GURL ManifestIconSelector::FindBestMatchingIcon(
|
||||
std::string type = base::UTF16ToUTF8(icon.type);
|
||||
if (!(blink::IsSupportedImageMimeType(base::UTF16ToUTF8(icon.type)) ||
|
||||
// The following condition is intended to support image/svg+xml:
|
||||
(base::StartsWith(base::UTF16ToUTF8(icon.type), "image/",
|
||||
base::CompareCase::SENSITIVE) &&
|
||||
(base::UTF16ToUTF8(icon.type).starts_with("image/") &&
|
||||
blink::IsSupportedNonImageMimeType(
|
||||
base::UTF16ToUTF8(icon.type))))) {
|
||||
continue;
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include <string_view>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
@ -128,9 +129,9 @@ bool IsSupportedNonImageMimeType(std::string_view mime_type) {
|
||||
#if !BUILDFLAG(IS_IOS)
|
||||
media::IsSupportedMediaMimeType(mime_lower) ||
|
||||
#endif
|
||||
(base::StartsWith(mime_lower, "text/") &&
|
||||
(mime_lower.starts_with("text/") &&
|
||||
!kUnsupportedTextTypes.contains(mime_lower)) ||
|
||||
(base::StartsWith(mime_lower, "application/") &&
|
||||
(mime_lower.starts_with("application/") &&
|
||||
net::MatchesMimeType("application/*+json", mime_lower));
|
||||
}
|
||||
|
||||
|
@ -46,8 +46,7 @@ bool ServiceWorkerScopeOrScriptUrlContainsDisallowedCharacter(
|
||||
|
||||
bool ServiceWorkerScopeMatches(const GURL& scope, const GURL& url) {
|
||||
DCHECK(!scope.has_ref());
|
||||
return base::StartsWith(url.spec(), scope.spec(),
|
||||
base::CompareCase::SENSITIVE);
|
||||
return url.spec().starts_with(scope.spec());
|
||||
}
|
||||
|
||||
ServiceWorkerLongestScopeMatcher::ServiceWorkerLongestScopeMatcher(
|
||||
|
@ -69,8 +69,7 @@ constexpr char kDynamicFrameMarker[] = "<!--dynamicFrame";
|
||||
constexpr size_t kMaxRequestedNameSize = 80;
|
||||
|
||||
bool IsNameWithFramePath(std::string_view name) {
|
||||
return base::StartsWith(name, kFramePathPrefix) &&
|
||||
base::EndsWith(name, "-->") &&
|
||||
return name.starts_with(kFramePathPrefix) && name.ends_with("-->") &&
|
||||
(kFramePathPrefixLength + kFramePathSuffixLength) < name.size();
|
||||
}
|
||||
|
||||
|
6
third_party/blink/renderer/modules/breakout_box/media_stream_video_track_underlying_source.cc
vendored
6
third_party/blink/renderer/modules/breakout_box/media_stream_video_track_underlying_source.cc
vendored
@ -24,10 +24,8 @@ constexpr char kScreenPrefix[] = "screen:";
|
||||
constexpr char kWindowPrefix[] = "window:";
|
||||
|
||||
bool IsScreenOrWindowCapture(const std::string& device_id) {
|
||||
return base::StartsWith(device_id, kScreenPrefix,
|
||||
base::CompareCase::SENSITIVE) ||
|
||||
base::StartsWith(device_id, kWindowPrefix,
|
||||
base::CompareCase::SENSITIVE);
|
||||
return device_id.starts_with(kScreenPrefix) ||
|
||||
device_id.starts_with(kWindowPrefix);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "third_party/blink/renderer/platform/image-decoders/skia/segment_stream.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "base/memory/scoped_refptr.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "third_party/blink/renderer/platform/image-decoders/segment_reader.h"
|
||||
|
@ -66,7 +66,7 @@ uint32_t GetReasonsForUncacheability(const WebURLResponse& response) {
|
||||
|
||||
const char kMaxAgePrefix[] = "max-age=";
|
||||
const size_t kMaxAgePrefixLen = std::size(kMaxAgePrefix) - 1;
|
||||
if (cache_control_header.substr(0, kMaxAgePrefixLen) == kMaxAgePrefix) {
|
||||
if (cache_control_header.starts_with(kMaxAgePrefix)) {
|
||||
int64_t max_age_seconds;
|
||||
base::StringToInt64(
|
||||
base::MakeStringPiece(cache_control_header.begin() + kMaxAgePrefixLen,
|
||||
@ -104,7 +104,7 @@ base::TimeDelta GetCacheValidUntil(const WebURLResponse& response) {
|
||||
|
||||
const char kMaxAgePrefix[] = "max-age=";
|
||||
const size_t kMaxAgePrefixLen = std::size(kMaxAgePrefix) - 1;
|
||||
if (cache_control_header.substr(0, kMaxAgePrefixLen) == kMaxAgePrefix) {
|
||||
if (cache_control_header.starts_with(kMaxAgePrefix)) {
|
||||
int64_t max_age_seconds;
|
||||
base::StringToInt64(
|
||||
base::MakeStringPiece(cache_control_header.begin() + kMaxAgePrefixLen,
|
||||
|
@ -493,8 +493,7 @@ bool ResourceMultiBufferDataProvider::ParseContentRange(
|
||||
int64_t* last_byte_position,
|
||||
int64_t* instance_size) {
|
||||
const char kUpThroughBytesUnit[] = "bytes ";
|
||||
if (!base::StartsWith(content_range_str, kUpThroughBytesUnit,
|
||||
base::CompareCase::SENSITIVE)) {
|
||||
if (!content_range_str.starts_with(kUpThroughBytesUnit)) {
|
||||
return false;
|
||||
}
|
||||
std::string range_spec =
|
||||
|
@ -106,8 +106,7 @@ bool MIMETypeRegistry::IsSupportedImagePrefixedMIMEType(
|
||||
const String& mime_type) {
|
||||
std::string ascii_mime_type = ToLowerASCIIOrEmpty(mime_type);
|
||||
return (blink::IsSupportedImageMimeType(ascii_mime_type) ||
|
||||
(base::StartsWith(ascii_mime_type, "image/",
|
||||
base::CompareCase::SENSITIVE) &&
|
||||
(ascii_mime_type.starts_with("image/") &&
|
||||
blink::IsSupportedNonImageMimeType(ascii_mime_type)));
|
||||
}
|
||||
|
||||
|
8
third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_impl_unittest.cc
vendored
8
third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_impl_unittest.cc
vendored
@ -852,13 +852,13 @@ class MainThreadSchedulerImplTest : public testing::Test {
|
||||
String::FromUTF8(task)));
|
||||
break;
|
||||
case 'C':
|
||||
if (base::StartsWith(task, "CM")) {
|
||||
if (task.starts_with("CM")) {
|
||||
compositor_task_runner_->PostTask(
|
||||
FROM_HERE, base::BindOnce(&MainThreadSchedulerImplTest::
|
||||
AppendToVectorBeginMainFrameTask,
|
||||
base::Unretained(this), run_order,
|
||||
String::FromUTF8(task)));
|
||||
} else if (base::StartsWith(task, "CI")) {
|
||||
} else if (task.starts_with("CI")) {
|
||||
compositor_task_runner_->PostTask(
|
||||
FROM_HERE,
|
||||
base::BindOnce(&MainThreadSchedulerImplTest::
|
||||
@ -872,7 +872,7 @@ class MainThreadSchedulerImplTest : public testing::Test {
|
||||
}
|
||||
break;
|
||||
case 'P':
|
||||
if (base::StartsWith(task, "PC")) {
|
||||
if (task.starts_with("PC")) {
|
||||
input_task_runner_->PostTask(
|
||||
FROM_HERE,
|
||||
base::BindOnce(
|
||||
@ -880,7 +880,7 @@ class MainThreadSchedulerImplTest : public testing::Test {
|
||||
base::Unretained(this), WebInputEvent::Type::kMouseMove,
|
||||
run_order, String::FromUTF8(task)));
|
||||
|
||||
} else if (base::StartsWith(task, "PD")) {
|
||||
} else if (task.starts_with("PD")) {
|
||||
input_task_runner_->PostTask(
|
||||
FROM_HERE,
|
||||
base::BindOnce(
|
||||
|
Reference in New Issue
Block a user