0

use base::ToString() where possible //content

Bug: 335797528
Change-Id: I50b5d409bbed663acb5526f714bc5c82ef89da9e
AX-Relnotes: n/a.
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6304962
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1426762}
This commit is contained in:
Helmut Januschka
2025-03-01 17:13:12 -08:00
committed by Chromium LUCI CQ
parent e7ae1aab5f
commit 42c8320787
27 changed files with 110 additions and 90 deletions

@ -12,6 +12,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/to_string.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "ui/accessibility/ax_enums.mojom.h"
@ -755,7 +756,7 @@ std::string AccessibilityTreeFormatterBlink::ProcessTreeForOutput(
}
WriteAttribute(false,
base::StringPrintf("%s=%s", ui::ToString(attr),
*bool_value ? "true" : "false"),
base::ToString(*bool_value)),
&line);
}

@ -19,6 +19,7 @@
#include "base/numerics/safe_conversions.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/to_string.h"
#include "base/strings/utf_string_conversions.h"
#include "content/common/android/gin_java_bridge_value.h"
@ -215,7 +216,7 @@ jvalue CoerceJavaScriptBooleanToJavaValue(JNIEnv* env,
break;
case JavaType::TypeString:
result.l = coerce_to_string ? ConvertUTF8ToJavaString(
env, boolean_value ? "true" : "false")
env, base::ToString(boolean_value))
.Release()
: nullptr;
break;

@ -26,6 +26,7 @@
#include "base/strings/strcat.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/to_string.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/bind.h"
#include "base/test/gmock_expected_support.h"
@ -1943,9 +1944,9 @@ class RedirectHeuristicGrantTest
std::string grant_time_string =
GetParam().write_redirect_grants ? "60s" : "0s";
std::string require_aba_flow_string =
GetParam().require_aba_flow ? "true" : "false";
base::ToString(GetParam().require_aba_flow);
std::string require_current_interaction_string =
GetParam().require_current_interaction ? "true" : "false";
base::ToString(GetParam().require_current_interaction);
enabled_features_.push_back(
{content_settings::features::kTpcdHeuristicsGrants,

@ -5,6 +5,7 @@
#include "content/browser/btm/btm_navigation_flow_detector.h"
#include "base/base64.h"
#include "base/strings/to_string.h"
#include "base/test/bind.h"
#include "base/test/gmock_expected_support.h"
#include "base/test/scoped_feature_list.h"
@ -58,14 +59,14 @@ std::vector<url::Origin> GetOrigins(const AttributionData& data) {
return origins;
}
const char* StringifyBooleanMetric(ukm::TestAutoSetUkmRecorder* ukm_recorder,
std::string StringifyBooleanMetric(ukm::TestAutoSetUkmRecorder* ukm_recorder,
const ukm::mojom::UkmEntry* entry,
std::string metric_name) {
const std::int64_t* metric = ukm_recorder->GetEntryMetric(entry, metric_name);
if (metric == nullptr) {
return "null";
}
return *metric ? "true" : "false";
return base::ToString(*metric);
}
const std::string StringifyNumericMetric(

@ -31,6 +31,7 @@
#include "base/notreached.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/to_string.h"
#include "base/synchronization/lock.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/bind.h"
@ -207,7 +208,7 @@ function reportResult(auctionConfig, browserSignals) {
};
}
)",
send_report ? "true" : "false", kOriginStringA,
base::ToString(send_report), kOriginStringA,
kOriginStringA);
}

