Skip to content

Commit

Permalink
//content: Convert base::(U)Int(64)ToString(16) to NumberToString(16)
Browse files Browse the repository at this point in the history
The former non-overloaded variants are deprecated.
Removed casts where they are now unnecessary.

This is a mechanical change; there is no intended behavior change.

Change-Id: I22afe243411e92a7051072724745eaad5234f18b
Reviewed-on: https://chromium-review.googlesource.com/c/1451843
Commit-Queue: Raul Tambre <raul@tambre.ee>
Commit-Queue: Avi Drissman <avi@chromium.org>
Auto-Submit: Raul Tambre <raul@tambre.ee>
Reviewed-by: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#628781}
  • Loading branch information
tambry authored and Commit Bot committed Feb 4, 2019
1 parent 3f58b40 commit 6c0c3f5
Show file tree
Hide file tree
Showing 63 changed files with 164 additions and 166 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ base::string16 AccessibilityTreeFormatterAndroid::ProcessTreeForOutput(
if (show_ids()) {
int id_value;
dict.GetInteger("id", &id_value);
WriteAttribute(true, base::IntToString16(id_value), &line);
WriteAttribute(true, base::NumberToString16(id_value), &line);
}

base::string16 class_value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ base::string16 AccessibilityTreeFormatterBlink::ProcessTreeForOutput(
if (show_ids()) {
int id_value;
dict.GetInteger("id", &id_value);
WriteAttribute(true, base::IntToString16(id_value), &line);
WriteAttribute(true, base::NumberToString16(id_value), &line);
}

base::string16 role_value;
Expand Down Expand Up @@ -434,7 +434,7 @@ base::string16 AccessibilityTreeFormatterBlink::ProcessTreeForOutput(
} else {
int int_value;
value->GetInteger(i, &int_value);
attr_string += base::IntToString(int_value);
attr_string += base::NumberToString(int_value);
}
}
WriteAttribute(false, attr_string, &line);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ void AddProperties(const BrowserAccessibility& node,
if (show_ids()) {
int id_value;
dict.GetInteger("id", &id_value);
WriteAttribute(true, base::IntToString16(id_value), &line);
WriteAttribute(true, base::NumberToString16(id_value), &line);
}

NSArray* defaultAttributes =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ base::string16 AccessibilityTreeFormatterStub::ProcessTreeForOutput(
base::DictionaryValue* filtered_dict_result) {
int id_value;
node.GetInteger("id", &id_value);
return base::IntToString16(id_value);
return base::NumberToString16(id_value);
}

const base::FilePath::StringType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ void AccessibilityTreeFormatterWin::AddIA2TextProperties(
if (hr == S_OK && temp_bstr && wcslen(temp_bstr)) {
// Append offset:<number>.
base::string16 offset_str =
base::ASCIIToUTF16("offset:") + base::IntToString16(start_offset);
base::ASCIIToUTF16("offset:") + base::NumberToString16(start_offset);
text_attributes->AppendString(offset_str);
// Append name:value pairs.
std::vector<base::string16> name_val_pairs =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ void AccessibilityWinBrowserTest::SetUpInputFieldHelper(
AccessibilityNotificationWaiter waiter(
shell()->web_contents(), ui::kAXModeComplete,
ax::mojom::Event::kTextSelectionChanged);
std::wstring caret_offset = base::UTF16ToWide(
base::IntToString16(static_cast<int>(kContentsLength - 1)));
std::wstring caret_offset =
base::UTF16ToWide(base::NumberToString16(kContentsLength - 1));
ExecuteScript(
std::wstring(L"let textField = document.querySelector('input,textarea');"
L"textField.focus();"
Expand Down Expand Up @@ -369,8 +369,8 @@ void AccessibilityWinBrowserTest::SetUpTextareaField(
AccessibilityNotificationWaiter waiter(
shell()->web_contents(), ui::kAXModeComplete,
ax::mojom::Event::kTextSelectionChanged);
std::wstring caret_offset = base::UTF16ToWide(
base::IntToString16(static_cast<int>(kContentsLength - 1)));
std::wstring caret_offset =
base::UTF16ToWide(base::NumberToString16(kContentsLength - 1));
ExecuteScript(
std::wstring(L"var textField = document.querySelector('textarea');"
L"textField.focus();"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ base::string16 BrowserAccessibilityAndroid::GetRoleDescription() const {
int level = GetIntAttribute(ax::mojom::IntAttribute::kHierarchicalLevel);
if (level >= 1 && level <= 6) {
std::vector<base::string16> values;
values.push_back(base::IntToString16(level));
values.push_back(base::NumberToString16(level));
return base::ReplaceStringPlaceholders(
content_client->GetLocalizedString(IDS_AX_ROLE_HEADING_WITH_LEVEL),
values, nullptr);
Expand Down
12 changes: 6 additions & 6 deletions content/browser/accessibility/browser_accessibility_com_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1902,9 +1902,9 @@ std::vector<base::string16> BrowserAccessibilityComWin::ComputeTextAttributes()
unsigned int blue = SkColorGetB(color);
// Don't expose default value of pure white.
if (alpha && (red != 255 || green != 255 || blue != 255)) {
base::string16 color_value = L"rgb(" + base::UintToString16(red) + L',' +
base::UintToString16(green) + L',' +
base::UintToString16(blue) + L')';
base::string16 color_value = L"rgb(" + base::NumberToString16(red) +
L',' + base::NumberToString16(green) + L',' +
base::NumberToString16(blue) + L')';
SanitizeStringAttributeForIA2(color_value, &color_value);
attributes.push_back(L"background-color:" + color_value);
}
Expand All @@ -1916,9 +1916,9 @@ std::vector<base::string16> BrowserAccessibilityComWin::ComputeTextAttributes()
unsigned int blue = SkColorGetB(color);
// Don't expose default value of black.
if (red || green || blue) {
base::string16 color_value = L"rgb(" + base::UintToString16(red) + L',' +
base::UintToString16(green) + L',' +
base::UintToString16(blue) + L')';
base::string16 color_value = L"rgb(" + base::NumberToString16(red) +
L',' + base::NumberToString16(green) + L',' +
base::NumberToString16(blue) + L')';
SanitizeStringAttributeForIA2(color_value, &color_value);
attributes.push_back(L"color:" + color_value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ IN_PROC_BROWSER_TEST_F(TouchAccessibilityBrowserTest,
for (int row = 0; row < 5; ++row) {
html_url += "<tr>";
for (int col = 0; col < 7; ++col) {
html_url += "<td>" + base::IntToString(cell) + "</td>";
html_url += "<td>" + base::NumberToString(cell) + "</td>";
++cell;
}
html_url += "</tr>";
Expand All @@ -98,7 +98,7 @@ IN_PROC_BROWSER_TEST_F(TouchAccessibilityBrowserTest,
shell()->web_contents(), ui::kAXModeComplete, ax::mojom::Event::kHover);
for (int row = 0; row < 5; ++row) {
for (int col = 0; col < 7; ++col) {
std::string expected_cell_text = base::IntToString(row * 7 + col);
std::string expected_cell_text = base::NumberToString(row * 7 + col);
VLOG(1) << "Sending event in row " << row << " col " << col
<< " with text " << expected_cell_text;
SendTouchExplorationEvent(50 * col + 25, 50 * row + 25);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ jvalue CoerceJavaScriptIntegerToJavaValue(JNIEnv* env,
result.l = NULL;
break;
case JavaType::TypeString:
result.l = coerce_to_string
? ConvertUTF8ToJavaString(
env, base::Int64ToString(int_value)).Release()
: NULL;
result.l = coerce_to_string ? ConvertUTF8ToJavaString(
env, base::NumberToString(int_value))
.Release()
: NULL;
break;
case JavaType::TypeBoolean:
// LIVECONNECT_COMPLIANCE: Existing behavior is to convert to false. Spec
Expand Down Expand Up @@ -539,7 +539,7 @@ jobject CoerceJavaScriptDictionaryToArray(JNIEnv* env,
}
auto null_value = std::make_unique<base::Value>();
for (jsize i = 0; i < length; ++i) {
const std::string key(base::IntToString(i));
const std::string key(base::NumberToString(i));
const base::Value* value_element = null_value.get();
if (dictionary_value->HasKey(key)) {
dictionary_value->Get(key, &value_element);
Expand Down
6 changes: 3 additions & 3 deletions content/browser/appcache/appcache_disk_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class AppCacheDiskCache::ActiveCall
scoped_refptr<ActiveCall> active_call(
new ActiveCall(owner, entry, std::move(callback)));
net::Error return_value = owner->disk_cache()->CreateEntry(
base::Int64ToString(key), net::HIGHEST, &active_call->entry_ptr_,
base::NumberToString(key), net::HIGHEST, &active_call->entry_ptr_,
base::BindOnce(&ActiveCall::OnAsyncCompletion, active_call));
return active_call->HandleImmediateReturnValue(return_value);
}
Expand All @@ -131,7 +131,7 @@ class AppCacheDiskCache::ActiveCall
scoped_refptr<ActiveCall> active_call(
new ActiveCall(owner, entry, std::move(callback)));
net::Error return_value = owner->disk_cache()->OpenEntry(
base::Int64ToString(key), net::HIGHEST, &active_call->entry_ptr_,
base::NumberToString(key), net::HIGHEST, &active_call->entry_ptr_,
base::BindOnce(&ActiveCall::OnAsyncCompletion, active_call));
return active_call->HandleImmediateReturnValue(return_value);
}
Expand All @@ -142,7 +142,7 @@ class AppCacheDiskCache::ActiveCall
scoped_refptr<ActiveCall> active_call(
new ActiveCall(owner, nullptr, std::move(callback)));
net::Error return_value = owner->disk_cache()->DoomEntry(
base::Int64ToString(key), net::HIGHEST,
base::NumberToString(key), net::HIGHEST,
base::BindOnce(&ActiveCall::OnAsyncCompletion, active_call));
return active_call->HandleImmediateReturnValue(return_value);
}
Expand Down
10 changes: 6 additions & 4 deletions content/browser/appcache/appcache_internals_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ std::unique_ptr<base::DictionaryValue> GetDictionaryValueForResponseEnquiry(
new base::DictionaryValue());
dict_value->SetString("manifestURL", response_enquiry.manifest_url);
dict_value->SetString("groupId",
base::Int64ToString(response_enquiry.group_id));
base::NumberToString(response_enquiry.group_id));
dict_value->SetString("responseId",
base::Int64ToString(response_enquiry.response_id));
base::NumberToString(response_enquiry.response_id));
return dict_value;
}

Expand All @@ -86,7 +86,8 @@ std::unique_ptr<base::DictionaryValue> GetDictionaryValueForAppCacheInfo(
dict_value->SetString(
"size",
base::UTF16ToUTF8(base::FormatBytesUnlocalized(appcache_info.size)));
dict_value->SetString("groupId", base::Int64ToString(appcache_info.group_id));
dict_value->SetString("groupId",
base::NumberToString(appcache_info.group_id));

return dict_value;
}
Expand Down Expand Up @@ -120,7 +121,8 @@ GetDictionaryValueForAppCacheResourceInfo(
dict->SetString(
"size",
base::UTF16ToUTF8(base::FormatBytesUnlocalized(resource_info.size)));
dict->SetString("responseId", base::Int64ToString(resource_info.response_id));
dict->SetString("responseId",
base::NumberToString(resource_info.response_id));
dict->SetBoolean("isExplicit", resource_info.is_explicit);
dict->SetBoolean("isManifest", resource_info.is_manifest);
dict->SetBoolean("isMaster", resource_info.is_master);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@ TEST_F(BackgroundFetchDataManagerTest, RegistrationLimitIsEnforced) {
for (int i = 0; i < 2; i++) {
// First Service Worker.
BackgroundFetchRegistrationId registration_id1(
swid1, origin(), kExampleDeveloperId + base::IntToString(i),
swid1, origin(), kExampleDeveloperId + base::NumberToString(i),
base::GenerateGUID());
CreateRegistration(
registration_id1, std::vector<blink::mojom::FetchAPIRequestPtr>(),
Expand All @@ -982,7 +982,7 @@ TEST_F(BackgroundFetchDataManagerTest, RegistrationLimitIsEnforced) {

// Second service Worker.
BackgroundFetchRegistrationId registration_id2(
swid2, origin(), kExampleDeveloperId + base::IntToString(i),
swid2, origin(), kExampleDeveloperId + base::NumberToString(i),
base::GenerateGUID());
CreateRegistration(
registration_id2, std::vector<blink::mojom::FetchAPIRequestPtr>(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void DidUnregisterServiceWorker(base::Closure quit_closure,
}

GURL GetScopeForId(const std::string& origin, int64_t id) {
return GURL(origin + base::IntToString(id));
return GURL(origin + base::NumberToString(id));
}

} // namespace
Expand Down
3 changes: 2 additions & 1 deletion content/browser/bad_message.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ void LogBadMessage(BadMessageReason reason) {

LOG(ERROR) << "Terminating renderer for bad IPC message, reason " << reason;
base::UmaHistogramSparse("Stability.BadMessageTerminated.Content", reason);
base::debug::SetCrashKeyString(bad_message_reason, base::IntToString(reason));
base::debug::SetCrashKeyString(bad_message_reason,
base::NumberToString(reason));
}

void ReceivedBadMessageOnUIThread(int render_process_id,
Expand Down
8 changes: 4 additions & 4 deletions content/browser/database_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ class DatabaseTest : public ContentBrowserTest {
void UpdateRecord(Shell* shell, int index, const std::string& data) {
RunScriptAndCheckResult(
shell,
"updateRecord(" + base::IntToString(index) + ", '" + data + "')",
"updateRecord(" + base::NumberToString(index) + ", '" + data + "')",
"done");
}

void DeleteRecord(Shell* shell, int index) {
RunScriptAndCheckResult(
shell, "deleteRecord(" + base::IntToString(index) + ")", "done");
shell, "deleteRecord(" + base::NumberToString(index) + ")", "done");
}

void CompareRecords(Shell* shell, const std::string& expected) {
Expand Down Expand Up @@ -123,7 +123,7 @@ IN_PROC_BROWSER_TEST_F(DatabaseTest, DatabaseOperations) {

std::string expected;
for (int i = 0; i < 10; ++i) {
std::string item = base::IntToString(i);
std::string item = base::NumberToString(i);
InsertRecord(shell(), item);
if (!expected.empty())
expected += ", ";
Expand All @@ -133,7 +133,7 @@ IN_PROC_BROWSER_TEST_F(DatabaseTest, DatabaseOperations) {

expected.clear();
for (int i = 0; i < 10; ++i) {
std::string item = base::IntToString(i * i);
std::string item = base::NumberToString(i * i);
UpdateRecord(shell(), i, item);
if (!expected.empty())
expected += ", ";
Expand Down
2 changes: 1 addition & 1 deletion content/browser/devtools/devtools_io_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ DevToolsIOContext::Stream::Stream(

std::string DevToolsIOContext::Stream::Register(DevToolsIOContext* context) {
static unsigned s_last_stream_handle = 0;
const std::string handle = base::UintToString(++s_last_stream_handle);
const std::string handle = base::NumberToString(++s_last_stream_handle);
Register(context, handle);
return handle;
}
Expand Down
6 changes: 3 additions & 3 deletions content/browser/devtools/protocol/emulation_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ Response EmulationHandler::SetDeviceMetricsOverride(
screen_height.fromMaybe(0) > max_size) {
return Response::InvalidParams(
"Screen width and height values must be positive, not greater than " +
base::IntToString(max_size));
base::NumberToString(max_size));
}

if (position_x.fromMaybe(0) < 0 || position_y.fromMaybe(0) < 0 ||
Expand All @@ -195,7 +195,7 @@ Response EmulationHandler::SetDeviceMetricsOverride(
if (width < 0 || height < 0 || width > max_size || height > max_size) {
return Response::InvalidParams(
"Width and height values must be positive, not greater than " +
base::IntToString(max_size));
base::NumberToString(max_size));
}

if (device_scale_factor < 0)
Expand All @@ -219,7 +219,7 @@ Response EmulationHandler::SetDeviceMetricsOverride(
if (orientationAngle < 0 || orientationAngle >= max_orientation_angle) {
return Response::InvalidParams(
"Screen orientation angle must be non-negative, less than " +
base::IntToString(max_orientation_angle));
base::NumberToString(max_orientation_angle));
}
}

Expand Down
32 changes: 15 additions & 17 deletions content/browser/devtools/protocol/service_worker_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ void ServiceWorkerHandler::OnWorkerRegistrationUpdated(
for (const auto& registration : registrations) {
result->addItem(Registration::Create()
.SetRegistrationId(
base::Int64ToString(registration.registration_id))
base::NumberToString(registration.registration_id))
.SetScopeURL(registration.scope.spec())
.SetIsDeleted(registration.delete_flag ==
ServiceWorkerRegistrationInfo::IS_DELETED)
Expand Down Expand Up @@ -404,20 +404,18 @@ void ServiceWorkerHandler::OnWorkerVersionUpdated(
for (auto& c : client_set)
clients->addItem(c);

std::unique_ptr<Version> version_value = Version::Create()
.SetVersionId(base::Int64ToString(version.version_id))
.SetRegistrationId(
base::Int64ToString(version.registration_id))
.SetScriptURL(version.script_url.spec())
.SetRunningStatus(
GetVersionRunningStatusString(version.running_status))
.SetStatus(GetVersionStatusString(version.status))
.SetScriptLastModified(
version.script_last_modified.ToDoubleT())
.SetScriptResponseTime(
version.script_response_time.ToDoubleT())
.SetControlledClients(std::move(clients))
.Build();
std::unique_ptr<Version> version_value =
Version::Create()
.SetVersionId(base::NumberToString(version.version_id))
.SetRegistrationId(base::NumberToString(version.registration_id))
.SetScriptURL(version.script_url.spec())
.SetRunningStatus(
GetVersionRunningStatusString(version.running_status))
.SetStatus(GetVersionStatusString(version.status))
.SetScriptLastModified(version.script_last_modified.ToDoubleT())
.SetScriptResponseTime(version.script_response_time.ToDoubleT())
.SetControlledClients(std::move(clients))
.Build();
scoped_refptr<DevToolsAgentHostImpl> host(
ServiceWorkerDevToolsManager::GetInstance()
->GetDevToolsAgentHostForWorker(
Expand All @@ -437,8 +435,8 @@ void ServiceWorkerHandler::OnErrorReported(
frontend_->WorkerErrorReported(
ServiceWorker::ServiceWorkerErrorMessage::Create()
.SetErrorMessage(base::UTF16ToUTF8(info.error_message))
.SetRegistrationId(base::Int64ToString(registration_id))
.SetVersionId(base::Int64ToString(version_id))
.SetRegistrationId(base::NumberToString(registration_id))
.SetVersionId(base::NumberToString(version_id))
.SetSourceURL(info.source_url.spec())
.SetLineNumber(info.line_number)
.SetColumnNumber(info.column_number)
Expand Down
4 changes: 1 addition & 3 deletions content/browser/devtools/protocol_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ class CONTENT_EXPORT StringUtil {
static String substring(const String& s, unsigned pos, unsigned len) {
return s.substr(pos, len);
}
static String fromInteger(int number) {
return base::IntToString(number);
}
static String fromInteger(int number) { return base::NumberToString(number); }
static String fromDouble(double number) {
String s = base::NumberToString(number);
if (!s.empty() && s[0] == '.')
Expand Down
2 changes: 1 addition & 1 deletion content/browser/dom_storage/local_storage_context_mojo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class LocalStorageContextMojo::StorageAreaHolder final
item->type = leveldb::mojom::BatchOperationType::PUT_KEY;
item->key = leveldb::StdStringToUint8Vector(kVersionKey);
item->value = leveldb::StdStringToUint8Vector(
base::Int64ToString(kCurrentLocalStorageSchemaVersion));
base::NumberToString(kCurrentLocalStorageSchemaVersion));
operations.push_back(std::move(item));
context_->database_initialized_ = true;
}
Expand Down
Loading

0 comments on commit 6c0c3f5

Please sign in to comment.