@ -32,6 +32,7 @@
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/to_string.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
@ -734,9 +735,9 @@ std::string MakeBidScript(const url::Origin& seller,
return base::StringPrintf(
kBidScript, seller.Serialize().c_str(), bid.c_str(), render_url.c_str(),
num_ad_components, interest_group_owner.Serialize().c_str(),
interest_group_name.c_str(), has_signals ? "true" : "false",
report_post_auction_signals ? "true" : "false",
report_reject_reason ? "true" : "false", kPostAuctionSignalsPlaceholder,
interest_group_name.c_str(), base::ToString(has_signals),
base::ToString(report_post_auction_signals),
base::ToString(report_reject_reason), kPostAuctionSignalsPlaceholder,
debug_loss_report_url.c_str(), debug_win_report_url.c_str(),
signal_key.c_str(), signal_val.c_str());
}
@ -1106,11 +1107,11 @@ std::string MakeDecisionScript(
return base::StringPrintf(
kCheckingAuctionScript, decision_logic_url.spec().c_str(),
send_report_url ? send_report_url->spec().c_str() : "",
report_post_auction_signals ? "true" : "false",
base::ToString(report_post_auction_signals),
kPostAuctionSignalsPlaceholder, debug_loss_report_url.c_str(),
debug_win_report_url.c_str(),
bid_from_component_auction_wins ? "true" : "false",
report_top_level_post_auction_signals ? "true" : "false",
base::ToString(bid_from_component_auction_wins),
base::ToString(report_top_level_post_auction_signals),
kTopLevelPostAuctionSignalsPlaceholder);
}
@ -1420,7 +1421,7 @@ const GURL ReportWinUrl(
"&madeHighestScoringOtherBid=%s&bidCurrency=%s&bid=%.0f",
url.c_str(), highest_scoring_other_bid,
blink::PrintableAdCurrency(highest_scoring_other_bid_currency).c_str(),
made_highest_scoring_other_bid ? "true" : "false",
base::ToString(made_highest_scoring_other_bid),
blink::PrintableAdCurrency(bid_currency).c_str(), bid));
}
@ -1442,11 +1443,11 @@ const GURL DebugReportUrl(
"highestScoringOtherBidCurrency=%s&madeHighestScoringOtherBid=%s",
url.c_str(), signals.winning_bid,
blink::PrintableAdCurrency(signals.winning_bid_currency).c_str(),
signals.made_winning_bid ? "true" : "false",
base::ToString(signals.made_winning_bid),
signals.highest_scoring_other_bid,
blink::PrintableAdCurrency(signals.highest_scoring_other_bid_currency)
.c_str(),
signals.made_highest_scoring_other_bid ? "true" : "false");
base::ToString(signals.made_highest_scoring_other_bid));
if (reject_reason.has_value()) {
report_url_string.append(
base::StringPrintf("&rejectReason=%s", reject_reason.value().c_str()));
@ -1485,15 +1486,15 @@ const GURL ComponentSellerDebugReportUrl(
"&bid=%.0f",
url.c_str(), signals.winning_bid,
blink::PrintableAdCurrency(signals.winning_bid_currency).c_str(),
signals.made_winning_bid ? "true" : "false",
base::ToString(signals.made_winning_bid),
signals.highest_scoring_other_bid,
blink::PrintableAdCurrency(signals.highest_scoring_other_bid_currency)
.c_str(),
signals.made_highest_scoring_other_bid ? "true" : "false",
base::ToString(signals.made_highest_scoring_other_bid),
top_level_signals.winning_bid,
blink::PrintableAdCurrency(top_level_signals.winning_bid_currency)
.c_str(),
top_level_signals.made_winning_bid ? "true" : "false", bid));
base::ToString(top_level_signals.made_winning_bid), bid));
}
// Builds a PrivateAggregationRequest with histogram contribution using given

@ -11,6 +11,7 @@
#include "base/containers/flat_map.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/to_string.h"
#include "base/test/scoped_feature_list.h"
#include "base/values.h"
#include "content/browser/interest_group/interest_group_features.h"
@ -113,7 +114,7 @@ std::ostream& operator<<(std::ostream& os,
const BiddingAndAuctionResponse& response) {
os << "BiddingAndAuctionResponse(";
os << "nonce: " << testing::PrintToString(response.nonce) << ",";
os << "is_chaff: " << (response.is_chaff ? "true" : "false") << ", ";
os << "is_chaff: " << base::ToString(response.is_chaff) << ", ";
os << "ad_render_url: " << response.ad_render_url << ", ";
os << "ad_components: [";
for (const auto& component : response.ad_components) {

@ -40,6 +40,7 @@
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/to_string.h"
#include "base/task/sequenced_task_runner.h"
#include "base/time/time.h"
#include "base/token.h"
@ -4012,9 +4013,8 @@ GURL InterestGroupAuction::FillPostAuctionSignals(
&query_string, 0, "${winningBidCurrency}",
blink::PrintableAdCurrency(signals.winning_bid_currency));
base::ReplaceSubstringsAfterOffset(
&query_string, 0, "${madeWinningBid}",
signals.made_winning_bid ? "true" : "false");
base::ReplaceSubstringsAfterOffset(&query_string, 0, "${madeWinningBid}",
base::ToString(signals.made_winning_bid));
base::ReplaceSubstringsAfterOffset(
&query_string, 0, "${highestScoringOtherBid}",
base::NumberToString(signals.highest_scoring_other_bid));
@ -4023,7 +4023,7 @@ GURL InterestGroupAuction::FillPostAuctionSignals(
blink::PrintableAdCurrency(signals.highest_scoring_other_bid_currency));
base::ReplaceSubstringsAfterOffset(
&query_string, 0, "${madeHighestScoringOtherBid}",
signals.made_highest_scoring_other_bid ? "true" : "false");
base::ToString(signals.made_highest_scoring_other_bid));
// For component auction sellers only, which get post auction signals from
// both their own component auctions and top-level auction.
@ -4038,7 +4038,7 @@ GURL InterestGroupAuction::FillPostAuctionSignals(
blink::PrintableAdCurrency(top_level_signals->winning_bid_currency));
base::ReplaceSubstringsAfterOffset(
&query_string, 0, "${topLevelMadeWinningBid}",
top_level_signals->made_winning_bid ? "true" : "false");
base::ToString(top_level_signals->made_winning_bid));
}
if (reject_reason.has_value()) {

@ -7,6 +7,7 @@
#include "base/command_line.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/to_string.h"
#include "build/build_config.h"
#include "content/browser/media/media_browsertest.h"
#include "content/public/test/browser_test.h"
@ -86,8 +87,8 @@ IN_PROC_BROWSER_TEST_F(MediaCanPlayTypeTest, CodecSupportTest_mp4) {
const bool is_ac3_eac3_supported =
media::IsDecoderSupportedAudioType({media::AudioCodec::kAC3});
ExecuteTest(base::StringPrintf("testMp4Variants(true, %s, %s)",
is_hevc_supported ? "true" : "false",
is_ac3_eac3_supported ? "true" : "false"));
base::ToString(is_hevc_supported),
base::ToString(is_ac3_eac3_supported)));
#endif // !BUILDFLAG(USE_PROPRIETARY_CODECS)
}

@ -8,6 +8,7 @@
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/strings/string_split.h"
#include "base/strings/to_string.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "content/public/common/content_switches.h"
@ -109,7 +110,7 @@ class MediaCapabilitiesTest : public ContentBrowserTest {
base::StringAppendF(&command, "testAudioConfig(");
} else if (stream_type == StreamType::kAudioWithSpatialRendering) {
base::StringAppendF(&command, "testAudioConfigWithSpatialRendering(%s,",
spatial_rendering ? "true" : "false");
base::ToString(spatial_rendering));
} else if (stream_type == StreamType::kVideoWithHdrMetadata) {
command.append("testVideoConfigWithHdrMetadata(");
for (auto x : {hdr_metadata_type, color_gamut, transfer_function}) {

@ -7,6 +7,7 @@
#include <memory>
#include "base/numerics/ranges.h"
#include "base/strings/to_string.h"
#include "base/time/time.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@ -135,7 +136,7 @@ class PhysicsModelUnittest : public ::testing::Test {
std::ostream& operator<<(std::ostream& os, const PhysicsModel::Result& r) {
os << "foreground offset: " << r.foreground_offset_physical
<< " background offset: " << r.background_offset_physical
<< " done: " << (r.done ? "true" : "false");
<< " done: " << base::ToString(r.done);
return os;
}

@ -17,6 +17,7 @@
#include "base/memory/ref_counted_memory.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/to_string.h"
#include "base/token.h"
#include "content/browser/devtools/devtools_background_services_context_impl.h"
#include "content/browser/payments/payment_app_context_impl.h"
@ -185,7 +186,7 @@ void PaymentAppProviderImpl::InstallAndInvokePaymentApp(
{"Payment Handler Name", app_name},
{"Service Worker JavaScript File URL", sw_js_url.spec()},
{"Service Worker Scope", sw_scope.spec()},
{"Service Worker Uses Cache", sw_use_cache ? "true" : "false"},
{"Service Worker Uses Cache", base::ToString(sw_use_cache)},
};
dev_tools->LogBackgroundServiceEvent(
/*service_worker_registration_id=*/-1,
@ -377,7 +378,7 @@ void PaymentAppProviderImpl::OnInstallPaymentApp(
GetDevTools(sw_origin)) {
std::map<std::string, std::string> data = {
{"Payment Handler Install Success",
registration_id >= 0 ? "true" : "false"},
base::ToString(registration_id >= 0)},
};
dev_tools->LogBackgroundServiceEvent(
registration_id, blink::StorageKey::CreateFirstParty(sw_origin),

@ -7,6 +7,7 @@
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/strings/to_string.h"
#include "content/browser/payments/payment_app_provider_impl.h"
#include "content/browser/service_worker/service_worker_context_wrapper.h"
#include "content/public/common/content_features.h"
@ -84,7 +85,7 @@ void OnResponseForCanMakePayment(
response_type << response->response_type;
std::map<std::string, std::string> data = {
{"Type", response_type.str()},
{"Can Make Payment", response->can_make_payment ? "true" : "false"}};
{"Can Make Payment", base::ToString(response->can_make_payment)}};
dev_tools->LogBackgroundServiceEvent(
registration_id, blink::StorageKey::CreateFirstParty(sw_origin),
DevToolsBackgroundService::kPaymentHandler, "Can make payment response",
@ -107,7 +108,7 @@ void OnResponseForAbortPayment(base::WeakPtr<PaymentAppProviderImpl> provider,
registration_id, blink::StorageKey::CreateFirstParty(sw_origin),
DevToolsBackgroundService::kPaymentHandler, "Abort payment response",
/*instance_id=*/payment_request_id,
{{"Payment Aborted", payment_aborted ? "true" : "false"}});
{{"Payment Aborted", base::ToString(payment_aborted)}});
}
std::move(callback).Run(payment_aborted);

@ -7,6 +7,7 @@
#include <optional>
#include <utility>
#include "base/strings/to_string.h"
#include "content/browser/bad_message.h"
#include "content/browser/blob_storage/chrome_blob_storage_context.h"
#include "content/browser/child_process_security_policy_impl.h"
@ -117,7 +118,7 @@ bool VerifyInitiatorOrigin(
}
if (current_rfh) {
auto bool_to_crash_key = [](bool b) { return b ? "true" : "false"; };
auto bool_to_crash_key = [](bool b) { return base::ToString(b); };
static auto* const is_main_frame_key =
base::debug::AllocateCrashKeyString(
"is_main_frame", base::debug::CrashKeySize::Size32);

@ -14,6 +14,7 @@
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/run_loop.h"
#include "base/strings/to_string.h"
#include "base/task/bind_post_task.h"
#include "base/task/sequenced_task_runner.h"
#include "build/build_config.h"
@ -464,7 +465,7 @@ void MediaDevicesDispatcherHost::GetVideoInputDeviceFormats(
MediaStreamManager::SendMessageToNativeLog(base::StringPrintf(
"MDDH::GetVideoInputDeviceFormats({hashed_device_id=%s}, "
"{try_in_use_first=%s})",
hashed_device_id.c_str(), try_in_use_first ? "true" : "false"));
hashed_device_id.c_str(), base::ToString(try_in_use_first)));
GetRawDeviceIDForMediaStreamHMAC(
blink::mojom::MediaStreamType::DEVICE_VIDEO_CAPTURE, salt_and_origin,
hashed_device_id, base::SequencedTaskRunner::GetCurrentDefault(),

@ -20,6 +20,7 @@
#include "base/metrics/histogram_functions.h"
#include "base/sequence_checker.h"
#include "base/strings/stringprintf.h"
#include "base/strings/to_string.h"
#include "base/task/bind_post_task.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
@ -547,8 +548,8 @@ void MediaDevicesManager::EnumerateAndRankDevices(
"EnumerateDevices({render_process_id=%d}, {render_frame_id=%d}, "
"{request_audio=%s}, {request_video=%s})",
render_frame_host_id.child_id, render_frame_host_id.frame_routing_id,
request_audio_input_capabilities ? "true" : "false",
request_video_input_capabilities ? "true" : "false"));
base::ToString(request_audio_input_capabilities),
base::ToString(request_video_input_capabilities)));
GetUIThreadTaskRunner({})->PostTask(
FROM_HERE,

@ -44,6 +44,7 @@
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/to_string.h"
#include "base/syslog_logging.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
@ -16375,59 +16376,56 @@ void RenderFrameHostImpl::LogCannotCommitUrlCrashKeys(
// Temporary instrumentation to debug the root cause of renderer process
// terminations. See https://crbug.com/931895.
auto bool_to_crash_key = [](bool b) { return b ? "true" : "false"; };
static auto* const navigation_url_key = base::debug::AllocateCrashKeyString(
"navigation_url", base::debug::CrashKeySize::Size256);
base::debug::SetCrashKeyString(navigation_url_key, url.spec());
static auto* const is_same_document_key = base::debug::AllocateCrashKeyString(
"is_same_document", base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(
is_same_document_key, bool_to_crash_key(is_same_document_navigation));
base::debug::SetCrashKeyString(is_same_document_key,
base::ToString(is_same_document_navigation));
static auto* const is_main_frame_key = base::debug::AllocateCrashKeyString(
"is_main_frame", base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(is_main_frame_key,
bool_to_crash_key(is_main_frame()));
base::ToString(is_main_frame()));
static auto* const is_outermost_frame_key =
base::debug::AllocateCrashKeyString("is_outermost_frame",
base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(is_outermost_frame_key,
bool_to_crash_key(IsOutermostMainFrame()));
base::ToString(IsOutermostMainFrame()));
static auto* const is_cross_process_subframe_key =
base::debug::AllocateCrashKeyString("is_cross_process_subframe",
base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(is_cross_process_subframe_key,
bool_to_crash_key(IsCrossProcessSubframe()));
base::ToString(IsCrossProcessSubframe()));
static auto* const is_local_root_key = base::debug::AllocateCrashKeyString(
"is_local_root", base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(is_local_root_key,
bool_to_crash_key(is_local_root()));
base::ToString(is_local_root()));
static auto* const is_opaque_origin_key = base::debug::AllocateCrashKeyString(
"is_opaque_origin", base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(is_opaque_origin_key,
bool_to_crash_key(origin.opaque()));
base::ToString(origin.opaque()));
static auto* const is_file_origin_key = base::debug::AllocateCrashKeyString(
"is_file_origin", base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(
is_file_origin_key,
bool_to_crash_key(origin.scheme() == url::kFileScheme));
is_file_origin_key, base::ToString(origin.scheme() == url::kFileScheme));
static auto* const is_data_url_key = base::debug::AllocateCrashKeyString(
"is_data_url", base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(
is_data_url_key, bool_to_crash_key(url.SchemeIs(url::kDataScheme)));
is_data_url_key, base::ToString(url.SchemeIs(url::kDataScheme)));
static auto* const is_srcdoc_url_key = base::debug::AllocateCrashKeyString(
"is_srcdoc_url", base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(is_srcdoc_url_key,
bool_to_crash_key(url.IsAboutSrcdoc()));
base::ToString(url.IsAboutSrcdoc()));
static auto* const is_loaddatawithbaseurl_key =
base::debug::AllocateCrashKeyString("is_loaddatawithbaseurl_navrequest",
@ -16435,7 +16433,7 @@ void RenderFrameHostImpl::LogCannotCommitUrlCrashKeys(
bool is_loaddatawithbaseurl =
navigation_request && navigation_request->IsLoadDataWithBaseURL();
base::debug::SetCrashKeyString(is_loaddatawithbaseurl_key,
bool_to_crash_key(is_loaddatawithbaseurl));
base::ToString(is_loaddatawithbaseurl));
static auto* const is_loaddatawithbaseurl_samedoc_key =
base::debug::AllocateCrashKeyString("is_loaddatawithbaseurl_samedoc",
@ -16445,7 +16443,7 @@ void RenderFrameHostImpl::LogCannotCommitUrlCrashKeys(
renderer_url_info_.was_loaded_from_load_data_with_base_url;
base::debug::SetCrashKeyString(
is_loaddatawithbaseurl_samedoc_key,
bool_to_crash_key(is_loaddatawithbaseurl_samedoc));
base::ToString(is_loaddatawithbaseurl_samedoc));
static auto* const site_lock_key = base::debug::AllocateCrashKeyString(
"site_lock", base::debug::CrashKeySize::Size256);
@ -16463,7 +16461,7 @@ void RenderFrameHostImpl::LogCannotCommitUrlCrashKeys(
base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(
is_process_locked_key,
bool_to_crash_key(GetProcess()->GetProcessLock().is_locked_to_site()));
base::ToString(GetProcess()->GetProcessLock().is_locked_to_site()));
if (!GetSiteInstance()->IsDefaultSiteInstance()) {
static auto* const original_url_origin_key =
@ -16478,7 +16476,7 @@ void RenderFrameHostImpl::LogCannotCommitUrlCrashKeys(
base::debug::AllocateCrashKeyString("is_mhtml_document",
base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(is_mhtml_document_key,
bool_to_crash_key(is_mhtml_document()));
base::ToString(is_mhtml_document()));
static auto* const last_committed_url_origin_key =
base::debug::AllocateCrashKeyString("last_committed_url_origin",
@ -16499,7 +16497,7 @@ void RenderFrameHostImpl::LogCannotCommitUrlCrashKeys(
base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(
is_on_initial_empty_document_key,
bool_to_crash_key(frame_tree_node_->is_on_initial_empty_document()));
base::ToString(frame_tree_node_->is_on_initial_empty_document()));
static auto* const origin_calculation_debug_info_key =
base::debug::AllocateCrashKeyString("origin_calculation_debug_info",
@ -16513,34 +16511,33 @@ void RenderFrameHostImpl::LogCannotCommitUrlCrashKeys(
base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(
is_renderer_initiated_key,
bool_to_crash_key(navigation_request->IsRendererInitiated()));
base::ToString(navigation_request->IsRendererInitiated()));
static auto* const is_server_redirect_key =
base::debug::AllocateCrashKeyString("is_server_redirect",
base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(
is_server_redirect_key,
bool_to_crash_key(navigation_request->WasServerRedirect()));
base::ToString(navigation_request->WasServerRedirect()));
static auto* const is_form_submission_key =
base::debug::AllocateCrashKeyString("is_form_submission",
base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(
is_form_submission_key,
bool_to_crash_key(navigation_request->IsFormSubmission()));
base::ToString(navigation_request->IsFormSubmission()));
static auto* const is_error_page_key = base::debug::AllocateCrashKeyString(
"is_error_page", base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(
is_error_page_key,
bool_to_crash_key(navigation_request->IsErrorPage()));
is_error_page_key, base::ToString(navigation_request->IsErrorPage()));
static auto* const from_begin_navigation_key =
base::debug::AllocateCrashKeyString("from_begin_navigation",
base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(
from_begin_navigation_key,
bool_to_crash_key(navigation_request->from_begin_navigation()));
base::ToString(navigation_request->from_begin_navigation()));
static auto* const net_error_key = base::debug::AllocateCrashKeyString(
"net_error", base::debug::CrashKeySize::Size32);
@ -16580,7 +16577,7 @@ void RenderFrameHostImpl::LogCannotCommitUrlCrashKeys(
base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(
does_recomputed_site_instance_match_key,
bool_to_crash_key(dest_instance == GetSiteInstance()));
base::ToString(dest_instance == GetSiteInstance()));
}
}
@ -17215,7 +17212,6 @@ void RenderFrameHostImpl::LogCannotCommitOriginCrashKeys(
// Temporary instrumentation to debug the root cause of
// https://crbug.com/923144.
auto bool_to_crash_key = [](bool b) { return b ? "true" : "false"; };
static auto* const target_url_key = base::debug::AllocateCrashKeyString(
"target_url", base::debug::CrashKeySize::Size256);
@ -17262,13 +17258,13 @@ void RenderFrameHostImpl::LogCannotCommitOriginCrashKeys(
static auto* const is_same_document_key = base::debug::AllocateCrashKeyString(
"is_same_document", base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(
is_same_document_key, bool_to_crash_key(is_same_document_navigation));
base::debug::SetCrashKeyString(is_same_document_key,
base::ToString(is_same_document_navigation));
static auto* const is_subframe_key = base::debug::AllocateCrashKeyString(
"is_subframe", base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(is_subframe_key,
bool_to_crash_key(GetMainFrame() != this));
base::ToString(GetMainFrame() != this));
static auto* const lifecycle_state_key = base::debug::AllocateCrashKeyString(
"lifecycle_state", base::debug::CrashKeySize::Size32);
@ -17277,18 +17273,18 @@ void RenderFrameHostImpl::LogCannotCommitOriginCrashKeys(
static auto* const is_active_key = base::debug::AllocateCrashKeyString(
"is_active", base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(is_active_key, bool_to_crash_key(IsActive()));
base::debug::SetCrashKeyString(is_active_key, base::ToString(IsActive()));
static auto* const is_cross_process_subframe_key =
base::debug::AllocateCrashKeyString("is_cross_process_subframe",
base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(is_cross_process_subframe_key,
bool_to_crash_key(IsCrossProcessSubframe()));
base::ToString(IsCrossProcessSubframe()));
static auto* const is_local_root_key = base::debug::AllocateCrashKeyString(
"is_local_root", base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(is_local_root_key,
bool_to_crash_key(is_local_root()));
base::ToString(is_local_root()));
if (navigation_request && navigation_request->IsNavigationStarted()) {
static auto* const is_renderer_initiated_key =
@ -17296,27 +17292,26 @@ void RenderFrameHostImpl::LogCannotCommitOriginCrashKeys(
base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(
is_renderer_initiated_key,
bool_to_crash_key(navigation_request->IsRendererInitiated()));
base::ToString(navigation_request->IsRendererInitiated()));
static auto* const is_server_redirect_key =
base::debug::AllocateCrashKeyString("is_server_redirect",
base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(
is_server_redirect_key,
bool_to_crash_key(navigation_request->WasServerRedirect()));
base::ToString(navigation_request->WasServerRedirect()));
static auto* const is_form_submission_key =
base::debug::AllocateCrashKeyString("is_form_submission",
base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(
is_form_submission_key,
bool_to_crash_key(navigation_request->IsFormSubmission()));
base::ToString(navigation_request->IsFormSubmission()));
static auto* const is_error_page_key = base::debug::AllocateCrashKeyString(
"is_error_page", base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(
is_error_page_key,
bool_to_crash_key(navigation_request->IsErrorPage()));
is_error_page_key, base::ToString(navigation_request->IsErrorPage()));
static auto* const initiator_origin_key =
base::debug::AllocateCrashKeyString("initiator_origin",

@ -17,6 +17,7 @@
#include "base/run_loop.h"
#include "base/scoped_observation.h"
#include "base/strings/string_split.h"
#include "base/strings/to_string.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/bind_post_task.h"
#include "base/task/single_thread_task_runner.h"
@ -1124,7 +1125,7 @@ class BoostRenderProcessForLoadingBrowserTest
{"prioritize_renderer_initiated", "false"},
{blink::features::kBoostRenderProcessForLoadingPrioritizeRestore
.name,
GetParam().prioritize_restore ? "true" : "false"}}}},
base::ToString(GetParam().prioritize_restore)}}}},
{});
} else {
feature_list_.InitAndDisableFeature(

@ -34,6 +34,7 @@
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/to_string.h"
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/lock.h"
#include "base/task/sequenced_task_runner.h"
@ -4753,10 +4754,10 @@ class ServiceWorkerWarmUpByPointerBrowserTest
"10"},
{blink::features::kSpeculativeServiceWorkerWarmUpOnPointerover
.name,
GetParam().enable_warm_up_by_pointerover ? "true" : "false"},
base::ToString(GetParam().enable_warm_up_by_pointerover)},
{blink::features::kSpeculativeServiceWorkerWarmUpOnPointerdown
.name,
GetParam().enable_warm_up_by_pointerdown ? "true" : "false"},
base::ToString(GetParam().enable_warm_up_by_pointerdown)},
}}},
{});
}

@ -9,6 +9,7 @@
#include "base/metrics/field_trial_params.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/to_string.h"
#include "base/test/bind.h"
#include "base/test/gmock_expected_support.h"
#include "base/test/scoped_feature_list.h"
@ -717,7 +718,7 @@ class OpenerHeuristicPastInteractionGrantBrowserTest
GetParam().write_grant_enabled ? "20m" : "0s";
tpcd_heuristics_grants_params_
["TpcdPopupHeuristicDisableForAdTaggedPopups"] =
GetParam().disable_for_ad_tagged_popups ? "true" : "false";
base::ToString(GetParam().disable_for_ad_tagged_popups);
}
void SetUpOnMainThread() override {
@ -1064,7 +1065,7 @@ class OpenerHeuristicCurrentInteractionGrantBrowserTest
GetParam().write_grant_enabled ? "20m" : "0s";
tpcd_heuristics_grants_params_
["TpcdPopupHeuristicDisableForAdTaggedPopups"] =
GetParam().disable_for_ad_tagged_popups ? "true" : "false";
base::ToString(GetParam().disable_for_ad_tagged_popups);
}
void SetUpOnMainThread() override {

@ -30,6 +30,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/to_string.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_future.h"
@ -254,14 +255,14 @@ struct CreateParameters {
std::string BuildCreateCallWithParameters(const CreateParameters& parameters) {
std::vector<std::string> substitutions;
substitutions.push_back(parameters.require_resident_key ? "true" : "false");
substitutions.push_back(base::ToString(parameters.require_resident_key));
substitutions.push_back(parameters.user_verification);
substitutions.push_back(parameters.rp_id);
substitutions.push_back(parameters.algorithm_identifier);
substitutions.push_back(parameters.authenticator_attachment);
substitutions.push_back(parameters.attestation);
substitutions.push_back(parameters.exclude_credentials);
substitutions.push_back(parameters.is_payment ? "true" : "false");
substitutions.push_back(base::ToString(parameters.is_payment));
substitutions.push_back(parameters.extra_extension);
std::string result;

@ -18,6 +18,7 @@
#include "base/metrics/histogram_macros.h"
#include "base/rand_util.h"
#include "base/strings/escape.h"
#include "base/strings/to_string.h"
#include "base/task/sequenced_task_runner.h"
#include "base/time/time.h"
#include "base/values.h"
@ -196,7 +197,7 @@ std::string ComputeUrlEncodedTokenPostData(
// Shares with IdP that whether the identity credential was automatically
// selected. This could help developers to better comprehend the token
// request and segment metrics accordingly.
std::string is_auto_selected = is_auto_reauthn ? "true" : "false";
std::string is_auto_selected = base::ToString(is_auto_reauthn);
if (!query.empty()) {
query += "&";
}

@ -9,6 +9,7 @@
#include "base/json/json_writer.h"
#include "base/strings/escape.h"
#include "base/strings/string_util.h"
#include "base/strings/to_string.h"
#include "base/task/sequenced_task_runner.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/browser/webid/fedcm_metrics.h"
@ -1146,7 +1147,7 @@ void IdpNetworkRequestManager::SendFailedTokenRequestMetrics(
MetricsEndpointErrorCode error_code) {
std::string url_encoded_post_data = base::StringPrintf(
"outcome=failure&error_code=%d&did_show_ui=%s",
static_cast<int>(error_code), did_show_ui ? "true" : "false");
static_cast<int>(error_code), base::ToString(did_show_ui));
std::unique_ptr<network::ResourceRequest> resource_request =
CreateUncredentialedResourceRequest(metrics_endpoint_url,
/*send_origin=*/false);

@ -13,6 +13,7 @@
#include "base/memory/weak_ptr.h"
#include "base/notreached.h"
#include "base/strings/string_split.h"
#include "base/strings/to_string.h"
#include "components/services/storage/shared_storage/shared_storage_manager.h"
#include "content/browser/renderer_host/frame_tree_node.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
@ -201,7 +202,7 @@ std::ostream& operator<<(std::ostream& os,
network::mojom::SharedStorageSetMethodPtr& set_method =
method_with_options->method->get_set_method();
os << "; Method: Set(" << set_method->key << "," << set_method->value
<< "," << (set_method->ignore_if_present ? "true" : "false") << ")";
<< "," << base::ToString(set_method->ignore_if_present) << ")";
break;
}
case network::mojom::SharedStorageModifierMethod::Tag::kAppendMethod: {

@ -15,6 +15,7 @@
#include "base/functional/bind.h"
#include "base/notreached.h"
#include "base/strings/stringprintf.h"
#include "base/strings/to_string.h"
#include "base/task/bind_post_task.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
@ -287,9 +288,9 @@ int RendererWebAudioDeviceImpl::MaxChannelCount() {
void RendererWebAudioDeviceImpl::SetDetectSilence(
bool enable_silence_detection) {
SendLogMessage(
base::StringPrintf("%s({enable_silence_detection=%s})", __func__,
enable_silence_detection ? "true" : "false"));
SendLogMessage(base::StringPrintf("%s({enable_silence_detection=%s})",
__func__,
base::ToString(enable_silence_detection)));
DCHECK(thread_checker_.CalledOnValidThread());
if (silent_sink_suspender_)

@ -47,6 +47,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/to_string.h"
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/bind_post_task.h"
@ -276,7 +277,7 @@ BASE_FEATURE(kUseThreadPoolForMediaTaskRunner,
void UpdateForegroundCrashKey(bool foreground) {
static auto* const crash_key = base::debug::AllocateCrashKeyString(
"renderer_foreground", base::debug::CrashKeySize::Size32);
base::debug::SetCrashKeyString(crash_key, foreground ? "true" : "false");
base::debug::SetCrashKeyString(crash_key, base::ToString(foreground));
}
scoped_refptr<viz::ContextProviderCommandBuffer> CreateOffscreenContext(

@ -3,8 +3,9 @@
// found in the LICENSE file.
#include "content/web_test/renderer/web_frame_test_proxy.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/to_string.h"
#include "components/plugins/renderer/plugin_placeholder.h"
#include "content/public/renderer/render_frame_observer.h"
#include "content/web_test/common/web_test_string_util.h"
@ -119,7 +120,7 @@ void PrintFrameUserGestureStatus(WebFrameTestProxy* frame_proxy,
bool is_user_gesture = frame->HasTransientUserActivation();
frame_proxy->GetWebTestControlHostRemote()->PrintMessage(
std::string("Frame with user gesture \"") +
(is_user_gesture ? "true" : "false") + "\"" + msg);
base::ToString(is_user_gesture) + "\"" + msg);
}
class TestRenderFrameObserver : public RenderFrameObserver {