diff options
144 files changed, 1464 insertions, 838 deletions
diff --git a/app/clipboard/clipboard_win.cc b/app/clipboard/clipboard_win.cc index 8ae60d3..393907d 100644 --- a/app/clipboard/clipboard_win.cc +++ b/app/clipboard/clipboard_win.cc @@ -16,7 +16,8 @@ #include "base/logging.h" #include "base/message_loop.h" #include "base/shared_memory.h" -#include "base/string_util.h" +#include "base/string_util.h" // Remove when ASCIIToWide is in utf_string_... +#include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "gfx/size.h" @@ -188,7 +189,7 @@ void Clipboard::WriteHTML(const char* markup_data, std::string html_fragment = ClipboardUtil::HtmlToCFHtml(markup, url); HGLOBAL glob = CreateGlobalData(html_fragment); - WriteToClipboard(StringToInt(GetHtmlFormatType()), glob); + WriteToClipboard(ClipboardUtil::GetHtmlFormat()->cfFormat, glob); } void Clipboard::WriteBookmark(const char* title_data, @@ -202,12 +203,13 @@ void Clipboard::WriteBookmark(const char* title_data, string16 wide_bookmark = UTF8ToWide(bookmark); HGLOBAL glob = CreateGlobalData(wide_bookmark); - WriteToClipboard(StringToInt(GetUrlWFormatType()), glob); + WriteToClipboard(ClipboardUtil::GetUrlWFormat()->cfFormat, glob); } void Clipboard::WriteWebSmartPaste() { DCHECK(clipboard_owner_); - ::SetClipboardData(StringToInt(GetWebKitSmartPasteFormatType()), NULL); + ::SetClipboardData(ClipboardUtil::GetWebKitSmartPasteFormat()->cfFormat, + NULL); } void Clipboard::WriteBitmap(const char* pixel_data, const char* size_data) { @@ -314,7 +316,10 @@ void Clipboard::WriteToClipboard(unsigned int format, HANDLE handle) { bool Clipboard::IsFormatAvailable(const Clipboard::FormatType& format, Clipboard::Buffer buffer) const { DCHECK_EQ(buffer, BUFFER_STANDARD); - return ::IsClipboardFormatAvailable(StringToInt(format)) != FALSE; + int f; + if (!base::StringToInt(format, &f)) + return false; + return ::IsClipboardFormatAvailable(f) != FALSE; } bool Clipboard::IsFormatAvailableByString( @@ -384,7 +389,7 @@ void Clipboard::ReadHTML(Clipboard::Buffer buffer, string16* markup, if (!clipboard.Acquire(GetClipboardWindow())) return; - HANDLE data = ::GetClipboardData(StringToInt(GetHtmlFormatType())); + HANDLE data = ::GetClipboardData(ClipboardUtil::GetHtmlFormat()->cfFormat); if (!data) return; @@ -410,7 +415,7 @@ void Clipboard::ReadBookmark(string16* title, std::string* url) const { if (!clipboard.Acquire(GetClipboardWindow())) return; - HANDLE data = ::GetClipboardData(StringToInt(GetUrlWFormatType())); + HANDLE data = ::GetClipboardData(ClipboardUtil::GetUrlWFormat()->cfFormat); if (!data) return; @@ -507,74 +512,75 @@ void Clipboard::ParseBookmarkClipboardFormat(const string16& bookmark, // static Clipboard::FormatType Clipboard::GetUrlFormatType() { - return IntToString(ClipboardUtil::GetUrlFormat()->cfFormat); + return base::IntToString(ClipboardUtil::GetUrlFormat()->cfFormat); } // static Clipboard::FormatType Clipboard::GetUrlWFormatType() { - return IntToString(ClipboardUtil::GetUrlWFormat()->cfFormat); + return base::IntToString(ClipboardUtil::GetUrlWFormat()->cfFormat); } // static Clipboard::FormatType Clipboard::GetMozUrlFormatType() { - return IntToString(ClipboardUtil::GetMozUrlFormat()->cfFormat); + return base::IntToString(ClipboardUtil::GetMozUrlFormat()->cfFormat); } // static Clipboard::FormatType Clipboard::GetPlainTextFormatType() { - return IntToString(ClipboardUtil::GetPlainTextFormat()->cfFormat); + return base::IntToString(ClipboardUtil::GetPlainTextFormat()->cfFormat); } // static Clipboard::FormatType Clipboard::GetPlainTextWFormatType() { - return IntToString(ClipboardUtil::GetPlainTextWFormat()->cfFormat); + return base::IntToString(ClipboardUtil::GetPlainTextWFormat()->cfFormat); } // static Clipboard::FormatType Clipboard::GetFilenameFormatType() { - return IntToString(ClipboardUtil::GetFilenameFormat()->cfFormat); + return base::IntToString(ClipboardUtil::GetFilenameFormat()->cfFormat); } // static Clipboard::FormatType Clipboard::GetFilenameWFormatType() { - return IntToString(ClipboardUtil::GetFilenameWFormat()->cfFormat); + return base::IntToString(ClipboardUtil::GetFilenameWFormat()->cfFormat); } // MS HTML Format // static Clipboard::FormatType Clipboard::GetHtmlFormatType() { - return IntToString(ClipboardUtil::GetHtmlFormat()->cfFormat); + return base::IntToString(ClipboardUtil::GetHtmlFormat()->cfFormat); } // static Clipboard::FormatType Clipboard::GetBitmapFormatType() { - return IntToString(CF_BITMAP); + return base::IntToString(CF_BITMAP); } // Firefox text/html // static Clipboard::FormatType Clipboard::GetTextHtmlFormatType() { - return IntToString(ClipboardUtil::GetTextHtmlFormat()->cfFormat); + return base::IntToString(ClipboardUtil::GetTextHtmlFormat()->cfFormat); } // static Clipboard::FormatType Clipboard::GetCFHDropFormatType() { - return IntToString(ClipboardUtil::GetCFHDropFormat()->cfFormat); + return base::IntToString(ClipboardUtil::GetCFHDropFormat()->cfFormat); } // static Clipboard::FormatType Clipboard::GetFileDescriptorFormatType() { - return IntToString(ClipboardUtil::GetFileDescriptorFormat()->cfFormat); + return base::IntToString(ClipboardUtil::GetFileDescriptorFormat()->cfFormat); } // static Clipboard::FormatType Clipboard::GetFileContentFormatZeroType() { - return IntToString(ClipboardUtil::GetFileContentFormatZero()->cfFormat); + return base::IntToString(ClipboardUtil::GetFileContentFormatZero()->cfFormat); } // static Clipboard::FormatType Clipboard::GetWebKitSmartPasteFormatType() { - return IntToString(ClipboardUtil::GetWebKitSmartPasteFormat()->cfFormat); + return base::IntToString( + ClipboardUtil::GetWebKitSmartPasteFormat()->cfFormat); } // static diff --git a/app/gfx/font_util.cc b/app/gfx/font_util.cc index b079dd9..61e1b52dd 100644 --- a/app/gfx/font_util.cc +++ b/app/gfx/font_util.cc @@ -6,7 +6,7 @@ #include "app/l10n_util.h" #include "base/logging.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "gfx/font.h" @@ -15,7 +15,8 @@ namespace gfx { int GetLocalizedContentsWidthForFont(int col_resource_id, const gfx::Font& font) { double chars = 0; - StringToDouble(WideToUTF8(l10n_util::GetString(col_resource_id)), &chars); + base::StringToDouble(WideToUTF8(l10n_util::GetString(col_resource_id)), + &chars); int width = font.GetExpectedTextWidth(static_cast<int>(chars)); DCHECK_GT(width, 0); return width; @@ -24,7 +25,8 @@ int GetLocalizedContentsWidthForFont(int col_resource_id, int GetLocalizedContentsHeightForFont(int row_resource_id, const gfx::Font& font) { double lines = 0; - StringToDouble(WideToUTF8(l10n_util::GetString(row_resource_id)), &lines); + base::StringToDouble(WideToUTF8(l10n_util::GetString(row_resource_id)), + &lines); int height = static_cast<int>(font.height() * lines); DCHECK_GT(height, 0); return height; diff --git a/app/l10n_util.cc b/app/l10n_util.cc index 95fd0ee..b3e550f 100644 --- a/app/l10n_util.cc +++ b/app/l10n_util.cc @@ -16,8 +16,7 @@ #include "base/path_service.h" #include "base/scoped_ptr.h" #include "base/string16.h" -#include "base/string_piece.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/sys_string_conversions.h" #include "build/build_config.h" #include "gfx/canvas.h" @@ -648,11 +647,11 @@ string16 GetStringFUTF16(int message_id, } std::wstring GetStringF(int message_id, int a) { - return GetStringF(message_id, IntToWString(a)); + return GetStringF(message_id, UTF8ToWide(base::IntToString(a))); } std::wstring GetStringF(int message_id, int64 a) { - return GetStringF(message_id, Int64ToWString(a)); + return GetStringF(message_id, UTF8ToWide(base::Int64ToString(a))); } std::wstring TruncateString(const std::wstring& string, size_t length) { diff --git a/app/l10n_util_win.cc b/app/l10n_util_win.cc index 350c29a..4d22dd3 100644 --- a/app/l10n_util_win.cc +++ b/app/l10n_util_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,7 +9,8 @@ #include "app/l10n_util_win.h" #include "base/i18n/rtl.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" +//#include "base/string_util.h" #include "base/win_util.h" #include "grit/app_locale_settings.h" @@ -107,7 +108,11 @@ bool NeedOverrideDefaultUIFont(std::wstring* override_font_family, } std::wstring ui_font_family = GetString(ui_font_family_id); - int scaler100 = StringToInt(l10n_util::GetString(ui_font_size_scaler_id)); + int scaler100; + if (!base::StringToInt(l10n_util::GetString(ui_font_size_scaler_id), + &scaler100)) + return false; + // We use the OS default in two cases: // 1) The resource bundle has 'default' and '100' for font family and // font scaler. diff --git a/base/base.gyp b/base/base.gyp index d53bd13..77f8de1 100644 --- a/base/base.gyp +++ b/base/base.gyp @@ -130,6 +130,7 @@ 'singleton_unittest.cc', 'stack_container_unittest.cc', 'stats_table_unittest.cc', + 'string_number_conversions_unittest.cc', 'string_piece_unittest.cc', 'string_split_unittest.cc', 'string_tokenizer_unittest.cc', diff --git a/base/base.gypi b/base/base.gypi index cad0256..a5fdfc6 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -216,6 +216,8 @@ 'stats_table.cc', 'stats_table.h', 'stl_util-inl.h', + 'string_number_conversions.cc', + 'string_number_conversions.h', 'string_piece.cc', 'string_piece.h', 'string_split.cc', diff --git a/base/file_util_win.cc b/base/file_util_win.cc index 2181516..33491ed 100644 --- a/base/file_util_win.cc +++ b/base/file_util_win.cc @@ -17,6 +17,7 @@ #include "base/pe_image.h" #include "base/scoped_comptr_win.h" #include "base/scoped_handle.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/time.h" #include "base/win_util.h" @@ -562,9 +563,9 @@ bool CreateTemporaryDirInDir(const FilePath& base_dir, // the one exists, keep trying another path name until we reach some limit. path_to_create = base_dir; - std::wstring new_dir_name; + string16 new_dir_name; new_dir_name.assign(prefix); - new_dir_name.append(IntToWString(rand() % kint16max)); + new_dir_name.append(base::IntToString16(rand() % kint16max)); path_to_create = path_to_create.Append(new_dir_name); if (::CreateDirectory(path_to_create.value().c_str(), NULL)) diff --git a/base/json/json_reader.cc b/base/json/json_reader.cc index cf9ce02..1255ac5 100644 --- a/base/json/json_reader.cc +++ b/base/json/json_reader.cc @@ -7,6 +7,7 @@ #include "base/float_util.h" #include "base/logging.h" #include "base/scoped_ptr.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "base/values.h" @@ -401,11 +402,11 @@ Value* JSONReader::DecodeNumber(const Token& token) { const std::wstring num_string(token.begin, token.length); int num_int; - if (StringToInt(WideToUTF16Hack(num_string), &num_int)) + if (StringToInt(WideToUTF8(num_string), &num_int)) return Value::CreateIntegerValue(num_int); double num_double; - if (StringToDouble(WideToUTF16Hack(num_string), &num_double) && + if (StringToDouble(WideToUTF8(num_string), &num_double) && base::IsFinite(num_double)) return Value::CreateRealValue(num_double); diff --git a/base/json/json_writer.cc b/base/json/json_writer.cc index ffdad76..fa43953 100644 --- a/base/json/json_writer.cc +++ b/base/json/json_writer.cc @@ -7,6 +7,7 @@ #include "base/json/string_escape.h" #include "base/logging.h" #include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/values.h" #include "base/utf_string_conversions.h" diff --git a/base/process_util_linux.cc b/base/process_util_linux.cc index d3d029e..8b8a0c7 100644 --- a/base/process_util_linux.cc +++ b/base/process_util_linux.cc @@ -17,6 +17,7 @@ #include "base/file_util.h" #include "base/logging.h" +#include "base/string_number_conversions.h" #include "base/string_tokenizer.h" #include "base/string_util.h" #include "base/sys_info.h" @@ -32,7 +33,7 @@ enum ParsingState { // spaces. void GetProcStats(pid_t pid, std::vector<std::string>* proc_stats) { FilePath stat_file("/proc"); - stat_file = stat_file.Append(IntToString(pid)); + stat_file = stat_file.Append(base::IntToString(pid)); stat_file = stat_file.Append("stat"); std::string mem_stats; if (!file_util::ReadFileToString(stat_file, &mem_stats)) @@ -46,7 +47,7 @@ namespace base { ProcessId GetParentProcessId(ProcessHandle process) { FilePath stat_file("/proc"); - stat_file = stat_file.Append(IntToString(process)); + stat_file = stat_file.Append(base::IntToString(process)); stat_file = stat_file.Append("status"); std::string status; if (!file_util::ReadFileToString(stat_file, &status)) @@ -64,7 +65,8 @@ ProcessId GetParentProcessId(ProcessHandle process) { case KEY_VALUE: DCHECK(!last_key_name.empty()); if (last_key_name == "PPid") { - pid_t ppid = StringToInt(tokenizer.token()); + int ppid; + base::StringToInt(tokenizer.token(), &ppid); return ppid; } state = KEY_NAME; @@ -77,7 +79,7 @@ ProcessId GetParentProcessId(ProcessHandle process) { FilePath GetProcessExecutablePath(ProcessHandle process) { FilePath stat_file("/proc"); - stat_file = stat_file.Append(IntToString(process)); + stat_file = stat_file.Append(base::IntToString(process)); stat_file = stat_file.Append("exe"); char exename[2048]; ssize_t len = readlink(stat_file.value().c_str(), exename, sizeof(exename)); @@ -205,8 +207,11 @@ size_t ProcessMetrics::GetPagefileUsage() const { std::vector<std::string> proc_stats; GetProcStats(process_, &proc_stats); const size_t kVmSize = 22; - if (proc_stats.size() > kVmSize) - return static_cast<size_t>(StringToInt(proc_stats[kVmSize])); + if (proc_stats.size() > kVmSize) { + int vm_size; + base::StringToInt(proc_stats[kVmSize], &vm_size); + return static_cast<size_t>(vm_size); + } return 0; } @@ -215,8 +220,11 @@ size_t ProcessMetrics::GetPeakPagefileUsage() const { std::vector<std::string> proc_stats; GetProcStats(process_, &proc_stats); const size_t kVmPeak = 21; - if (proc_stats.size() > kVmPeak) - return static_cast<size_t>(StringToInt(proc_stats[kVmPeak])); + if (proc_stats.size() > kVmPeak) { + int vm_peak; + if (base::StringToInt(proc_stats[kVmPeak], &vm_peak)) + return vm_peak; + } return 0; } @@ -226,8 +234,9 @@ size_t ProcessMetrics::GetWorkingSetSize() const { GetProcStats(process_, &proc_stats); const size_t kVmRss = 23; if (proc_stats.size() > kVmRss) { - size_t num_pages = static_cast<size_t>(StringToInt(proc_stats[kVmRss])); - return num_pages * getpagesize(); + int num_pages; + if (base::StringToInt(proc_stats[kVmRss], &num_pages)) + return static_cast<size_t>(num_pages) * getpagesize(); } return 0; } @@ -238,8 +247,9 @@ size_t ProcessMetrics::GetPeakWorkingSetSize() const { GetProcStats(process_, &proc_stats); const size_t kVmHwm = 23; if (proc_stats.size() > kVmHwm) { - size_t num_pages = static_cast<size_t>(StringToInt(proc_stats[kVmHwm])); - return num_pages * getpagesize(); + int num_pages; + base::StringToInt(proc_stats[kVmHwm], &num_pages); + return static_cast<size_t>(num_pages) * getpagesize(); } return 0; } @@ -265,7 +275,7 @@ bool ProcessMetrics::GetMemoryBytes(size_t* private_bytes, // See http://www.pixelbeat.org/scripts/ps_mem.py bool ProcessMetrics::GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const { FilePath stat_file = - FilePath("/proc").Append(IntToString(process_)).Append("smaps"); + FilePath("/proc").Append(base::IntToString(process_)).Append("smaps"); std::string smaps; int private_kb = 0; int pss_kb = 0; @@ -288,10 +298,14 @@ bool ProcessMetrics::GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const { return false; } if (last_key_name.starts_with(private_prefix)) { - private_kb += StringToInt(tokenizer.token()); + int cur; + base::StringToInt(tokenizer.token(), &cur); + private_kb += cur; } else if (last_key_name.starts_with(pss_prefix)) { have_pss = true; - pss_kb += StringToInt(tokenizer.token()); + int cur; + base::StringToInt(tokenizer.token(), &cur); + pss_kb += cur; } state = KEY_NAME; break; @@ -305,7 +319,7 @@ bool ProcessMetrics::GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const { return false; stat_file = - FilePath("/proc").Append(IntToString(process_)).Append("statm"); + FilePath("/proc").Append(base::IntToString(process_)).Append("statm"); std::string statm; if (!file_util::ReadFileToString(stat_file, &statm) || statm.length() == 0) return false; @@ -314,8 +328,11 @@ bool ProcessMetrics::GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const { SplitString(statm, ' ', &statm_vec); if (statm_vec.size() != 7) return false; // Not the format we expect. - private_kb = StringToInt(statm_vec[1]) - StringToInt(statm_vec[2]); - private_kb *= page_size_kb; + + int statm1, statm2; + base::StringToInt(statm_vec[1], &statm1); + base::StringToInt(statm_vec[2], &statm2); + private_kb = (statm1 - statm2) * page_size_kb; } ws_usage->priv = private_kb; // Sharable is not calculated, as it does not provide interesting data. @@ -332,7 +349,7 @@ bool ProcessMetrics::GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const { bool ProcessMetrics::GetIOCounters(IoCounters* io_counters) const { std::string proc_io_contents; FilePath io_file("/proc"); - io_file = io_file.Append(IntToString(process_)); + io_file = io_file.Append(base::IntToString(process_)); io_file = io_file.Append("io"); if (!file_util::ReadFileToString(io_file, &proc_io_contents)) return false; @@ -352,13 +369,17 @@ bool ProcessMetrics::GetIOCounters(IoCounters* io_counters) const { case KEY_VALUE: DCHECK(!last_key_name.empty()); if (last_key_name == "syscr") { - (*io_counters).ReadOperationCount = StringToInt64(tokenizer.token()); + base::StringToInt64(tokenizer.token(), + reinterpret_cast<int64*>(&(*io_counters).ReadOperationCount)); } else if (last_key_name == "syscw") { - (*io_counters).WriteOperationCount = StringToInt64(tokenizer.token()); + base::StringToInt64(tokenizer.token(), + reinterpret_cast<int64*>(&(*io_counters).WriteOperationCount)); } else if (last_key_name == "rchar") { - (*io_counters).ReadTransferCount = StringToInt64(tokenizer.token()); + base::StringToInt64(tokenizer.token(), + reinterpret_cast<int64*>(&(*io_counters).ReadTransferCount)); } else if (last_key_name == "wchar") { - (*io_counters).WriteTransferCount = StringToInt64(tokenizer.token()); + base::StringToInt64(tokenizer.token(), + reinterpret_cast<int64*>(&(*io_counters).WriteTransferCount)); } state = KEY_NAME; break; @@ -384,7 +405,10 @@ int ParseProcStatCPU(const std::string& input) { if (fields.size() < 13) return -1; // Output not in the format we expect. - return StringToInt(fields[11]) + StringToInt(fields[12]); + int fields11, fields12; + base::StringToInt(fields[11], &fields11); + base::StringToInt(fields[12], &fields12); + return fields11 + fields12; } // Get the total CPU of a single process. Return value is number of jiffies @@ -498,13 +522,13 @@ size_t GetSystemCommitCharge() { DCHECK_EQ(meminfo_fields[kMemBuffersIndex-1], "Buffers:"); DCHECK_EQ(meminfo_fields[kMemCacheIndex-1], "Cached:"); - size_t result_in_kb; - result_in_kb = StringToInt(meminfo_fields[kMemTotalIndex]); - result_in_kb -= StringToInt(meminfo_fields[kMemFreeIndex]); - result_in_kb -= StringToInt(meminfo_fields[kMemBuffersIndex]); - result_in_kb -= StringToInt(meminfo_fields[kMemCacheIndex]); + int mem_total, mem_free, mem_buffers, mem_cache; + base::StringToInt(meminfo_fields[kMemTotalIndex], &mem_total); + base::StringToInt(meminfo_fields[kMemFreeIndex], &mem_free); + base::StringToInt(meminfo_fields[kMemBuffersIndex], &mem_buffers); + base::StringToInt(meminfo_fields[kMemCacheIndex], &mem_cache); - return result_in_kb; + return mem_total - mem_free - mem_buffers - mem_cache; } namespace { @@ -613,13 +637,13 @@ bool AdjustOOMScore(ProcessId process, int score) { return false; FilePath oom_adj("/proc"); - oom_adj = oom_adj.Append(Int64ToString(process)); + oom_adj = oom_adj.Append(base::Int64ToString(process)); oom_adj = oom_adj.AppendASCII("oom_adj"); if (!file_util::PathExists(oom_adj)) return false; - std::string score_str = IntToString(score); + std::string score_str = base::IntToString(score); return (static_cast<int>(score_str.length()) == file_util::WriteFile(oom_adj, score_str.c_str(), score_str.length())); } diff --git a/base/simple_thread.cc b/base/simple_thread.cc index 6d531a2..a72542d 100644 --- a/base/simple_thread.cc +++ b/base/simple_thread.cc @@ -7,7 +7,7 @@ #include "base/waitable_event.h" #include "base/logging.h" #include "base/platform_thread.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" namespace base { diff --git a/base/simple_thread_unittest.cc b/base/simple_thread_unittest.cc index 8bb267d..df0f5c6 100644 --- a/base/simple_thread_unittest.cc +++ b/base/simple_thread_unittest.cc @@ -1,10 +1,11 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "base/atomic_sequence_num.h" #include "base/lock.h" #include "base/simple_thread.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/waitable_event.h" #include "testing/gtest/include/gtest/gtest.h" @@ -121,8 +122,8 @@ TEST(SimpleThreadTest, NamedWithOptions) { thread.Start(); EXPECT_EQ(thread.name_prefix(), "event_waiter"); - EXPECT_EQ(thread.name(), std::string("event_waiter/") + - IntToString(thread.tid())); + EXPECT_EQ(thread.name(), + std::string("event_waiter/") + base::IntToString(thread.tid())); event.Wait(); EXPECT_TRUE(event.IsSignaled()); @@ -130,8 +131,8 @@ TEST(SimpleThreadTest, NamedWithOptions) { // We keep the name and tid, even after the thread is gone. EXPECT_EQ(thread.name_prefix(), "event_waiter"); - EXPECT_EQ(thread.name(), std::string("event_waiter/") + - IntToString(thread.tid())); + EXPECT_EQ(thread.name(), + std::string("event_waiter/") + base::IntToString(thread.tid())); } TEST(SimpleThreadTest, ThreadPool) { diff --git a/base/string_number_conversions.cc b/base/string_number_conversions.cc new file mode 100644 index 0000000..d340151 --- /dev/null +++ b/base/string_number_conversions.cc @@ -0,0 +1,400 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/string_number_conversions.h" + +#include <errno.h> +#include <stdlib.h> + +#include "base/logging.h" +#include "base/third_party/dmg_fp/dmg_fp.h" +#include "base/utf_string_conversions.h" + +namespace base { + +namespace { + +template <typename STR, typename INT, typename UINT, bool NEG> +struct IntToStringT { + // This is to avoid a compiler warning about unary minus on unsigned type. + // For example, say you had the following code: + // template <typename INT> + // INT abs(INT value) { return value < 0 ? -value : value; } + // Even though if INT is unsigned, it's impossible for value < 0, so the + // unary minus will never be taken, the compiler will still generate a + // warning. We do a little specialization dance... + template <typename INT2, typename UINT2, bool NEG2> + struct ToUnsignedT {}; + + template <typename INT2, typename UINT2> + struct ToUnsignedT<INT2, UINT2, false> { + static UINT2 ToUnsigned(INT2 value) { + return static_cast<UINT2>(value); + } + }; + + template <typename INT2, typename UINT2> + struct ToUnsignedT<INT2, UINT2, true> { + static UINT2 ToUnsigned(INT2 value) { + return static_cast<UINT2>(value < 0 ? -value : value); + } + }; + + // This set of templates is very similar to the above templates, but + // for testing whether an integer is negative. + template <typename INT2, bool NEG2> + struct TestNegT {}; + template <typename INT2> + struct TestNegT<INT2, false> { + static bool TestNeg(INT2 value) { + // value is unsigned, and can never be negative. + return false; + } + }; + template <typename INT2> + struct TestNegT<INT2, true> { + static bool TestNeg(INT2 value) { + return value < 0; + } + }; + + static STR IntToString(INT value) { + // log10(2) ~= 0.3 bytes needed per bit or per byte log10(2**8) ~= 2.4. + // So round up to allocate 3 output characters per byte, plus 1 for '-'. + const int kOutputBufSize = 3 * sizeof(INT) + 1; + + // Allocate the whole string right away, we will right back to front, and + // then return the substr of what we ended up using. + STR outbuf(kOutputBufSize, 0); + + bool is_neg = TestNegT<INT, NEG>::TestNeg(value); + // Even though is_neg will never be true when INT is parameterized as + // unsigned, even the presence of the unary operation causes a warning. + UINT res = ToUnsignedT<INT, UINT, NEG>::ToUnsigned(value); + + for (typename STR::iterator it = outbuf.end();;) { + --it; + DCHECK(it != outbuf.begin()); + *it = static_cast<typename STR::value_type>((res % 10) + '0'); + res /= 10; + + // We're done.. + if (res == 0) { + if (is_neg) { + --it; + DCHECK(it != outbuf.begin()); + *it = static_cast<typename STR::value_type>('-'); + } + return STR(it, outbuf.end()); + } + } + NOTREACHED(); + return STR(); + } +}; + +// Generalized string-to-number conversion. +// +// StringToNumberTraits should provide: +// - a typedef for string_type, the STL string type used as input. +// - a typedef for value_type, the target numeric type. +// - a static function, convert_func, which dispatches to an appropriate +// strtol-like function and returns type value_type. +// - a static function, valid_func, which validates |input| and returns a bool +// indicating whether it is in proper form. This is used to check for +// conditions that convert_func tolerates but should result in +// StringToNumber returning false. For strtol-like funtions, valid_func +// should check for leading whitespace. +template<typename StringToNumberTraits> +bool StringToNumber(const typename StringToNumberTraits::string_type& input, + typename StringToNumberTraits::value_type* output) { + typedef StringToNumberTraits traits; + + errno = 0; // Thread-safe? It is on at least Mac, Linux, and Windows. + typename traits::string_type::value_type* endptr = NULL; + typename traits::value_type value = traits::convert_func(input.c_str(), + &endptr); + *output = value; + + // Cases to return false: + // - If errno is ERANGE, there was an overflow or underflow. + // - If the input string is empty, there was nothing to parse. + // - If endptr does not point to the end of the string, there are either + // characters remaining in the string after a parsed number, or the string + // does not begin with a parseable number. endptr is compared to the + // expected end given the string's stated length to correctly catch cases + // where the string contains embedded NUL characters. + // - valid_func determines that the input is not in preferred form. + return errno == 0 && + !input.empty() && + input.c_str() + input.length() == endptr && + traits::valid_func(input); +} + +static int strtoi(const char *nptr, char **endptr, int base) { + long res = strtol(nptr, endptr, base); +#if __LP64__ + // Long is 64-bits, we have to handle under/overflow ourselves. + if (res > kint32max) { + res = kint32max; + errno = ERANGE; + } else if (res < kint32min) { + res = kint32min; + errno = ERANGE; + } +#endif + return static_cast<int>(res); +} + +static unsigned int strtoui(const char *nptr, char **endptr, int base) { + unsigned long res = strtoul(nptr, endptr, base); +#if __LP64__ + // Long is 64-bits, we have to handle under/overflow ourselves. Test to see + // if the result can fit into 32-bits (as signed or unsigned). + if (static_cast<int>(static_cast<long>(res)) != static_cast<long>(res) && + static_cast<unsigned int>(res) != res) { + res = kuint32max; + errno = ERANGE; + } +#endif + return static_cast<unsigned int>(res); +} + +class StringToIntTraits { + public: + typedef std::string string_type; + typedef int value_type; + static const int kBase = 10; + static inline value_type convert_func(const string_type::value_type* str, + string_type::value_type** endptr) { + return strtoi(str, endptr, kBase); + } + static inline bool valid_func(const string_type& str) { + return !str.empty() && !isspace(str[0]); + } +}; + +class String16ToIntTraits { + public: + typedef string16 string_type; + typedef int value_type; + static const int kBase = 10; + static inline value_type convert_func(const string_type::value_type* str, + string_type::value_type** endptr) { +#if defined(WCHAR_T_IS_UTF16) + return wcstol(str, endptr, kBase); +#elif defined(WCHAR_T_IS_UTF32) + std::string ascii_string = UTF16ToUTF8(string16(str)); + char* ascii_end = NULL; + value_type ret = strtoi(ascii_string.c_str(), &ascii_end, kBase); + if (ascii_string.c_str() + ascii_string.length() == ascii_end) { + *endptr = + const_cast<string_type::value_type*>(str) + ascii_string.length(); + } + return ret; +#endif + } + static inline bool valid_func(const string_type& str) { + return !str.empty() && !iswspace(str[0]); + } +}; + +class StringToInt64Traits { + public: + typedef std::string string_type; + typedef int64 value_type; + static const int kBase = 10; + static inline value_type convert_func(const string_type::value_type* str, + string_type::value_type** endptr) { +#ifdef OS_WIN + return _strtoi64(str, endptr, kBase); +#else // assume OS_POSIX + return strtoll(str, endptr, kBase); +#endif + } + static inline bool valid_func(const string_type& str) { + return !str.empty() && !isspace(str[0]); + } +}; + +class String16ToInt64Traits { + public: + typedef string16 string_type; + typedef int64 value_type; + static const int kBase = 10; + static inline value_type convert_func(const string_type::value_type* str, + string_type::value_type** endptr) { +#ifdef OS_WIN + return _wcstoi64(str, endptr, kBase); +#else // assume OS_POSIX + std::string ascii_string = UTF16ToUTF8(string16(str)); + char* ascii_end = NULL; + value_type ret = strtoll(ascii_string.c_str(), &ascii_end, kBase); + if (ascii_string.c_str() + ascii_string.length() == ascii_end) { + *endptr = + const_cast<string_type::value_type*>(str) + ascii_string.length(); + } + return ret; +#endif + } + static inline bool valid_func(const string_type& str) { + return !str.empty() && !iswspace(str[0]); + } +}; + +// For the HexString variants, use the unsigned variants like strtoul for +// convert_func so that input like "0x80000000" doesn't result in an overflow. + +class HexStringToIntTraits { + public: + typedef std::string string_type; + typedef int value_type; + static const int kBase = 16; + static inline value_type convert_func(const string_type::value_type* str, + string_type::value_type** endptr) { + return strtoui(str, endptr, kBase); + } + static inline bool valid_func(const string_type& str) { + return !str.empty() && !isspace(str[0]); + } +}; + +class StringToDoubleTraits { + public: + typedef std::string string_type; + typedef double value_type; + static inline value_type convert_func(const string_type::value_type* str, + string_type::value_type** endptr) { + return dmg_fp::strtod(str, endptr); + } + static inline bool valid_func(const string_type& str) { + return !str.empty() && !isspace(str[0]); + } +}; + +template<class CHAR> +bool HexDigitToIntT(const CHAR digit, uint8* val) { + if (digit >= '0' && digit <= '9') + *val = digit - '0'; + else if (digit >= 'a' && digit <= 'f') + *val = 10 + digit - 'a'; + else if (digit >= 'A' && digit <= 'F') + *val = 10 + digit - 'A'; + else + return false; + return true; +} + +template<typename STR> +bool HexStringToBytesT(const STR& input, std::vector<uint8>* output) { + DCHECK(output->size() == 0); + size_t count = input.size(); + if (count == 0 || (count % 2) != 0) + return false; + for (uintptr_t i = 0; i < count / 2; ++i) { + uint8 msb = 0; // most significant 4 bits + uint8 lsb = 0; // least significant 4 bits + if (!HexDigitToIntT(input[i * 2], &msb) || + !HexDigitToIntT(input[i * 2 + 1], &lsb)) + return false; + output->push_back((msb << 4) | lsb); + } + return true; +} + +} // namespace + +std::string IntToString(int value) { + return IntToStringT<std::string, int, unsigned int, true>:: + IntToString(value); +} + +string16 IntToString16(int value) { + return IntToStringT<string16, int, unsigned int, true>:: + IntToString(value); +} + +std::string UintToString(unsigned int value) { + return IntToStringT<std::string, unsigned int, unsigned int, false>:: + IntToString(value); +} + +string16 UintToString16(unsigned int value) { + return IntToStringT<string16, unsigned int, unsigned int, false>:: + IntToString(value); +} + +std::string Int64ToString(int64 value) { + return IntToStringT<std::string, int64, uint64, true>:: + IntToString(value); +} + +string16 Int64ToString16(int64 value) { + return IntToStringT<string16, int64, uint64, true>::IntToString(value); +} + +std::string Uint64ToString(uint64 value) { + return IntToStringT<std::string, uint64, uint64, false>:: + IntToString(value); +} + +string16 Uint64ToString16(uint64 value) { + return IntToStringT<string16, uint64, uint64, false>:: + IntToString(value); +} + +std::string DoubleToString(double value) { + // According to g_fmt.cc, it is sufficient to declare a buffer of size 32. + char buffer[32]; + dmg_fp::g_fmt(buffer, value); + return std::string(buffer); +} + +bool StringToInt(const std::string& input, int* output) { + return StringToNumber<StringToIntTraits>(input, output); +} + +bool StringToInt(const string16& input, int* output) { + return StringToNumber<String16ToIntTraits>(input, output); +} + +bool StringToInt64(const std::string& input, int64* output) { + return StringToNumber<StringToInt64Traits>(input, output); +} + +bool StringToInt64(const string16& input, int64* output) { + return StringToNumber<String16ToInt64Traits>(input, output); +} + +bool StringToDouble(const std::string& input, double* output) { + return StringToNumber<StringToDoubleTraits>(input, output); +} + +// Note: if you need to add String16ToDouble, first ask yourself if it's +// really necessary. If it is, probably the best implementation here is to +// convert to 8-bit and then use the 8-bit version. + +std::string HexEncode(const void* bytes, size_t size) { + static const char kHexChars[] = "0123456789ABCDEF"; + + // Each input byte creates two output hex characters. + std::string ret(size * 2, '\0'); + + for (size_t i = 0; i < size; ++i) { + char b = reinterpret_cast<const char*>(bytes)[i]; + ret[(i * 2)] = kHexChars[(b >> 4) & 0xf]; + ret[(i * 2) + 1] = kHexChars[b & 0xf]; + } + return ret; +} + +bool HexStringToInt(const std::string& input, int* output) { + return StringToNumber<HexStringToIntTraits>(input, output); +} + +bool HexStringToBytes(const std::string& input, std::vector<uint8>* output) { + return HexStringToBytesT(input, output); +} + +} // namespace base diff --git a/base/string_number_conversions.h b/base/string_number_conversions.h new file mode 100644 index 0000000..928cb8a --- /dev/null +++ b/base/string_number_conversions.h @@ -0,0 +1,92 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef BASE_STRING_NUMBER_CONVERSIONS_H_ +#define BASE_STRING_NUMBER_CONVERSIONS_H_ + +#include <string> +#include <vector> + +#include "base/basictypes.h" +#include "base/string16.h" + +// ---------------------------------------------------------------------------- +// IMPORTANT MESSAGE FROM YOUR SPONSOR +// +// This file contains no "wstring" variants. New code should use string16. If +// you need to make old code work, use the UTF8 version and convert. Please do +// not add wstring variants. +// +// Please do not add "convenience" functions for converting strings to integers +// that return the value and ignore success/failure. That encourages people to +// write code that doesn't properly handle the error conditions. +// ---------------------------------------------------------------------------- + +namespace base { + +// Number -> string conversions ------------------------------------------------ + +std::string IntToString(int value); +string16 IntToString16(int value); + +std::string UintToString(unsigned value); +string16 UintToString16(unsigned value); + +std::string Int64ToString(int64 value); +string16 Int64ToString16(int64 value); + +std::string Uint64ToString(uint64 value); +string16 Uint64ToString16(uint64 value); + +// DoubleToString converts the double to a string format that ignores the +// locale. If you want to use locale specific formatting, use ICU. +std::string DoubleToString(double value); + +// String -> number conversions ------------------------------------------------ + +// Perform a best-effort conversion of the input string to a numeric type, +// setting |*output| to the result of the conversion. Returns true for +// "perfect" conversions; returns false in the following cases: +// - Overflow/underflow. |*output| will be set to the maximum value supported +// by the data type. +// - Trailing characters in the string after parsing the number. |*output| +// will be set to the value of the number that was parsed. +// - No characters parseable as a number at the beginning of the string. +// |*output| will be set to 0. +// - Empty string. |*output| will be set to 0. +bool StringToInt(const std::string& input, int* output); +bool StringToInt(const string16& input, int* output); +bool StringToInt64(const std::string& input, int64* output); +bool StringToInt64(const string16& input, int64* output); + +// For floating-point conversions, only conversions of input strings in decimal +// form are defined to work. Behavior with strings representing floating-point +// numbers in hexadecimal, and strings representing non-fininte values (such as +// NaN and inf) is undefined. Otherwise, these behave the same as the integral +// variants. This expects the input string to NOT be specific to the locale. +// If your input is locale specific, use ICU to read the number. +bool StringToDouble(const std::string& input, double* output); + +// Hex encoding ---------------------------------------------------------------- + +// Returns a hex string representation of a binary buffer. The returned hex +// string will be in upper case. This function does not check if |size| is +// within reasonable limits since it's written with trusted data in mind. If +// you suspect that the data you want to format might be large, the absolute +// max size for |size| should be is +// std::numeric_limits<size_t>::max() / 2 +std::string HexEncode(const void* bytes, size_t size); + +// Best effort conversion, see StringToInt above for restrictions. +bool HexStringToInt(const std::string& input, int* output); + +// Similar to the previous functions, except that output is a vector of bytes. +// |*output| will contain as many bytes as were successfully parsed prior to the +// error. There is no overflow, but input.size() must be evenly divisible by 2. +// Leading 0x or +/- are not allowed. +bool HexStringToBytes(const std::string& input, std::vector<uint8>* output); + +} // namespace base + +#endif // BASE_STRING_NUMBER_CONVERSIONS_H_ diff --git a/base/string_number_conversions_unittest.cc b/base/string_number_conversions_unittest.cc new file mode 100644 index 0000000..2d4747e --- /dev/null +++ b/base/string_number_conversions_unittest.cc @@ -0,0 +1,339 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include <limits> +#include <math.h> // For HUGE_VAL. + +#include "base/string_number_conversions.h" +#include "base/utf_string_conversions.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace base { + +namespace { + +template <typename INT> +struct IntToStringTest { + INT num; + const char* sexpected; + const char* uexpected; +}; + +} // namespace + +TEST(StringNumberConversionsTest, IntToString) { + static const IntToStringTest<int> int_tests[] = { + { 0, "0", "0" }, + { -1, "-1", "4294967295" }, + { std::numeric_limits<int>::max(), "2147483647", "2147483647" }, + { std::numeric_limits<int>::min(), "-2147483648", "2147483648" }, + }; + static const IntToStringTest<int64> int64_tests[] = { + { 0, "0", "0" }, + { -1, "-1", "18446744073709551615" }, + { std::numeric_limits<int64>::max(), + "9223372036854775807", + "9223372036854775807", }, + { std::numeric_limits<int64>::min(), + "-9223372036854775808", + "9223372036854775808" }, + }; + + for (size_t i = 0; i < arraysize(int_tests); ++i) { + const IntToStringTest<int>* test = &int_tests[i]; + EXPECT_EQ(IntToString(test->num), test->sexpected); + EXPECT_EQ(IntToString16(test->num), UTF8ToUTF16(test->sexpected)); + EXPECT_EQ(UintToString(test->num), test->uexpected); + EXPECT_EQ(UintToString16(test->num), UTF8ToUTF16(test->uexpected)); + } + for (size_t i = 0; i < arraysize(int64_tests); ++i) { + const IntToStringTest<int64>* test = &int64_tests[i]; + EXPECT_EQ(Int64ToString(test->num), test->sexpected); + EXPECT_EQ(Int64ToString16(test->num), UTF8ToUTF16(test->sexpected)); + EXPECT_EQ(Uint64ToString(test->num), test->uexpected); + EXPECT_EQ(Uint64ToString16(test->num), UTF8ToUTF16(test->uexpected)); + } +} + +TEST(StringNumberConversionsTest, Uint64ToString) { + static const struct { + uint64 input; + std::string output; + } cases[] = { + {0, "0"}, + {42, "42"}, + {INT_MAX, "2147483647"}, + {kuint64max, "18446744073709551615"}, + }; + + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) + EXPECT_EQ(cases[i].output, Uint64ToString(cases[i].input)); +} + +TEST(StringNumberConversionsTest, StringToInt) { + static const struct { + std::string input; + int output; + bool success; + } cases[] = { + {"0", 0, true}, + {"42", 42, true}, + {"-2147483648", INT_MIN, true}, + {"2147483647", INT_MAX, true}, + {"", 0, false}, + {" 42", 42, false}, + {"42 ", 42, false}, + {"\t\n\v\f\r 42", 42, false}, + {"blah42", 0, false}, + {"42blah", 42, false}, + {"blah42blah", 0, false}, + {"-273.15", -273, false}, + {"+98.6", 98, false}, + {"--123", 0, false}, + {"++123", 0, false}, + {"-+123", 0, false}, + {"+-123", 0, false}, + {"-", 0, false}, + {"-2147483649", INT_MIN, false}, + {"-99999999999", INT_MIN, false}, + {"2147483648", INT_MAX, false}, + {"99999999999", INT_MAX, false}, + }; + + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { + int output; + EXPECT_EQ(cases[i].success, StringToInt(cases[i].input, &output)); + EXPECT_EQ(cases[i].output, output); + + string16 utf16_input = UTF8ToUTF16(cases[i].input); + EXPECT_EQ(cases[i].success, StringToInt(utf16_input, &output)); + EXPECT_EQ(cases[i].output, output); + } + + // One additional test to verify that conversion of numbers in strings with + // embedded NUL characters. The NUL and extra data after it should be + // interpreted as junk after the number. + const char input[] = "6\06"; + std::string input_string(input, arraysize(input) - 1); + int output; + EXPECT_FALSE(StringToInt(input_string, &output)); + EXPECT_EQ(6, output); + + string16 utf16_input = UTF8ToUTF16(input_string); + EXPECT_FALSE(StringToInt(utf16_input, &output)); + EXPECT_EQ(6, output); +} + +TEST(StringNumberConversionsTest, StringToInt64) { + static const struct { + std::string input; + int64 output; + bool success; + } cases[] = { + {"0", 0, true}, + {"42", 42, true}, + {"-2147483648", INT_MIN, true}, + {"2147483647", INT_MAX, true}, + {"-2147483649", GG_INT64_C(-2147483649), true}, + {"-99999999999", GG_INT64_C(-99999999999), true}, + {"2147483648", GG_INT64_C(2147483648), true}, + {"99999999999", GG_INT64_C(99999999999), true}, + {"9223372036854775807", kint64max, true}, + {"-9223372036854775808", kint64min, true}, + {"09", 9, true}, + {"-09", -9, true}, + {"", 0, false}, + {" 42", 42, false}, + {"42 ", 42, false}, + {"\t\n\v\f\r 42", 42, false}, + {"blah42", 0, false}, + {"42blah", 42, false}, + {"blah42blah", 0, false}, + {"-273.15", -273, false}, + {"+98.6", 98, false}, + {"--123", 0, false}, + {"++123", 0, false}, + {"-+123", 0, false}, + {"+-123", 0, false}, + {"-", 0, false}, + {"-9223372036854775809", kint64min, false}, + {"-99999999999999999999", kint64min, false}, + {"9223372036854775808", kint64max, false}, + {"99999999999999999999", kint64max, false}, + }; + + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { + int64 output; + EXPECT_EQ(cases[i].success, StringToInt64(cases[i].input, &output)); + EXPECT_EQ(cases[i].output, output); + + string16 utf16_input = UTF8ToUTF16(cases[i].input); + EXPECT_EQ(cases[i].success, StringToInt64(utf16_input, &output)); + EXPECT_EQ(cases[i].output, output); + } + + // One additional test to verify that conversion of numbers in strings with + // embedded NUL characters. The NUL and extra data after it should be + // interpreted as junk after the number. + const char input[] = "6\06"; + std::string input_string(input, arraysize(input) - 1); + int64 output; + EXPECT_FALSE(StringToInt64(input_string, &output)); + EXPECT_EQ(6, output); + + string16 utf16_input = UTF8ToUTF16(input_string); + EXPECT_FALSE(StringToInt64(utf16_input, &output)); + EXPECT_EQ(6, output); +} + +TEST(StringNumberConversionsTest, HexStringToInt) { + static const struct { + std::string input; + int output; + bool success; + } cases[] = { + {"0", 0, true}, + {"42", 66, true}, + {"-42", -66, true}, + {"+42", 66, true}, + {"7fffffff", INT_MAX, true}, + {"80000000", INT_MIN, true}, + {"ffffffff", -1, true}, + {"DeadBeef", 0xdeadbeef, true}, + {"0x42", 66, true}, + {"-0x42", -66, true}, + {"+0x42", 66, true}, + {"0x7fffffff", INT_MAX, true}, + {"0x80000000", INT_MIN, true}, + {"0xffffffff", -1, true}, + {"0XDeadBeef", 0xdeadbeef, true}, + {"0x0f", 15, true}, + {"0f", 15, true}, + {" 45", 0x45, false}, + {"\t\n\v\f\r 0x45", 0x45, false}, + {" 45", 0x45, false}, + {"45 ", 0x45, false}, + {"efgh", 0xef, false}, + {"0xefgh", 0xef, false}, + {"hgfe", 0, false}, + {"100000000", -1, false}, // don't care about |output|, just |success| + {"-", 0, false}, + {"", 0, false}, + }; + + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { + int output; + EXPECT_EQ(cases[i].success, HexStringToInt(cases[i].input, &output)); + EXPECT_EQ(cases[i].output, output); + } + // One additional test to verify that conversion of numbers in strings with + // embedded NUL characters. The NUL and extra data after it should be + // interpreted as junk after the number. + const char input[] = "0xc0ffee\09"; + std::string input_string(input, arraysize(input) - 1); + int output; + EXPECT_FALSE(HexStringToInt(input_string, &output)); + EXPECT_EQ(0xc0ffee, output); +} + +TEST(StringNumberConversionsTest, HexStringToBytes) { + static const struct { + const std::string input; + const char* output; + size_t output_len; + bool success; + } cases[] = { + {"0", "", 0, false}, // odd number of characters fails + {"00", "\0", 1, true}, + {"42", "\x42", 1, true}, + {"-42", "", 0, false}, // any non-hex value fails + {"+42", "", 0, false}, + {"7fffffff", "\x7f\xff\xff\xff", 4, true}, + {"80000000", "\x80\0\0\0", 4, true}, + {"deadbeef", "\xde\xad\xbe\xef", 4, true}, + {"DeadBeef", "\xde\xad\xbe\xef", 4, true}, + {"0x42", "", 0, false}, // leading 0x fails (x is not hex) + {"0f", "\xf", 1, true}, + {"45 ", "\x45", 1, false}, + {"efgh", "\xef", 1, false}, + {"", "", 0, false}, + {"0123456789ABCDEF", "\x01\x23\x45\x67\x89\xAB\xCD\xEF", 8, true}, + {"0123456789ABCDEF012345", + "\x01\x23\x45\x67\x89\xAB\xCD\xEF\x01\x23\x45", 11, true}, + }; + + + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { + std::vector<uint8> output; + std::vector<uint8> compare; + EXPECT_EQ(cases[i].success, HexStringToBytes(cases[i].input, &output)) << + i << ": " << cases[i].input; + for (size_t j = 0; j < cases[i].output_len; ++j) + compare.push_back(static_cast<uint8>(cases[i].output[j])); + ASSERT_EQ(output.size(), compare.size()) << i << ": " << cases[i].input; + EXPECT_TRUE(std::equal(output.begin(), output.end(), compare.begin())) << + i << ": " << cases[i].input; + } +} + +TEST(StringNumberConversionsTest, StringToDouble) { + static const struct { + std::string input; + double output; + bool success; + } cases[] = { + {"0", 0.0, true}, + {"42", 42.0, true}, + {"-42", -42.0, true}, + {"123.45", 123.45, true}, + {"-123.45", -123.45, true}, + {"+123.45", 123.45, true}, + {"2.99792458e8", 299792458.0, true}, + {"149597870.691E+3", 149597870691.0, true}, + {"6.", 6.0, true}, + {"9e99999999999999999999", HUGE_VAL, false}, + {"-9e99999999999999999999", -HUGE_VAL, false}, + {"1e-2", 0.01, true}, + {" 1e-2", 0.01, false}, + {"1e-2 ", 0.01, false}, + {"-1E-7", -0.0000001, true}, + {"01e02", 100, true}, + {"2.3e15", 2.3e15, true}, + {"\t\n\v\f\r -123.45e2", -12345.0, false}, + {"+123 e4", 123.0, false}, + {"123e ", 123.0, false}, + {"123e", 123.0, false}, + {" 2.99", 2.99, false}, + {"1e3.4", 1000.0, false}, + {"nothing", 0.0, false}, + {"-", 0.0, false}, + {"+", 0.0, false}, + {"", 0.0, false}, + }; + + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { + double output; + EXPECT_EQ(cases[i].success, StringToDouble(cases[i].input, &output)); + EXPECT_DOUBLE_EQ(cases[i].output, output); + } + + // One additional test to verify that conversion of numbers in strings with + // embedded NUL characters. The NUL and extra data after it should be + // interpreted as junk after the number. + const char input[] = "3.14\0159"; + std::string input_string(input, arraysize(input) - 1); + double output; + EXPECT_FALSE(StringToDouble(input_string, &output)); + EXPECT_DOUBLE_EQ(3.14, output); +} + +TEST(StringNumberConversionsTest, HexEncode) { + std::string hex(HexEncode(NULL, 0)); + EXPECT_EQ(hex.length(), 0U); + unsigned char bytes[] = {0x01, 0xff, 0x02, 0xfe, 0x03, 0x80, 0x81}; + hex = HexEncode(bytes, sizeof(bytes)); + EXPECT_EQ(hex.compare("01FF02FE038081"), 0); +} + +} // namespace base
\ No newline at end of file diff --git a/base/string_util_unittest.cc b/base/string_util_unittest.cc index 7afc0bd..f063fcc 100644 --- a/base/string_util_unittest.cc +++ b/base/string_util_unittest.cc @@ -633,365 +633,6 @@ TEST(StringUtilTest, ReplaceFirstSubstringAfterOffset) { } } -namespace { - -template <typename INT> -struct IntToStringTest { - INT num; - const char* sexpected; - const char* uexpected; -}; - -} // namespace - -TEST(StringUtilTest, IntToString) { - static const IntToStringTest<int> int_tests[] = { - { 0, "0", "0" }, - { -1, "-1", "4294967295" }, - { std::numeric_limits<int>::max(), "2147483647", "2147483647" }, - { std::numeric_limits<int>::min(), "-2147483648", "2147483648" }, - }; - static const IntToStringTest<int64> int64_tests[] = { - { 0, "0", "0" }, - { -1, "-1", "18446744073709551615" }, - { std::numeric_limits<int64>::max(), - "9223372036854775807", - "9223372036854775807", }, - { std::numeric_limits<int64>::min(), - "-9223372036854775808", - "9223372036854775808" }, - }; - - for (size_t i = 0; i < arraysize(int_tests); ++i) { - const IntToStringTest<int>* test = &int_tests[i]; - EXPECT_EQ(IntToString(test->num), test->sexpected); - EXPECT_EQ(IntToWString(test->num), UTF8ToWide(test->sexpected)); - EXPECT_EQ(UintToString(test->num), test->uexpected); - EXPECT_EQ(UintToWString(test->num), UTF8ToWide(test->uexpected)); - } - for (size_t i = 0; i < arraysize(int64_tests); ++i) { - const IntToStringTest<int64>* test = &int64_tests[i]; - EXPECT_EQ(Int64ToString(test->num), test->sexpected); - EXPECT_EQ(Int64ToWString(test->num), UTF8ToWide(test->sexpected)); - EXPECT_EQ(Uint64ToString(test->num), test->uexpected); - EXPECT_EQ(Uint64ToWString(test->num), UTF8ToWide(test->uexpected)); - } -} - -TEST(StringUtilTest, Uint64ToString) { - static const struct { - uint64 input; - std::string output; - } cases[] = { - {0, "0"}, - {42, "42"}, - {INT_MAX, "2147483647"}, - {kuint64max, "18446744073709551615"}, - }; - - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) - EXPECT_EQ(cases[i].output, Uint64ToString(cases[i].input)); -} - -TEST(StringUtilTest, StringToInt) { - static const struct { - std::string input; - int output; - bool success; - } cases[] = { - {"0", 0, true}, - {"42", 42, true}, - {"-2147483648", INT_MIN, true}, - {"2147483647", INT_MAX, true}, - {"", 0, false}, - {" 42", 42, false}, - {"42 ", 42, false}, - {"\t\n\v\f\r 42", 42, false}, - {"blah42", 0, false}, - {"42blah", 42, false}, - {"blah42blah", 0, false}, - {"-273.15", -273, false}, - {"+98.6", 98, false}, - {"--123", 0, false}, - {"++123", 0, false}, - {"-+123", 0, false}, - {"+-123", 0, false}, - {"-", 0, false}, - {"-2147483649", INT_MIN, false}, - {"-99999999999", INT_MIN, false}, - {"2147483648", INT_MAX, false}, - {"99999999999", INT_MAX, false}, - }; - - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { - EXPECT_EQ(cases[i].output, StringToInt(cases[i].input)); - int output; - EXPECT_EQ(cases[i].success, StringToInt(cases[i].input, &output)); - EXPECT_EQ(cases[i].output, output); - - std::wstring wide_input = ASCIIToWide(cases[i].input); - EXPECT_EQ(cases[i].output, StringToInt(WideToUTF16Hack(wide_input))); - EXPECT_EQ(cases[i].success, StringToInt(WideToUTF16Hack(wide_input), - &output)); - EXPECT_EQ(cases[i].output, output); - } - - // One additional test to verify that conversion of numbers in strings with - // embedded NUL characters. The NUL and extra data after it should be - // interpreted as junk after the number. - const char input[] = "6\06"; - std::string input_string(input, arraysize(input) - 1); - int output; - EXPECT_FALSE(StringToInt(input_string, &output)); - EXPECT_EQ(6, output); - - std::wstring wide_input = ASCIIToWide(input_string); - EXPECT_FALSE(StringToInt(WideToUTF16Hack(wide_input), &output)); - EXPECT_EQ(6, output); -} - -TEST(StringUtilTest, StringToInt64) { - static const struct { - std::string input; - int64 output; - bool success; - } cases[] = { - {"0", 0, true}, - {"42", 42, true}, - {"-2147483648", INT_MIN, true}, - {"2147483647", INT_MAX, true}, - {"-2147483649", GG_INT64_C(-2147483649), true}, - {"-99999999999", GG_INT64_C(-99999999999), true}, - {"2147483648", GG_INT64_C(2147483648), true}, - {"99999999999", GG_INT64_C(99999999999), true}, - {"9223372036854775807", kint64max, true}, - {"-9223372036854775808", kint64min, true}, - {"09", 9, true}, - {"-09", -9, true}, - {"", 0, false}, - {" 42", 42, false}, - {"42 ", 42, false}, - {"\t\n\v\f\r 42", 42, false}, - {"blah42", 0, false}, - {"42blah", 42, false}, - {"blah42blah", 0, false}, - {"-273.15", -273, false}, - {"+98.6", 98, false}, - {"--123", 0, false}, - {"++123", 0, false}, - {"-+123", 0, false}, - {"+-123", 0, false}, - {"-", 0, false}, - {"-9223372036854775809", kint64min, false}, - {"-99999999999999999999", kint64min, false}, - {"9223372036854775808", kint64max, false}, - {"99999999999999999999", kint64max, false}, - }; - - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { - EXPECT_EQ(cases[i].output, StringToInt64(cases[i].input)); - int64 output; - EXPECT_EQ(cases[i].success, StringToInt64(cases[i].input, &output)); - EXPECT_EQ(cases[i].output, output); - - std::wstring wide_input = ASCIIToWide(cases[i].input); - EXPECT_EQ(cases[i].output, StringToInt64(WideToUTF16Hack(wide_input))); - EXPECT_EQ(cases[i].success, StringToInt64(WideToUTF16Hack(wide_input), - &output)); - EXPECT_EQ(cases[i].output, output); - } - - // One additional test to verify that conversion of numbers in strings with - // embedded NUL characters. The NUL and extra data after it should be - // interpreted as junk after the number. - const char input[] = "6\06"; - std::string input_string(input, arraysize(input) - 1); - int64 output; - EXPECT_FALSE(StringToInt64(input_string, &output)); - EXPECT_EQ(6, output); - - std::wstring wide_input = ASCIIToWide(input_string); - EXPECT_FALSE(StringToInt64(WideToUTF16Hack(wide_input), &output)); - EXPECT_EQ(6, output); -} - -TEST(StringUtilTest, HexStringToInt) { - static const struct { - std::string input; - int output; - bool success; - } cases[] = { - {"0", 0, true}, - {"42", 66, true}, - {"-42", -66, true}, - {"+42", 66, true}, - {"7fffffff", INT_MAX, true}, - {"80000000", INT_MIN, true}, - {"ffffffff", -1, true}, - {"DeadBeef", 0xdeadbeef, true}, - {"0x42", 66, true}, - {"-0x42", -66, true}, - {"+0x42", 66, true}, - {"0x7fffffff", INT_MAX, true}, - {"0x80000000", INT_MIN, true}, - {"0xffffffff", -1, true}, - {"0XDeadBeef", 0xdeadbeef, true}, - {"0x0f", 15, true}, - {"0f", 15, true}, - {" 45", 0x45, false}, - {"\t\n\v\f\r 0x45", 0x45, false}, - {" 45", 0x45, false}, - {"45 ", 0x45, false}, - {"efgh", 0xef, false}, - {"0xefgh", 0xef, false}, - {"hgfe", 0, false}, - {"100000000", -1, false}, // don't care about |output|, just |success| - {"-", 0, false}, - {"", 0, false}, - }; - - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { - EXPECT_EQ(cases[i].output, HexStringToInt(cases[i].input)); - int output; - EXPECT_EQ(cases[i].success, HexStringToInt(cases[i].input, &output)); - EXPECT_EQ(cases[i].output, output); - - std::wstring wide_input = ASCIIToWide(cases[i].input); - EXPECT_EQ(cases[i].output, HexStringToInt(WideToUTF16Hack(wide_input))); - EXPECT_EQ(cases[i].success, HexStringToInt(WideToUTF16Hack(wide_input), - &output)); - EXPECT_EQ(cases[i].output, output); - } - // One additional test to verify that conversion of numbers in strings with - // embedded NUL characters. The NUL and extra data after it should be - // interpreted as junk after the number. - const char input[] = "0xc0ffee\09"; - std::string input_string(input, arraysize(input) - 1); - int output; - EXPECT_FALSE(HexStringToInt(input_string, &output)); - EXPECT_EQ(0xc0ffee, output); - - std::wstring wide_input = ASCIIToWide(input_string); - EXPECT_FALSE(HexStringToInt(WideToUTF16Hack(wide_input), &output)); - EXPECT_EQ(0xc0ffee, output); -} - -TEST(StringUtilTest, HexStringToBytes) { - static const struct { - const std::string input; - const char* output; - size_t output_len; - bool success; - } cases[] = { - {"0", "", 0, false}, // odd number of characters fails - {"00", "\0", 1, true}, - {"42", "\x42", 1, true}, - {"-42", "", 0, false}, // any non-hex value fails - {"+42", "", 0, false}, - {"7fffffff", "\x7f\xff\xff\xff", 4, true}, - {"80000000", "\x80\0\0\0", 4, true}, - {"deadbeef", "\xde\xad\xbe\xef", 4, true}, - {"DeadBeef", "\xde\xad\xbe\xef", 4, true}, - {"0x42", "", 0, false}, // leading 0x fails (x is not hex) - {"0f", "\xf", 1, true}, - {"45 ", "\x45", 1, false}, - {"efgh", "\xef", 1, false}, - {"", "", 0, false}, - {"0123456789ABCDEF", "\x01\x23\x45\x67\x89\xAB\xCD\xEF", 8, true}, - {"0123456789ABCDEF012345", - "\x01\x23\x45\x67\x89\xAB\xCD\xEF\x01\x23\x45", 11, true}, - }; - - - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { - std::vector<uint8> output; - std::vector<uint8> compare; - EXPECT_EQ(cases[i].success, HexStringToBytes(cases[i].input, &output)) << - i << ": " << cases[i].input; - for (size_t j = 0; j < cases[i].output_len; ++j) - compare.push_back(static_cast<uint8>(cases[i].output[j])); - ASSERT_EQ(output.size(), compare.size()) << i << ": " << cases[i].input; - EXPECT_TRUE(std::equal(output.begin(), output.end(), compare.begin())) << - i << ": " << cases[i].input; - - output.clear(); - compare.clear(); - - std::wstring wide_input = ASCIIToWide(cases[i].input); - EXPECT_EQ(cases[i].success, - HexStringToBytes(WideToUTF16Hack(wide_input), &output)) << - i << ": " << cases[i].input; - for (size_t j = 0; j < cases[i].output_len; ++j) - compare.push_back(static_cast<uint8>(cases[i].output[j])); - ASSERT_EQ(output.size(), compare.size()) << i << ": " << cases[i].input; - EXPECT_TRUE(std::equal(output.begin(), output.end(), compare.begin())) << - i << ": " << cases[i].input; - } -} - -TEST(StringUtilTest, StringToDouble) { - static const struct { - std::string input; - double output; - bool success; - } cases[] = { - {"0", 0.0, true}, - {"42", 42.0, true}, - {"-42", -42.0, true}, - {"123.45", 123.45, true}, - {"-123.45", -123.45, true}, - {"+123.45", 123.45, true}, - {"2.99792458e8", 299792458.0, true}, - {"149597870.691E+3", 149597870691.0, true}, - {"6.", 6.0, true}, - {"9e99999999999999999999", HUGE_VAL, false}, - {"-9e99999999999999999999", -HUGE_VAL, false}, - {"1e-2", 0.01, true}, - {" 1e-2", 0.01, false}, - {"1e-2 ", 0.01, false}, - {"-1E-7", -0.0000001, true}, - {"01e02", 100, true}, - {"2.3e15", 2.3e15, true}, - {"\t\n\v\f\r -123.45e2", -12345.0, false}, - {"+123 e4", 123.0, false}, - {"123e ", 123.0, false}, - {"123e", 123.0, false}, - {" 2.99", 2.99, false}, - {"1e3.4", 1000.0, false}, - {"nothing", 0.0, false}, - {"-", 0.0, false}, - {"+", 0.0, false}, - {"", 0.0, false}, - }; - - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { - EXPECT_DOUBLE_EQ(cases[i].output, StringToDouble(cases[i].input)); - double output; - EXPECT_EQ(cases[i].success, StringToDouble(cases[i].input, &output)); - EXPECT_DOUBLE_EQ(cases[i].output, output); - - std::wstring wide_input = ASCIIToWide(cases[i].input); - EXPECT_DOUBLE_EQ(cases[i].output, - StringToDouble(WideToUTF16Hack(wide_input))); - EXPECT_EQ(cases[i].success, StringToDouble(WideToUTF16Hack(wide_input), - &output)); - EXPECT_DOUBLE_EQ(cases[i].output, output); - } - - // One additional test to verify that conversion of numbers in strings with - // embedded NUL characters. The NUL and extra data after it should be - // interpreted as junk after the number. - const char input[] = "3.14\0159"; - std::string input_string(input, arraysize(input) - 1); - double output; - EXPECT_FALSE(StringToDouble(input_string, &output)); - EXPECT_DOUBLE_EQ(3.14, output); - - std::wstring wide_input = ASCIIToWide(input_string); - EXPECT_FALSE(StringToDouble(WideToUTF16Hack(wide_input), &output)); - EXPECT_DOUBLE_EQ(3.14, output); -} - // This checks where we can use the assignment operator for a va_list. We need // a way to do this since Visual C doesn't support va_copy, but assignment on // va_list is not guaranteed to be a copy. See StringAppendVT which uses this @@ -1655,14 +1296,6 @@ TEST(StringUtilTest, ElideString) { } } -TEST(StringUtilTest, HexEncode) { - std::string hex(HexEncode(NULL, 0)); - EXPECT_EQ(hex.length(), 0U); - unsigned char bytes[] = {0x01, 0xff, 0x02, 0xfe, 0x03, 0x80, 0x81}; - hex = HexEncode(bytes, sizeof(bytes)); - EXPECT_EQ(hex.compare("01FF02FE038081"), 0); -} - TEST(StringUtilTest, RemoveChars) { const char* kRemoveChars = "-/+*"; std::string input = "A-+bc/d!*"; diff --git a/base/version.cc b/base/version.cc index 2271fcf..c784082 100644 --- a/base/version.cc +++ b/base/version.cc @@ -5,13 +5,15 @@ #include "base/version.h" #include "base/logging.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" +#include "base/utf_string_conversions.h" // static Version* Version::GetVersionFromString(const std::wstring& version_str) { if (!IsStringASCII(version_str)) return NULL; - return GetVersionFromString(WideToASCII(version_str)); + return GetVersionFromString(WideToUTF8(version_str)); } // static @@ -60,10 +62,10 @@ const std::string Version::GetString() const { std::string version_str; int count = components_.size(); for (int i = 0; i < count - 1; ++i) { - version_str.append(IntToString(components_[i])); + version_str.append(base::IntToString(components_[i])); version_str.append("."); } - version_str.append(IntToString(components_[count - 1])); + version_str.append(base::IntToString(components_[count - 1])); return version_str; } @@ -76,7 +78,7 @@ bool Version::InitFromString(const std::string& version_str) { for (std::vector<std::string>::iterator i = numbers.begin(); i != numbers.end(); ++i) { int num; - if (!StringToInt(*i, &num)) + if (!base::StringToInt(*i, &num)) return false; if (num < 0) return false; @@ -84,7 +86,7 @@ bool Version::InitFromString(const std::string& version_str) { if (num > max) return false; // This throws out things like +3, or 032. - if (IntToString(num) != *i) + if (base::IntToString(num) != *i) return false; uint16 component = static_cast<uint16>(num); components_.push_back(component); diff --git a/chrome/app/chrome_dll_main.cc b/chrome/app/chrome_dll_main.cc index 7018b16..a3c1cbb 100644 --- a/chrome/app/chrome_dll_main.cc +++ b/chrome/app/chrome_dll_main.cc @@ -46,6 +46,7 @@ #include "base/scoped_nsautorelease_pool.h" #include "base/stats_counters.h" #include "base/stats_table.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "chrome/browser/diagnostics/diagnostics_main.h" @@ -583,8 +584,9 @@ int ChromeMain(int argc, char** argv) { std::wstring channel_name = parsed_command_line.GetSwitchValue(switches::kProcessChannelID); - browser_pid = - static_cast<base::ProcessId>(StringToInt(WideToASCII(channel_name))); + int browser_pid_int; + base::StringToInt(WideToUTF8(channel_name), &browser_pid_int); + browser_pid = static_cast<base::ProcessId>(browser_pid_int); DCHECK_NE(browser_pid, 0u); #elif defined(OS_MACOSX) browser_pid = base::GetCurrentProcId(); diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm index 4789204..7a219d7 100644 --- a/chrome/browser/app_controller_mac.mm +++ b/chrome/browser/app_controller_mac.mm @@ -9,6 +9,7 @@ #include "base/command_line.h" #include "base/mac_util.h" #include "base/message_loop.h" +#include "base/string_number_conversions.h" #include "base/sys_string_conversions.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/browser.h" @@ -532,7 +533,7 @@ void RecordLastRunAppBundlePath() { // Dialog text: warning and explanation. warningText = l10n_util::GetNSStringF( IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_WARNING, product_name, - IntToString16(downloadCount)); + base::IntToString16(downloadCount)); explanationText = l10n_util::GetNSStringF( IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_EXPLANATION, product_name); diff --git a/chrome/browser/autofill/auto_fill_editor_gtk.cc b/chrome/browser/autofill/auto_fill_editor_gtk.cc index c6fab96..f3d0e9f 100644 --- a/chrome/browser/autofill/auto_fill_editor_gtk.cc +++ b/chrome/browser/autofill/auto_fill_editor_gtk.cc @@ -13,6 +13,7 @@ #include "base/string_util.h" #include "base/task.h" #include "base/time.h" +#include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "chrome/browser/autofill/personal_data_manager.h" #include "chrome/browser/autofill/phone_number.h" @@ -887,14 +888,14 @@ void AutoFillCreditCardEditor::SetCreditCardValuesFromWidgets( if (selected_month_index == -1) selected_month_index = 0; card->SetInfo(AutoFillType(CREDIT_CARD_EXP_MONTH), - IntToString16(selected_month_index + 1)); + base::IntToString16(selected_month_index + 1)); int selected_year_index = gtk_combo_box_get_active(GTK_COMBO_BOX(year_)); if (selected_year_index == -1) selected_year_index = 0; card->SetInfo(AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR), - IntToString16(selected_year_index + base_year_)); + base::IntToString16(selected_year_index + base_year_)); } void AutoFillCreditCardEditor::UpdateOkButton() { diff --git a/chrome/browser/autofill/credit_card.cc b/chrome/browser/autofill/credit_card.cc index 7f3e521..e6e06cb 100644 --- a/chrome/browser/autofill/credit_card.cc +++ b/chrome/browser/autofill/credit_card.cc @@ -9,6 +9,7 @@ #include "app/l10n_util.h" #include "base/basictypes.h" #include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/string16.h" #include "base/utf_string_conversions.h" #include "chrome/browser/autofill/autofill_type.h" @@ -62,7 +63,7 @@ std::string GetCreditCardType(string16 number) { return kGenericCard; int first_four_digits = 0; - if (!StringToInt(number.substr(0, 4), &first_four_digits)) + if (!base::StringToInt(number.substr(0, 4), &first_four_digits)) return kGenericCard; int first_three_digits = first_four_digits / 10; @@ -438,7 +439,7 @@ string16 CreditCard::ExpirationMonthAsString() const { if (expiration_month_ == 0) return string16(); - string16 month = IntToString16(expiration_month_); + string16 month = base::IntToString16(expiration_month_); if (expiration_month_ >= 10) return month; @@ -451,14 +452,14 @@ string16 CreditCard::Expiration4DigitYearAsString() const { if (expiration_year_ == 0) return string16(); - return IntToString16(Expiration4DigitYear()); + return base::IntToString16(Expiration4DigitYear()); } string16 CreditCard::Expiration2DigitYearAsString() const { if (expiration_year_ == 0) return string16(); - return IntToString16(Expiration2DigitYear()); + return base::IntToString16(Expiration2DigitYear()); } void CreditCard::SetExpirationMonthFromString(const string16& text) { @@ -563,7 +564,7 @@ bool CreditCard::IsNameOnCard(const string16& text) const { bool CreditCard::IsExpirationMonth(const string16& text) const { int month; - if (!StringToInt(text, &month)) + if (!base::StringToInt(text, &month)) return false; return expiration_month_ == month; @@ -571,7 +572,7 @@ bool CreditCard::IsExpirationMonth(const string16& text) const { bool CreditCard::Is2DigitExpirationYear(const string16& text) const { int year; - if (!StringToInt(text, &year)) + if (!base::StringToInt(text, &year)) return false; return year < 100 && (expiration_year_ % 100) == year; @@ -579,7 +580,7 @@ bool CreditCard::Is2DigitExpirationYear(const string16& text) const { bool CreditCard::Is4DigitExpirationYear(const string16& text) const { int year; - if (!StringToInt(text, &year)) + if (!base::StringToInt(text, &year)) return false; return expiration_year_ == year; @@ -587,7 +588,7 @@ bool CreditCard::Is4DigitExpirationYear(const string16& text) const { bool CreditCard::ConvertDate(const string16& date, int* num) const { if (!date.empty()) { - bool converted = StringToInt(date, num); + bool converted = base::StringToInt(date, num); DCHECK(converted); if (!converted) return false; diff --git a/chrome/browser/autofill/form_structure.cc b/chrome/browser/autofill/form_structure.cc index e207aef..92df538 100644 --- a/chrome/browser/autofill/form_structure.cc +++ b/chrome/browser/autofill/form_structure.cc @@ -7,7 +7,7 @@ #include "base/basictypes.h" #include "base/logging.h" #include "base/sha1.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "chrome/browser/autofill/autofill_xml_parser.h" #include "chrome/browser/autofill/field_types.h" @@ -82,7 +82,8 @@ FormStructure::FormStructure(const FormData& form) } // Generate a unique name for this field by appending a counter to the name. - string16 unique_name = field->name() + IntToString16(fields_.size() + 1); + string16 unique_name = field->name() + + base::IntToString16(fields_.size() + 1); fields_.push_back(new AutoFillField(*field, unique_name)); } diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index f635916..9ee12d8 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -21,6 +21,7 @@ #include "base/string_util.h" #include "base/task.h" #include "base/thread.h" +#include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "base/values.h" #include "base/waitable_event.h" @@ -4334,7 +4335,7 @@ void AutomationProvider::GetExtensionProperty( } index++; } - *value = IntToString(found_index); + *value = base::IntToString(found_index); *success = true; } break; diff --git a/chrome/browser/back_forward_menu_model.cc b/chrome/browser/back_forward_menu_model.cc index 5a164e7..fb18da8 100644 --- a/chrome/browser/back_forward_menu_model.cc +++ b/chrome/browser/back_forward_menu_model.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -8,6 +8,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" +#include "base/string_number_conversions.h" #include "chrome/browser/browser.h" #include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/tab_contents/navigation_controller.h" @@ -368,7 +369,7 @@ std::string BackForwardMenuModel::BuildActionName( metric_string += action; if (index != -1) { // +1 is for historical reasons (indices used to start at 1). - metric_string += IntToString(index + 1); + metric_string += base::IntToString(index + 1); } return metric_string; } diff --git a/chrome/browser/bookmarks/bookmark_codec.cc b/chrome/browser/bookmarks/bookmark_codec.cc index e64c365..a56636a 100644 --- a/chrome/browser/bookmarks/bookmark_codec.cc +++ b/chrome/browser/bookmarks/bookmark_codec.cc @@ -7,6 +7,7 @@ #include <algorithm> #include "app/l10n_util.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/values.h" #include "chrome/browser/bookmarks/bookmark_model.h" @@ -84,12 +85,12 @@ bool BookmarkCodec::Decode(BookmarkNode* bb_node, Value* BookmarkCodec::EncodeNode(const BookmarkNode* node) { DictionaryValue* value = new DictionaryValue(); - std::string id = Int64ToString(node->id()); + std::string id = base::Int64ToString(node->id()); value->SetString(kIdKey, id); const string16& title = node->GetTitleAsString16(); value->SetStringFromUTF16(kNameKey, title); value->SetString(kDateAddedKey, - Int64ToString(node->date_added().ToInternalValue())); + base::Int64ToString(node->date_added().ToInternalValue())); if (node->type() == BookmarkNode::URL) { value->SetString(kTypeKey, kTypeURL); std::string url = node->GetURL().possibly_invalid_spec(); @@ -98,7 +99,7 @@ Value* BookmarkCodec::EncodeNode(const BookmarkNode* node) { } else { value->SetString(kTypeKey, kTypeFolder); value->SetString(kDateModifiedKey, - Int64ToString(node->date_group_modified(). + base::Int64ToString(node->date_group_modified(). ToInternalValue())); UpdateChecksumWithFolderNode(id, title); @@ -207,7 +208,7 @@ bool BookmarkCodec::DecodeNode(const DictionaryValue& value, std::string date_added_string; if (!value.GetString(kDateAddedKey, &date_added_string)) - date_added_string = Int64ToString(Time::Now().ToInternalValue()); + date_added_string = base::Int64ToString(Time::Now().ToInternalValue()); base::Time date_added = base::Time::FromInternalValue( StringToInt64(date_added_string)); #if !defined(OS_WIN) @@ -249,7 +250,7 @@ bool BookmarkCodec::DecodeNode(const DictionaryValue& value, } else { std::string last_modified_date; if (!value.GetString(kDateModifiedKey, &last_modified_date)) - last_modified_date = Int64ToString(Time::Now().ToInternalValue()); + last_modified_date = base::Int64ToString(Time::Now().ToInternalValue()); Value* child_values; if (!value.Get(kChildrenKey, &child_values)) diff --git a/chrome/browser/bookmarks/bookmark_html_writer.cc b/chrome/browser/bookmarks/bookmark_html_writer.cc index d3df9b4..24646f7 100644 --- a/chrome/browser/bookmarks/bookmark_html_writer.cc +++ b/chrome/browser/bookmarks/bookmark_html_writer.cc @@ -11,7 +11,7 @@ #include "base/message_loop.h" #include "base/platform_file.h" #include "base/scoped_ptr.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/time.h" #include "chrome/browser/bookmarks/bookmark_codec.h" #include "chrome/browser/bookmarks/bookmark_model.h" @@ -218,9 +218,10 @@ class Writer : public Task { // Converts a time string written to the JSON codec into a time_t string // (used by bookmarks.html) and writes it. bool WriteTime(const std::string& time_string) { - base::Time time = base::Time::FromInternalValue( - StringToInt64(time_string)); - return Write(Int64ToString(time.ToTimeT())); + int64 internal_value; + base::StringToInt64(time_string, &internal_value); + return Write(base::Int64ToString( + base::Time::FromInternalValue(internal_value).ToTimeT())); } // Writes the node and all its children, returning true on success. diff --git a/chrome/browser/bookmarks/bookmark_utils.cc b/chrome/browser/bookmarks/bookmark_utils.cc index 8003ea5..753c38c 100644 --- a/chrome/browser/bookmarks/bookmark_utils.cc +++ b/chrome/browser/bookmarks/bookmark_utils.cc @@ -9,7 +9,7 @@ #include "app/tree_node_iterator.h" #include "base/basictypes.h" #include "base/file_path.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/string16.h" #include "base/time.h" #include "chrome/browser/bookmarks/bookmark_drag_data.h" @@ -165,7 +165,7 @@ bool ShouldOpenAll(gfx::NativeWindow parent, string16 message = l10n_util::GetStringFUTF16( IDS_BOOKMARK_BAR_SHOULD_OPEN_ALL, - IntToString16(descendant_count)); + base::IntToString16(descendant_count)); string16 title = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); return platform_util::SimpleYesNoBox(parent, title, message); } diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc index bc7024b..2a0eae5 100644 --- a/chrome/browser/browser_about_handler.cc +++ b/chrome/browser/browser_about_handler.cc @@ -18,6 +18,7 @@ #include "base/path_service.h" #include "base/platform_thread.h" #include "base/stats_table.h" +#include "base/string_number_conversions.h" #include "base/string_piece.h" #include "base/string_util.h" #include "base/thread.h" @@ -996,11 +997,14 @@ void AboutMemoryHandler::OnDetailsAvailable() { log_string.append(L", "); log_string.append(browser_processes[index].name); log_string.append(L", "); - log_string.append(Int64ToWString(aggregate.working_set.priv)); + log_string.append(UTF8ToWide( + base::Int64ToString(aggregate.working_set.priv))); log_string.append(L", "); - log_string.append(Int64ToWString(aggregate.working_set.shared)); + log_string.append(UTF8ToWide( + base::Int64ToString(aggregate.working_set.shared))); log_string.append(L", "); - log_string.append(Int64ToWString(aggregate.working_set.shareable)); + log_string.append(UTF8ToWide( + base::Int64ToString(aggregate.working_set.shareable))); } if (log_string.length() > 0) LOG(INFO) << "memory: " << log_string; diff --git a/chrome/browser/browser_shutdown.cc b/chrome/browser/browser_shutdown.cc index 99f3c69..3e961c3 100644 --- a/chrome/browser/browser_shutdown.cc +++ b/chrome/browser/browser_shutdown.cc @@ -13,6 +13,7 @@ #include "base/histogram.h" #include "base/path_service.h" #include "base/process_util.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/thread.h" #include "base/time.h" @@ -208,7 +209,8 @@ void Shutdown() { // and then write it to a file to be read at startup. // We can't use prefs since all services are shutdown at this point. TimeDelta shutdown_delta = Time::Now() - shutdown_started_; - std::string shutdown_ms = Int64ToString(shutdown_delta.InMilliseconds()); + std::string shutdown_ms = + base::Int64ToString(shutdown_delta.InMilliseconds()); int len = static_cast<int>(shutdown_ms.length()) + 1; FilePath shutdown_ms_file = GetShutdownMsPath(); file_util::WriteFile(shutdown_ms_file, shutdown_ms.c_str(), len); diff --git a/chrome/browser/chromeos/cros/network_library.cc b/chrome/browser/chromeos/cros/network_library.cc index b688231..ba16587 100644 --- a/chrome/browser/chromeos/cros/network_library.cc +++ b/chrome/browser/chromeos/cros/network_library.cc @@ -6,6 +6,7 @@ #include <algorithm> +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "chrome/browser/chrome_thread.h" @@ -530,12 +531,14 @@ std::string NetworkLibraryImpl::GetHtmlInfo(int refresh) { output.append("<html><head><title>About Network</title>"); if (refresh > 0) output.append("<meta http-equiv=\"refresh\" content=\"" + - IntToString(refresh) + "\"/>"); + base::IntToString(refresh) + "\"/>"); output.append("</head><body>"); - if (refresh > 0) - output.append("(Auto-refreshing page every " + IntToString(refresh) + "s)"); - else + if (refresh > 0) { + output.append("(Auto-refreshing page every " + + base::IntToString(refresh) + "s)"); + } else { output.append("(To auto-refresh this page: about:network/<secs>)"); + } output.append("<h3>Ethernet:</h3><table border=1>"); output.append("<tr>" + ToHtmlTableHeader(ðernet_) + "</tr>"); diff --git a/chrome/browser/chromeos/status/power_menu_button.cc b/chrome/browser/chromeos/status/power_menu_button.cc index de10159..d5d91e5 100644 --- a/chrome/browser/chromeos/status/power_menu_button.cc +++ b/chrome/browser/chromeos/status/power_menu_button.cc @@ -6,6 +6,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" +#include "base/string_number_conversions.h" #include "base/time.h" #include "chrome/browser/chromeos/cros/cros_library.h" #include "gfx/canvas.h" @@ -51,7 +52,7 @@ string16 PowerMenuButton::GetLabelAt(int index) const { double percent = cros->battery_fully_charged() ? 100 : cros->battery_percentage(); return l10n_util::GetStringFUTF16(IDS_STATUSBAR_BATTERY_PERCENTAGE, - IntToString16(static_cast<int>(percent))); + base::IntToString16(static_cast<int>(percent))); } // The second item shows the battery is charged if it is. @@ -77,8 +78,8 @@ string16 PowerMenuButton::GetLabelAt(int index) const { IDS_STATUSBAR_BATTERY_TIME_UNTIL_EMPTY; int hour = time.InHours(); int min = (time - base::TimeDelta::FromHours(hour)).InMinutes(); - string16 hour_str = IntToString16(hour); - string16 min_str = IntToString16(min); + string16 hour_str = base::IntToString16(hour); + string16 min_str = base::IntToString16(min); // Append a "0" before the minute if it's only a single digit. if (min < 10) min_str = ASCIIToUTF16("0") + min_str; diff --git a/chrome/browser/chromeos/update_observer.cc b/chrome/browser/chromeos/update_observer.cc index b73fd0a..1765a8a 100644 --- a/chrome/browser/chromeos/update_observer.cc +++ b/chrome/browser/chromeos/update_observer.cc @@ -5,7 +5,7 @@ #include "chrome/browser/chromeos/update_observer.h" #include "app/l10n_util.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "chrome/common/time_format.h" #include "grit/generated_resources.h" @@ -41,7 +41,7 @@ void UpdateObserver::UpdateStatusChanged(UpdateLibrary* library) { if (progress != progress_) { progress_ = progress; notification_.Show(l10n_util::GetStringFUTF16(IDS_UPDATE_DOWNLOADING, - IntToString16(progress_)), false); + base::IntToString16(progress_)), false); } } break; diff --git a/chrome/browser/cocoa/about_window_controller.mm b/chrome/browser/cocoa/about_window_controller.mm index 0b24762..1dcb37a 100644 --- a/chrome/browser/cocoa/about_window_controller.mm +++ b/chrome/browser/cocoa/about_window_controller.mm @@ -8,6 +8,7 @@ #include "app/resource_bundle.h" #include "base/logging.h" #include "base/mac_util.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/sys_string_conversions.h" #include "chrome/browser/browser_list.h" @@ -452,7 +453,7 @@ static BOOL recentShownUserActionFailedStatus = NO; // just to get the throbber to stop spinning if it's running. imageID = IDR_UPDATE_FAIL; message = l10n_util::GetNSStringFWithFixup(IDS_UPGRADE_ERROR, - IntToString16(status)); + base::IntToString16(status)); break; @@ -550,14 +551,14 @@ static BOOL recentShownUserActionFailedStatus = NO; // just to get the throbber to stop spinning if it's running. imageID = IDR_UPDATE_FAIL; message = l10n_util::GetNSStringFWithFixup(IDS_UPGRADE_ERROR, - IntToString16(status)); + base::IntToString16(status)); break; case kAutoupdateRegisterFailed: imageID = IDR_UPDATE_FAIL; message = l10n_util::GetNSStringFWithFixup(IDS_UPGRADE_ERROR, - IntToString16(status)); + base::IntToString16(status)); enablePromoteButton = false; break; @@ -565,7 +566,7 @@ static BOOL recentShownUserActionFailedStatus = NO; case kAutoupdateCheckFailed: imageID = IDR_UPDATE_FAIL; message = l10n_util::GetNSStringFWithFixup(IDS_UPGRADE_ERROR, - IntToString16(status)); + base::IntToString16(status)); break; @@ -574,7 +575,7 @@ static BOOL recentShownUserActionFailedStatus = NO; imageID = IDR_UPDATE_FAIL; message = l10n_util::GetNSStringFWithFixup(IDS_UPGRADE_ERROR, - IntToString16(status)); + base::IntToString16(status)); // Allow another chance. enableUpdateButton = true; @@ -586,7 +587,7 @@ static BOOL recentShownUserActionFailedStatus = NO; imageID = IDR_UPDATE_FAIL; message = l10n_util::GetNSStringFWithFixup(IDS_UPGRADE_ERROR, - IntToString16(status)); + base::IntToString16(status)); break; diff --git a/chrome/browser/cocoa/history_menu_bridge.mm b/chrome/browser/cocoa/history_menu_bridge.mm index 7795bf7..d75043e 100644 --- a/chrome/browser/cocoa/history_menu_bridge.mm +++ b/chrome/browser/cocoa/history_menu_bridge.mm @@ -8,6 +8,7 @@ #include "app/resource_bundle.h" #include "base/callback.h" #include "base/stl_util-inl.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/sys_string_conversions.h" #include "chrome/app/chrome_dll_resource.h" // IDC_HISTORY_MENU @@ -207,7 +208,7 @@ void HistoryMenuBridge::TabRestoreServiceChanged(TabRestoreService* service) { } else { item->title =l10n_util::GetStringFUTF16( IDS_NEW_TAB_RECENTLY_CLOSED_WINDOW_MULTIPLE, - IntToString16(item->tabs.size())); + base::IntToString16(item->tabs.size())); } // Sometimes it is possible for there to not be any subitems for a given diff --git a/chrome/browser/cocoa/page_info_window_mac_unittest.mm b/chrome/browser/cocoa/page_info_window_mac_unittest.mm index ab9fdbe..2bbaf24 100644 --- a/chrome/browser/cocoa/page_info_window_mac_unittest.mm +++ b/chrome/browser/cocoa/page_info_window_mac_unittest.mm @@ -5,6 +5,7 @@ #include "app/l10n_util.h" #include "base/scoped_nsobject.h" #include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/sys_string_conversions.h" #import "chrome/browser/cocoa/page_info_window_mac.h" #import "chrome/browser/cocoa/page_info_window_controller.h" @@ -170,7 +171,7 @@ TEST_F(PageInfoWindowMacTest, NoHistoryMixedSecurity) { l10n_util::GetStringFUTF16( IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, ASCIIToUTF16("chrome.google.com"), - IntToString16(1024)), + base::IntToString16(1024)), l10n_util::GetStringUTF16( IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING))); diff --git a/chrome/browser/config_dir_policy_provider_unittest.cc b/chrome/browser/config_dir_policy_provider_unittest.cc index c992ff3..14dad65 100644 --- a/chrome/browser/config_dir_policy_provider_unittest.cc +++ b/chrome/browser/config_dir_policy_provider_unittest.cc @@ -4,7 +4,7 @@ #include "base/file_util.h" #include "base/path_service.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "chrome/browser/config_dir_policy_provider.h" #include "chrome/browser/mock_configuration_policy_store.h" #include "chrome/common/json_value_serializer.h" @@ -93,12 +93,12 @@ TEST_F(ConfigDirPolicyProviderTest, ReadPrefsMergePrefs) { DictionaryValue test_dict_bar; test_dict_bar.SetString(L"HomepageLocation", L"http://bar.com"); for (unsigned int i = 1; i <= 4; ++i) - WriteConfigFile(test_dict_bar, IntToString(i)); + WriteConfigFile(test_dict_bar, base::IntToString(i)); DictionaryValue test_dict_foo; test_dict_foo.SetString(L"HomepageLocation", L"http://foo.com"); WriteConfigFile(test_dict_foo, "9"); for (unsigned int i = 5; i <= 8; ++i) - WriteConfigFile(test_dict_bar, IntToString(i)); + WriteConfigFile(test_dict_bar, base::IntToString(i)); ConfigDirPolicyProvider provider(test_dir_); EXPECT_TRUE(provider.Provide(policy_store_.get())); diff --git a/chrome/browser/debugger/debugger_remote_service.cc b/chrome/browser/debugger/debugger_remote_service.cc index 91fca90..74ac1e0 100644 --- a/chrome/browser/debugger/debugger_remote_service.cc +++ b/chrome/browser/debugger/debugger_remote_service.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,7 +9,7 @@ #include "base/json/json_reader.h" #include "base/json/json_writer.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/values.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/debugger/devtools_manager.h" @@ -166,12 +166,12 @@ void DebuggerRemoteService::DebuggerOutput(int32 tab_uid, std::string content = StringPrintf( "{\"command\":\"%s\",\"result\":%s,\"data\":%s}", DebuggerRemoteServiceCommand::kDebuggerCommand.c_str(), - IntToString(RESULT_OK).c_str(), + base::IntToString(RESULT_OK).c_str(), message.c_str()); scoped_ptr<DevToolsRemoteMessage> response_message( DevToolsRemoteMessageBuilder::instance().Create( kToolName, - IntToString(tab_uid), + base::IntToString(tab_uid), content)); delegate_->Send(*(response_message.get())); } @@ -186,7 +186,7 @@ void DebuggerRemoteService::FrameNavigate(int32 tab_uid, value.SetString(kCommandWide, DebuggerRemoteServiceCommand::kFrameNavigate); value.SetInteger(kResultWide, RESULT_OK); value.SetString(kDataWide, url); - SendResponse(value, kToolName, IntToString(tab_uid)); + SendResponse(value, kToolName, base::IntToString(tab_uid)); } // Gets invoked from a DevToolsClientHost callback whenever @@ -196,7 +196,7 @@ void DebuggerRemoteService::TabClosed(int32 tab_id) { DictionaryValue value; value.SetString(kCommandWide, DebuggerRemoteServiceCommand::kTabClosed); value.SetInteger(kResultWide, RESULT_OK); - SendResponse(value, kToolName, IntToString(tab_id)); + SendResponse(value, kToolName, base::IntToString(tab_id)); } // Attaches a remote debugger to the target tab specified by |destination| diff --git a/chrome/browser/debugger/devtools_remote_listen_socket.cc b/chrome/browser/debugger/devtools_remote_listen_socket.cc index 87b88d0..bce2ba4 100644 --- a/chrome/browser/debugger/devtools_remote_listen_socket.cc +++ b/chrome/browser/debugger/devtools_remote_listen_socket.cc @@ -20,9 +20,10 @@ #include "net/base/net_errors.h" #endif +#include "base/compiler_specific.h" #include "base/eintr_wrapper.h" #include "base/platform_thread.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "chrome/browser/debugger/devtools_remote.h" #include "chrome/browser/debugger/devtools_remote_message.h" @@ -60,7 +61,7 @@ void DevToolsRemoteListenSocket::StartNextField() { if (protocol_field_.size() == 0) { // empty line - end of headers const std::string& payload_length_string = GetHeader( DevToolsRemoteMessageHeaders::kContentLength, "0"); - remaining_payload_length_ = StringToInt(payload_length_string); + base::StringToInt(payload_length_string, &remaining_payload_length_); state_ = PAYLOAD; if (remaining_payload_length_ == 0) { // no payload DispatchField(); diff --git a/chrome/browser/debugger/devtools_remote_message.cc b/chrome/browser/debugger/devtools_remote_message.cc index 97c6875..eb63009 100644 --- a/chrome/browser/debugger/devtools_remote_message.cc +++ b/chrome/browser/debugger/devtools_remote_message.cc @@ -1,10 +1,11 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/string_util.h" #include "chrome/browser/debugger/devtools_remote_message.h" +#include "base/string_number_conversions.h" + const char DevToolsRemoteMessageHeaders::kContentLength[] = "Content-Length"; const char DevToolsRemoteMessageHeaders::kTool[] = "Tool"; const char DevToolsRemoteMessageHeaders::kDestination[] = "Destination"; @@ -47,7 +48,7 @@ DevToolsRemoteMessage* DevToolsRemoteMessageBuilder::Create( const std::string& content) { DevToolsRemoteMessage::HeaderMap headers; headers[DevToolsRemoteMessageHeaders::kContentLength] = - IntToString(content.size()); + base::IntToString(content.size()); headers[DevToolsRemoteMessageHeaders::kTool] = tool; headers[DevToolsRemoteMessageHeaders::kDestination] = destination; return new DevToolsRemoteMessage(headers, content); diff --git a/chrome/browser/debugger/devtools_remote_message_unittest.cc b/chrome/browser/debugger/devtools_remote_message_unittest.cc index bc84a4c..6917f2a 100644 --- a/chrome/browser/debugger/devtools_remote_message_unittest.cc +++ b/chrome/browser/debugger/devtools_remote_message_unittest.cc @@ -1,10 +1,10 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include <string> -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "chrome/browser/debugger/devtools_remote.h" #include "chrome/browser/debugger/devtools_remote_message.h" #include "testing/gtest/include/gtest/gtest.h" @@ -25,7 +25,7 @@ TEST_F(DevToolsRemoteMessageTest, ConstructInstanceManually) { std::string content = "{\"command\":\"ping\"}"; headers[DevToolsRemoteMessageHeaders::kTool] = "DevToolsService"; headers[DevToolsRemoteMessageHeaders::kContentLength] = - IntToString(content.size()); + base::IntToString(content.size()); DevToolsRemoteMessage message(headers, content); ASSERT_STREQ("DevToolsService", diff --git a/chrome/browser/debugger/extension_ports_remote_service.cc b/chrome/browser/debugger/extension_ports_remote_service.cc index d2a05ea..72510b6 100644 --- a/chrome/browser/debugger/extension_ports_remote_service.cc +++ b/chrome/browser/debugger/extension_ports_remote_service.cc @@ -12,7 +12,7 @@ #include "base/json/json_reader.h" #include "base/json/json_writer.h" #include "base/message_loop.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/values.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/debugger/devtools_manager.h" @@ -280,7 +280,7 @@ void ExtensionPortsRemoteService::OnExtensionMessage( return; } content.Set(kDataWide, data); - SendResponse(content, kToolName, IntToString(port_id)); + SendResponse(content, kToolName, base::IntToString(port_id)); } void ExtensionPortsRemoteService::OnExtensionPortDisconnected(int port_id) { @@ -289,7 +289,7 @@ void ExtensionPortsRemoteService::OnExtensionPortDisconnected(int port_id) { DictionaryValue content; content.SetString(kCommandWide, kOnDisconnect); content.SetInteger(kResultWide, RESULT_OK); - SendResponse(content, kToolName, IntToString(port_id)); + SendResponse(content, kToolName, base::IntToString(port_id)); } void ExtensionPortsRemoteService::ConnectCommand( diff --git a/chrome/browser/diagnostics/recon_diagnostics.cc b/chrome/browser/diagnostics/recon_diagnostics.cc index 1f0ab8a..eb76c2b 100644 --- a/chrome/browser/diagnostics/recon_diagnostics.cc +++ b/chrome/browser/diagnostics/recon_diagnostics.cc @@ -10,6 +10,7 @@ #include "base/file_version_info.h" #include "base/json/json_reader.h" #include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "base/sys_info.h" #include "base/path_service.h" @@ -295,7 +296,7 @@ class JSONTest : public DiagnosticTest { scoped_ptr<Value> json_root(json.Deserialize(&error_code, &error_message)); if (base::JSONReader::JSON_NO_ERROR != error_code) { if (error_message.empty()) { - error_message = "Parse error " + IntToString(error_code); + error_message = "Parse error " + base::IntToString(error_code); } RecordFailure(UTF8ToUTF16(error_message)); return true; diff --git a/chrome/browser/diagnostics/sqlite_diagnostics.cc b/chrome/browser/diagnostics/sqlite_diagnostics.cc index 1e21c22..5013fa9 100644 --- a/chrome/browser/diagnostics/sqlite_diagnostics.cc +++ b/chrome/browser/diagnostics/sqlite_diagnostics.cc @@ -12,7 +12,7 @@ #include "base/logging.h" #include "base/path_service.h" #include "base/singleton.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" #include "third_party/sqlite/preprocessed/sqlite3.h" @@ -58,7 +58,7 @@ class SqliteIntegrityTest : public DiagnosticTest { RecordFailure(ASCIIToUTF16("DB locked by another process")); } else { string16 str(ASCIIToUTF16("Pragma failed. Error: ")); - str += IntToString16(error); + str += base::IntToString16(error); RecordFailure(str); } return false; @@ -72,7 +72,7 @@ class SqliteIntegrityTest : public DiagnosticTest { // All done. Report to the user. if (errors != 0) { string16 str(ASCIIToUTF16("Database corruption detected :")); - str += IntToString16(errors) + ASCIIToUTF16(" errors"); + str += base::IntToString16(errors) + ASCIIToUTF16(" errors"); RecordFailure(str); return true; } diff --git a/chrome/browser/dom_ui/net_internals_ui.cc b/chrome/browser/dom_ui/net_internals_ui.cc index 951aef4..f87532c 100644 --- a/chrome/browser/dom_ui/net_internals_ui.cc +++ b/chrome/browser/dom_ui/net_internals_ui.cc @@ -18,8 +18,8 @@ #include "base/message_loop.h" #include "base/path_service.h" #include "base/singleton.h" +#include "base/string_number_conversions.h" #include "base/string_piece.h" -#include "base/string_util.h" #include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/browser/browser_process.h" @@ -52,7 +52,7 @@ namespace { // Formats |t| as a decimal number, in milliseconds. std::string TickCountToString(const base::TimeTicks& t) { - return Int64ToString((t - base::TimeTicks()).InMilliseconds()); + return base::Int64ToString((t - base::TimeTicks()).InMilliseconds()); } // Returns the HostCache for |context|'s primary HostResolver, or NULL if @@ -589,7 +589,7 @@ void NetInternalsMessageHandler::IOThreadImpl::OnRendererReady( // Pass it as a string, since it may be too large to fit in an integer. CallJavascriptFunction(L"g_browser.receivedTimeTickOffset", Value::CreateStringValue( - Int64ToString(tick_to_unix_time_ms))); + base::Int64ToString(tick_to_unix_time_ms))); } OnGetPassiveLogEntries(NULL); diff --git a/chrome/browser/dom_ui/ntp_resource_cache.cc b/chrome/browser/dom_ui/ntp_resource_cache.cc index e9f046d..38eb5c7 100644 --- a/chrome/browser/dom_ui/ntp_resource_cache.cc +++ b/chrome/browser/dom_ui/ntp_resource_cache.cc @@ -14,6 +14,7 @@ #include "base/command_line.h" #include "base/file_util.h" #include "base/ref_counted_memory.h" +#include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "base/values.h" #include "chrome/browser/browser_theme_provider.h" @@ -104,10 +105,10 @@ std::string GetNewTabBackgroundCSS(const ThemeProvider* theme_provider, if (alignment & BrowserThemeProvider::ALIGN_TOP) { if (alignment & BrowserThemeProvider::ALIGN_LEFT) - return "0% " + IntToString(-offset) + "px"; + return "0% " + base::IntToString(-offset) + "px"; else if (alignment & BrowserThemeProvider::ALIGN_RIGHT) - return "100% " + IntToString(-offset) + "px"; - return "center " + IntToString(-offset) + "px"; + return "100% " + base::IntToString(-offset) + "px"; + return "center " + base::IntToString(-offset) + "px"; } return BrowserThemeProvider::AlignmentToString(alignment); } diff --git a/chrome/browser/download/drag_download_util.cc b/chrome/browser/download/drag_download_util.cc index a617d41..29fd84e 100644 --- a/chrome/browser/download/drag_download_util.cc +++ b/chrome/browser/download/drag_download_util.cc @@ -9,6 +9,7 @@ #include "base/file_util.h" #include "base/scoped_ptr.h" #include "base/task.h" +#include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "chrome/browser/chrome_thread.h" #include "googleurl/src/gurl.h" @@ -65,9 +66,9 @@ FileStream* CreateFileStreamForDrop(FilePath* file_path) { new_file_path = *file_path; } else { #if defined(OS_WIN) - std::wstring suffix = std::wstring(L"-") + IntToWString(seq); + string16 suffix = ASCIIToUTF16("-") + base::IntToString16(seq); #else - std::string suffix = std::string("-") + IntToString(seq); + std::string suffix = std::string("-") + base::IntToString(seq); #endif new_file_path = file_path->InsertBeforeExtension(suffix); } diff --git a/chrome/browser/extensions/extension_bookmark_helpers.cc b/chrome/browser/extensions/extension_bookmark_helpers.cc index f648a5e..a41c340 100644 --- a/chrome/browser/extensions/extension_bookmark_helpers.cc +++ b/chrome/browser/extensions/extension_bookmark_helpers.cc @@ -4,7 +4,7 @@ #include "chrome/browser/extensions/extension_bookmark_helpers.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "chrome/browser/extensions/extension_bookmarks_module_constants.h" namespace keys = extension_bookmarks_module_constants; @@ -16,11 +16,11 @@ DictionaryValue* GetNodeDictionary(const BookmarkNode* node, bool recurse, bool only_folders) { DictionaryValue* dict = new DictionaryValue(); - dict->SetString(keys::kIdKey, Int64ToString(node->id())); + dict->SetString(keys::kIdKey, base::Int64ToString(node->id())); const BookmarkNode* parent = node->GetParent(); if (parent) { - dict->SetString(keys::kParentIdKey, Int64ToString(parent->id())); + dict->SetString(keys::kParentIdKey, base::Int64ToString(parent->id())); dict->SetInteger(keys::kIndexKey, parent->IndexOfChild(node)); } diff --git a/chrome/browser/extensions/extension_bookmark_manager_api.cc b/chrome/browser/extensions/extension_bookmark_manager_api.cc index 9b796d2..2cbc471 100644 --- a/chrome/browser/extensions/extension_bookmark_manager_api.cc +++ b/chrome/browser/extensions/extension_bookmark_manager_api.cc @@ -8,7 +8,7 @@ #include "app/l10n_util.h" #include "base/json/json_writer.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/values.h" #include "chrome/browser/bookmarks/bookmark_drag_data.h" #include "chrome/browser/bookmarks/bookmark_model.h" @@ -77,10 +77,10 @@ void AddNodeToList(ListValue* list, const BookmarkNode& node) { // Add id and parentId so we can associate the data with existing nodes on the // client side. - std::string id_string = Int64ToString(node.id()); + std::string id_string = base::Int64ToString(node.id()); dict->SetString(keys::kIdKey, id_string); - std::string parent_id_string = Int64ToString(node.GetParent()->id()); + std::string parent_id_string = base::Int64ToString(node.GetParent()->id()); dict->SetString(keys::kParentIdKey, parent_id_string); if (node.is_url()) diff --git a/chrome/browser/extensions/extension_bookmarks_module.cc b/chrome/browser/extensions/extension_bookmarks_module.cc index 0eb7a30..b819217 100644 --- a/chrome/browser/extensions/extension_bookmarks_module.cc +++ b/chrome/browser/extensions/extension_bookmarks_module.cc @@ -7,7 +7,7 @@ #include "base/json/json_writer.h" #include "base/sha1.h" #include "base/stl_util-inl.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "chrome/browser/bookmarks/bookmark_codec.h" #include "chrome/browser/bookmarks/bookmark_html_writer.h" #include "chrome/browser/bookmarks/bookmark_model.h" @@ -56,7 +56,7 @@ void BookmarksFunction::Run() { bool BookmarksFunction::GetBookmarkIdAsInt64( const std::string& id_string, int64* id) { - if (StringToInt64(id_string, id)) + if (base::StringToInt64(id_string, id)) return true; error_ = keys::kInvalidIdError; @@ -112,12 +112,13 @@ void ExtensionBookmarkEventRouter::BookmarkNodeMoved( int new_index) { ListValue args; const BookmarkNode* node = new_parent->GetChild(new_index); - args.Append(new StringValue(Int64ToString(node->id()))); + args.Append(new StringValue(base::Int64ToString(node->id()))); DictionaryValue* object_args = new DictionaryValue(); - object_args->SetString(keys::kParentIdKey, Int64ToString(new_parent->id())); + object_args->SetString(keys::kParentIdKey, + base::Int64ToString(new_parent->id())); object_args->SetInteger(keys::kIndexKey, new_index); object_args->SetString(keys::kOldParentIdKey, - Int64ToString(old_parent->id())); + base::Int64ToString(old_parent->id())); object_args->SetInteger(keys::kOldIndexKey, old_index); args.Append(object_args); @@ -131,7 +132,7 @@ void ExtensionBookmarkEventRouter::BookmarkNodeAdded(BookmarkModel* model, int index) { ListValue args; const BookmarkNode* node = parent->GetChild(index); - args.Append(new StringValue(Int64ToString(node->id()))); + args.Append(new StringValue(base::Int64ToString(node->id()))); DictionaryValue* obj = extension_bookmark_helpers::GetNodeDictionary(node, false, false); args.Append(obj); @@ -147,9 +148,10 @@ void ExtensionBookmarkEventRouter::BookmarkNodeRemoved( int index, const BookmarkNode* node) { ListValue args; - args.Append(new StringValue(Int64ToString(node->id()))); + args.Append(new StringValue(base::Int64ToString(node->id()))); DictionaryValue* object_args = new DictionaryValue(); - object_args->SetString(keys::kParentIdKey, Int64ToString(parent->id())); + object_args->SetString(keys::kParentIdKey, + base::Int64ToString(parent->id())); object_args->SetInteger(keys::kIndexKey, index); args.Append(object_args); @@ -161,7 +163,7 @@ void ExtensionBookmarkEventRouter::BookmarkNodeRemoved( void ExtensionBookmarkEventRouter::BookmarkNodeChanged( BookmarkModel* model, const BookmarkNode* node) { ListValue args; - args.Append(new StringValue(Int64ToString(node->id()))); + args.Append(new StringValue(base::Int64ToString(node->id()))); // TODO(erikkay) The only three things that BookmarkModel sends this // notification for are title, url and favicon. Since we're currently @@ -187,12 +189,12 @@ void ExtensionBookmarkEventRouter::BookmarkNodeFavIconLoaded( void ExtensionBookmarkEventRouter::BookmarkNodeChildrenReordered( BookmarkModel* model, const BookmarkNode* node) { ListValue args; - args.Append(new StringValue(Int64ToString(node->id()))); + args.Append(new StringValue(base::Int64ToString(node->id()))); int childCount = node->GetChildCount(); ListValue* children = new ListValue(); for (int i = 0; i < childCount; ++i) { const BookmarkNode* child = node->GetChild(i); - Value* child_id = new StringValue(Int64ToString(child->id())); + Value* child_id = new StringValue(base::Int64ToString(child->id())); children->Append(child_id); } DictionaryValue* reorder_info = new DictionaryValue(); @@ -347,7 +349,7 @@ bool RemoveBookmarkFunction::ExtractIds(const ListValue* args, if (!args->GetString(0, &id_string)) return false; int64 id; - if (StringToInt64(id_string, &id)) + if (base::StringToInt64(id_string, &id)) ids->push_back(id); else *invalid_id = true; @@ -618,7 +620,10 @@ class CreateBookmarkBucketMapper : public BookmarkBucketMapper<std::string> { return; } BookmarkModel* model = profile_->GetBookmarkModel(); - const BookmarkNode* parent = model->GetNodeByID(StringToInt64(parent_id)); + + int64 parent_id_int64; + base::StringToInt64(parent_id, &parent_id_int64); + const BookmarkNode* parent = model->GetNodeByID(parent_id_int64); if (!parent) return; diff --git a/chrome/browser/extensions/extension_browsertest.cc b/chrome/browser/extensions/extension_browsertest.cc index dedcf8f..a30f352 100644 --- a/chrome/browser/extensions/extension_browsertest.cc +++ b/chrome/browser/extensions/extension_browsertest.cc @@ -9,7 +9,7 @@ #include "base/command_line.h" #include "base/file_path.h" #include "base/path_service.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_window.h" #include "chrome/browser/location_bar.h" @@ -147,8 +147,9 @@ bool ExtensionBrowserTest::InstallOrUpdateExtension(const std::string& id, size_t num_after = service->extensions()->size(); if (num_after != (num_before + expected_change)) { - std::cout << "Num extensions before: " << IntToString(num_before) << " " - << "num after: " << IntToString(num_after) << " " + std::cout << "Num extensions before: " + << base::IntToString(num_before) << " " + << "num after: " << base::IntToString(num_after) << " " << "Installed extensions follow:\n"; for (size_t i = 0; i < service->extensions()->size(); ++i) diff --git a/chrome/browser/extensions/extension_clipboard_api.cc b/chrome/browser/extensions/extension_clipboard_api.cc index 22a6253..af1deae 100644 --- a/chrome/browser/extensions/extension_clipboard_api.cc +++ b/chrome/browser/extensions/extension_clipboard_api.cc @@ -4,7 +4,7 @@ #include "chrome/browser/extensions/extension_clipboard_api.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/values.h" #include "chrome/browser/extensions/extension_tabs_module.h" #include "chrome/browser/renderer_host/render_view_host.h" @@ -23,8 +23,8 @@ bool ClipboardFunction::RunImpl() { TabContents* contents = NULL; if (!ExtensionTabUtil::GetTabById(tab_id, profile(), include_incognito(), NULL, NULL, &contents, NULL)) { - error_ = ExtensionErrorUtils::FormatErrorMessage(kNoTabError, - IntToString(tab_id)); + error_ = ExtensionErrorUtils::FormatErrorMessage( + kNoTabError, base::IntToString(tab_id)); return false; } diff --git a/chrome/browser/extensions/extension_context_menu_api.cc b/chrome/browser/extensions/extension_context_menu_api.cc index 9b7a3a8..356a43c 100644 --- a/chrome/browser/extensions/extension_context_menu_api.cc +++ b/chrome/browser/extensions/extension_context_menu_api.cc @@ -7,6 +7,7 @@ #include <string> #include "base/values.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/profile.h" @@ -188,7 +189,8 @@ bool ExtensionContextMenuFunction::GetParent( ExtensionMenuItem* parent = manager.GetItemById(parent_id); if (!parent) { - error_ = "Cannot find menu item with id " + IntToString(parent_id.second); + error_ = "Cannot find menu item with id " + + base::IntToString(parent_id.second); return false; } if (parent->type() != ExtensionMenuItem::NORMAL) { @@ -246,7 +248,7 @@ bool CreateContextMenuFunction::RunImpl() { ExtensionMenuItem* parent = menu_manager->GetItemById(parent_id); if (!parent) { error_ = ExtensionErrorUtils::FormatErrorMessage( - kCannotFindItemError, IntToString(parent_id.second)); + kCannotFindItemError, base::IntToString(parent_id.second)); return false; } if (parent->type() != ExtensionMenuItem::NORMAL) { @@ -273,7 +275,7 @@ bool UpdateContextMenuFunction::RunImpl() { ExtensionMenuItem* item = manager->GetItemById(item_id); if (!item || item->extension_id() != extension_id()) { error_ = ExtensionErrorUtils::FormatErrorMessage( - kCannotFindItemError, IntToString(item_id.second)); + kCannotFindItemError, base::IntToString(item_id.second)); return false; } @@ -341,7 +343,7 @@ bool RemoveContextMenuFunction::RunImpl() { // Ensure one extension can't remove another's menu items. if (!item || item->extension_id() != extension_id()) { error_ = ExtensionErrorUtils::FormatErrorMessage( - kCannotFindItemError, IntToString(id.second)); + kCannotFindItemError, base::IntToString(id.second)); return false; } diff --git a/chrome/browser/extensions/extension_history_api.cc b/chrome/browser/extensions/extension_history_api.cc index 23f861f..0b891c8 100644 --- a/chrome/browser/extensions/extension_history_api.cc +++ b/chrome/browser/extensions/extension_history_api.cc @@ -7,7 +7,7 @@ #include "base/callback.h" #include "base/json/json_writer.h" #include "base/message_loop.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/task.h" #include "base/values.h" #include "chrome/browser/extensions/extension_history_api_constants.h" @@ -28,7 +28,7 @@ double MilliSecondsFromTime(const base::Time& time) { void GetHistoryItemDictionary(const history::URLRow& row, DictionaryValue* value) { - value->SetString(keys::kIdKey, Int64ToString(row.id())); + value->SetString(keys::kIdKey, base::Int64ToString(row.id())); value->SetString(keys::kUrlKey, row.url().spec()); value->SetStringFromUTF16(keys::kTitleKey, row.title()); value->SetReal(keys::kLastVisitdKey, MilliSecondsFromTime(row.last_visit())); @@ -44,11 +44,11 @@ void AddHistoryNode(const history::URLRow& row, ListValue* list) { void GetVisitInfoDictionary(const history::VisitRow& row, DictionaryValue* value) { - value->SetString(keys::kIdKey, Int64ToString(row.url_id)); - value->SetString(keys::kVisitId, Int64ToString(row.visit_id)); + value->SetString(keys::kIdKey, base::Int64ToString(row.url_id)); + value->SetString(keys::kVisitId, base::Int64ToString(row.visit_id)); value->SetReal(keys::kVisitTime, MilliSecondsFromTime(row.visit_time)); value->SetString(keys::kReferringVisitId, - Int64ToString(row.referring_visit)); + base::Int64ToString(row.referring_visit)); const char* trans = PageTransition::CoreTransitionString(row.transition); DCHECK(trans) << "Invalid transition."; diff --git a/chrome/browser/extensions/extension_infobar_module.cc b/chrome/browser/extensions/extension_infobar_module.cc index 8ca5605..2d3e67f 100644 --- a/chrome/browser/extensions/extension_infobar_module.cc +++ b/chrome/browser/extensions/extension_infobar_module.cc @@ -5,6 +5,7 @@ #include "chrome/browser/extensions/extension_infobar_module.h" #include "base/string_util.h" +#include "base/string_number_conversions.h" #include "chrome/browser/browser.h" #include "chrome/browser/extensions/extension_host.h" #include "chrome/browser/extensions/extension_infobar_module_constants.h" @@ -45,7 +46,7 @@ bool ShowInfoBarFunction::RunImpl() { NULL)) { error_ = ExtensionErrorUtils::FormatErrorMessage( extension_tabs_module_constants::kTabNotFoundError, - IntToString(tab_id)); + base::IntToString(tab_id)); return false; } diff --git a/chrome/browser/extensions/extension_page_actions_module.cc b/chrome/browser/extensions/extension_page_actions_module.cc index cdeb892..095cd36 100644 --- a/chrome/browser/extensions/extension_page_actions_module.cc +++ b/chrome/browser/extensions/extension_page_actions_module.cc @@ -4,7 +4,7 @@ #include "chrome/browser/extensions/extension_page_actions_module.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/profile.h" @@ -71,8 +71,8 @@ bool PageActionFunction::SetPageActionEnabled(bool enable) { bool result = ExtensionTabUtil::GetTabById( tab_id, profile(), include_incognito(), NULL, NULL, &contents, NULL); if (!result || !contents) { - error_ = ExtensionErrorUtils::FormatErrorMessage(kNoTabError, - IntToString(tab_id)); + error_ = ExtensionErrorUtils::FormatErrorMessage( + kNoTabError, base::IntToString(tab_id)); return false; } @@ -104,8 +104,8 @@ bool PageActionFunction::InitCommon(int tab_id) { bool result = ExtensionTabUtil::GetTabById( tab_id, profile(), include_incognito(), NULL, NULL, &contents_, NULL); if (!result || !contents_) { - error_ = ExtensionErrorUtils::FormatErrorMessage(kNoTabError, - IntToString(tab_id)); + error_ = ExtensionErrorUtils::FormatErrorMessage( + kNoTabError, base::IntToString(tab_id)); return false; } diff --git a/chrome/browser/extensions/extension_prefs.cc b/chrome/browser/extensions/extension_prefs.cc index ed44ec4..4006120 100644 --- a/chrome/browser/extensions/extension_prefs.cc +++ b/chrome/browser/extensions/extension_prefs.cc @@ -3,6 +3,8 @@ // found in the LICENSE file. #include "base/string_util.h" +#include "base/string_number_conversions.h" +#include "base/utf_string_conversions.h" #include "chrome/browser/extensions/extension_prefs.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/pref_names.h" @@ -317,7 +319,7 @@ void ExtensionPrefs::SetLastPingDayImpl(const Time& time, NOTREACHED(); return; } - std::string value = Int64ToString(time.ToInternalValue()); + std::string value = base::Int64ToString(time.ToInternalValue()); dictionary->SetString(kLastPingDay, value); prefs_->ScheduleSavePersistentPrefs(); } @@ -695,7 +697,7 @@ void ExtensionPrefs::SetIdleInstallInfo(const std::string& extension_id, info->SetString(kIdleInstallInfoCrxPath, crx_path.value()); info->SetString(kIdleInstallInfoVersion, version); info->SetString(kIdleInstallInfoFetchTime, - Int64ToString(fetch_time.ToInternalValue())); + base::Int64ToString(fetch_time.ToInternalValue())); extension_prefs->Set(kIdleInstallInfo, info); prefs_->ScheduleSavePersistentPrefs(); } diff --git a/chrome/browser/extensions/extension_prefs_unittest.cc b/chrome/browser/extensions/extension_prefs_unittest.cc index 812891b..cd87bbe 100644 --- a/chrome/browser/extensions/extension_prefs_unittest.cc +++ b/chrome/browser/extensions/extension_prefs_unittest.cc @@ -6,7 +6,7 @@ #include "base/path_service.h" #include "base/scoped_temp_dir.h" #include "base/stl_util-inl.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/extensions/extension_prefs.h" #include "chrome/browser/extensions/test_extension_prefs.h" @@ -172,7 +172,7 @@ class ExtensionPrefsBlacklist : public ExtensionPrefsTest { // Install 5 extensions. for (int i = 0; i < 5; i++) { - std::string name = "test" + IntToString(i); + std::string name = "test" + base::IntToString(i); extensions_.push_back(linked_ptr<Extension>(prefs_.AddExtension(name))); } EXPECT_EQ(NULL, prefs()->GetInstalledExtensionInfo(not_installed_id_)); @@ -225,8 +225,9 @@ class ExtensionPrefsIdleInstallInfo : public ExtensionPrefsTest { public: // Sets idle install information for one test extension. void SetIdleInfo(std::string id, int num) { - prefs()->SetIdleInstallInfo(id, basedir_.AppendASCII(IntToString(num)), - "1." + IntToString(num), + prefs()->SetIdleInstallInfo(id, + basedir_.AppendASCII(base::IntToString(num)), + "1." + base::IntToString(num), now_ + TimeDelta::FromSeconds(num)); } @@ -239,8 +240,8 @@ class ExtensionPrefsIdleInstallInfo : public ExtensionPrefsTest { ASSERT_TRUE(prefs()->GetIdleInstallInfo(id, &crx_path, &version, &fetch_time)); ASSERT_EQ(crx_path.value(), - basedir_.AppendASCII(IntToString(num)).value()); - ASSERT_EQ("1." + IntToString(num), version); + basedir_.AppendASCII(base::IntToString(num)).value()); + ASSERT_EQ("1." + base::IntToString(num), version); ASSERT_TRUE(fetch_time == now_ + TimeDelta::FromSeconds(num)); } diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc index a4b1ee1..4d0d11f 100644 --- a/chrome/browser/extensions/extension_tabs_module.cc +++ b/chrome/browser/extensions/extension_tabs_module.cc @@ -5,6 +5,7 @@ #include "chrome/browser/extensions/extension_tabs_module.h" #include "base/base64.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" @@ -223,7 +224,7 @@ bool GetWindowFunction::RunImpl() { include_incognito(), &error_); if (!browser || !browser->window()) { error_ = ExtensionErrorUtils::FormatErrorMessage( - keys::kWindowNotFoundError, IntToString(window_id)); + keys::kWindowNotFoundError, base::IntToString(window_id)); return false; } @@ -396,7 +397,7 @@ bool UpdateWindowFunction::RunImpl() { include_incognito(), &error_); if (!browser || !browser->window()) { error_ = ExtensionErrorUtils::FormatErrorMessage( - keys::kWindowNotFoundError, IntToString(window_id)); + keys::kWindowNotFoundError, base::IntToString(window_id)); return false; } @@ -746,7 +747,7 @@ bool MoveTabFunction::RunImpl() { contents = source_tab_strip->DetachTabContentsAt(tab_index); if (!contents) { error_ = ExtensionErrorUtils::FormatErrorMessage( - keys::kTabNotFoundError, IntToString(tab_id)); + keys::kTabNotFoundError, base::IntToString(tab_id)); return false; } @@ -1060,7 +1061,7 @@ static Browser* GetBrowserInProfileWithId(Profile* profile, if (error_message) *error_message = ExtensionErrorUtils::FormatErrorMessage( - keys::kWindowNotFoundError, IntToString(window_id)); + keys::kWindowNotFoundError, base::IntToString(window_id)); return NULL; } @@ -1078,7 +1079,7 @@ static bool GetTabById(int tab_id, Profile* profile, if (error_message) *error_message = ExtensionErrorUtils::FormatErrorMessage( - keys::kTabNotFoundError, IntToString(tab_id)); + keys::kTabNotFoundError, base::IntToString(tab_id)); return false; } diff --git a/chrome/browser/extensions/extension_updater.cc b/chrome/browser/extensions/extension_updater.cc index 9f21100..f0da90f 100644 --- a/chrome/browser/extensions/extension_updater.cc +++ b/chrome/browser/extensions/extension_updater.cc @@ -14,6 +14,7 @@ #include "base/rand_util.h" #include "base/sha2.h" #include "base/stl_util-inl.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/time.h" #include "base/thread.h" @@ -105,8 +106,8 @@ bool ManifestFetchData::AddExtension(std::string id, std::string version, parts.push_back("uc"); if (ShouldPing(days)) { - parts.push_back("ping=" + EscapeQueryParamValue("r=" + IntToString(days), - true)); + parts.push_back("ping=" + + EscapeQueryParamValue("r=" + base::IntToString(days), true)); } std::string extra = full_url_.has_query() ? "&" : "?"; @@ -556,7 +557,8 @@ void ExtensionUpdater::ProcessBlacklist(const std::string& data) { // Verify sha256 hash value. char sha256_hash_value[base::SHA256_LENGTH]; base::SHA256HashString(data, sha256_hash_value, base::SHA256_LENGTH); - std::string hash_in_hex = HexEncode(sha256_hash_value, base::SHA256_LENGTH); + std::string hash_in_hex = base::HexEncode(sha256_hash_value, + base::SHA256_LENGTH); if (current_extension_fetch_.package_hash != hash_in_hex) { NOTREACHED() << "Fetched blacklist checksum is not as expected. " diff --git a/chrome/browser/extensions/extension_updater_unittest.cc b/chrome/browser/extensions/extension_updater_unittest.cc index 0895501..8f314a9 100644 --- a/chrome/browser/extensions/extension_updater_unittest.cc +++ b/chrome/browser/extensions/extension_updater_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -8,6 +8,7 @@ #include "base/rand_util.h" #include "base/scoped_ptr.h" #include "base/stl_util-inl.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/thread.h" #include "base/version.h" @@ -767,7 +768,7 @@ class ExtensionUpdaterTest : public testing::Test { if (ping_days == 0) { EXPECT_TRUE(url1_query.find(search_string) == std::string::npos); } else { - search_string += "%253D" + IntToString(ping_days); + search_string += "%253D" + base::IntToString(ping_days); size_t pos = url1_query.find(search_string); EXPECT_TRUE(pos != std::string::npos); } diff --git a/chrome/browser/geolocation/network_location_request.cc b/chrome/browser/geolocation/network_location_request.cc index 7eae212..2683b0c 100644 --- a/chrome/browser/geolocation/network_location_request.cc +++ b/chrome/browser/geolocation/network_location_request.cc @@ -6,7 +6,7 @@ #include "base/json/json_reader.h" #include "base/json/json_writer.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/values.h" #include "chrome/common/geoposition.h" #include "chrome/common/net/url_request_context_getter.h" @@ -202,7 +202,7 @@ void GetLocationFromResponse(bool http_post_result, } if (status_code != 200) { // HTTP OK. std::string message = "Returned error code "; - message += IntToString(status_code); + message += base::IntToString(status_code); FormatPositionError(server_url, message, position); return; } diff --git a/chrome/browser/gtk/download_in_progress_dialog_gtk.cc b/chrome/browser/gtk/download_in_progress_dialog_gtk.cc index 8ee6b30..8a41589 100644 --- a/chrome/browser/gtk/download_in_progress_dialog_gtk.cc +++ b/chrome/browser/gtk/download_in_progress_dialog_gtk.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,6 +7,7 @@ #include <gtk/gtk.h> #include "app/l10n_util.h" +#include "base/string_number_conversions.h" #include "base/string16.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_window.h" @@ -41,7 +42,8 @@ DownloadInProgressDialogGtk::DownloadInProgressDialogGtk(Browser* browser) } else { warning_text = l10n_util::GetStringFUTF8(IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_WARNING, - product_name, IntToString16(download_count)); + product_name, + base::IntToString16(download_count)); explanation_text = l10n_util::GetStringFUTF8( IDS_MULTIPLE_DOWNLOADS_REMOVE_CONFIRM_EXPLANATION, product_name); diff --git a/chrome/browser/gtk/find_bar_gtk.cc b/chrome/browser/gtk/find_bar_gtk.cc index 18a41258..0c0f40d 100644 --- a/chrome/browser/gtk/find_bar_gtk.cc +++ b/chrome/browser/gtk/find_bar_gtk.cc @@ -13,6 +13,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/i18n/rtl.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "chrome/browser/browser.h" #include "chrome/browser/find_bar_controller.h" @@ -384,8 +385,8 @@ void FindBarGtk::UpdateUIForFindResult(const FindNotificationDetails& result, if (!find_text.empty() && have_valid_range) { gtk_label_set_text(GTK_LABEL(match_count_label_), l10n_util::GetStringFUTF8(IDS_FIND_IN_PAGE_COUNT, - IntToString16(result.active_match_ordinal()), - IntToString16(result.number_of_matches())).c_str()); + base::IntToString16(result.active_match_ordinal()), + base::IntToString16(result.number_of_matches())).c_str()); UpdateMatchLabelAppearance(result.number_of_matches() == 0 && result.final_update()); } else { diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc index 44a41b8..442306f 100644 --- a/chrome/browser/metrics/metrics_service.cc +++ b/chrome/browser/metrics/metrics_service.cc @@ -167,6 +167,7 @@ #include "base/command_line.h" #include "base/histogram.h" #include "base/md5.h" +#include "base/string_number_conversions.h" #include "base/thread.h" #include "base/values.h" #include "chrome/browser/bookmarks/bookmark_model.h" @@ -515,7 +516,7 @@ void MetricsService::SetRecording(bool enabled) { // Might as well make a note of how long this ID has existed pref->SetString(prefs::kMetricsClientIDTimestamp, - Int64ToString(Time::Now().ToTimeT())); + base::Int64ToString(Time::Now().ToTimeT())); } } child_process_logging::SetClientId(client_id_); diff --git a/chrome/browser/net/predictor_api.cc b/chrome/browser/net/predictor_api.cc index 4e4569e..98febfe 100644 --- a/chrome/browser/net/predictor_api.cc +++ b/chrome/browser/net/predictor_api.cc @@ -10,7 +10,7 @@ #include "base/singleton.h" #include "base/stats_counters.h" #include "base/stl_util-inl.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/thread.h" #include "base/waitable_event.h" #include "base/values.h" @@ -310,7 +310,7 @@ void PrefetchObserver::StartupListAppend(const std::string& host, int port) { std::string url_spec = is_ssl ? "https://" : "http://"; url_spec += host; url_spec += ":"; - url_spec += IntToString(port); + url_spec += base::IntToString(port); GURL url(url_spec); first_resolutions_.insert(url); diff --git a/chrome/browser/net/predictor_unittest.cc b/chrome/browser/net/predictor_unittest.cc index 9a3eea3..58c71ed 100644 --- a/chrome/browser/net/predictor_unittest.cc +++ b/chrome/browser/net/predictor_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -10,7 +10,7 @@ #include "base/message_loop.h" #include "base/scoped_ptr.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/timer.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/net/predictor_api.h" @@ -235,7 +235,7 @@ TEST_F(PredictorTest, MassiveConcurrentLookupTest) { UrlList names; for (int i = 0; i < 100; i++) - names.push_back(GURL("http://host" + IntToString(i) + ".notfound:80")); + names.push_back(GURL("http://host" + base::IntToString(i) + ".notfound:80")); // Try to flood the predictor with many concurrent requests. for (int i = 0; i < 10; i++) diff --git a/chrome/browser/page_info_model.cc b/chrome/browser/page_info_model.cc index aed8b23..636e252 100644 --- a/chrome/browser/page_info_model.cc +++ b/chrome/browser/page_info_model.cc @@ -9,6 +9,7 @@ #include "app/l10n_util.h" #include "base/callback.h" #include "base/i18n/time_formatting.h" +#include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "chrome/browser/cert_store.h" #include "chrome/browser/pref_service.h" @@ -136,7 +137,7 @@ PageInfoModel::PageInfoModel(Profile* profile, description.assign(l10n_util::GetStringFUTF16( IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, subject_name, - IntToString16(ssl.security_bits()))); + base::IntToString16(ssl.security_bits()))); if (ssl.displayed_insecure_content() || ssl.ran_insecure_content()) { state = false; description.assign(l10n_util::GetStringFUTF16( diff --git a/chrome/browser/page_state.cc b/chrome/browser/page_state.cc index bf431ca..19764f0 100644 --- a/chrome/browser/page_state.cc +++ b/chrome/browser/page_state.cc @@ -6,7 +6,7 @@ #include "base/basictypes.h" #include "base/logging.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "chrome/browser/page_state.h" #include "chrome/common/json_value_serializer.h" @@ -80,25 +80,25 @@ bool PageState::GetProperty(const std::wstring& key, } void PageState::SetInt64Property(const std::wstring& key, int64 value) { - SetProperty(key, Int64ToWString(value)); + SetProperty(key, UTF8ToWide(base::Int64ToString(value))); } bool PageState::GetInt64Property(const std::wstring& key, int64* value) const { std::wstring v; if (GetProperty(key, &v)) { - return StringToInt64(WideToUTF16Hack(v), value); + return base::StringToInt64(WideToUTF8(v), value); } return false; } void PageState::SetIntProperty(const std::wstring& key, int value) { - SetProperty(key, IntToWString(value)); + SetProperty(key, UTF8ToWide(base::IntToString(value))); } bool PageState::GetIntProperty(const std::wstring& key, int* value) const { std::wstring v; if (GetProperty(key, &v)) { - return StringToInt(WideToUTF16Hack(v), value); + return base::StringToInt(WideToUTF8(v), value); } return false; } diff --git a/chrome/browser/parsers/metadata_parser_filebase.cc b/chrome/browser/parsers/metadata_parser_filebase.cc index 5b4aeff..0146f3f 100644 --- a/chrome/browser/parsers/metadata_parser_filebase.cc +++ b/chrome/browser/parsers/metadata_parser_filebase.cc @@ -1,11 +1,11 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/parsers/metadata_parser_filebase.h" #include "base/file_util.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" FileMetadataParser::FileMetadataParser(const FilePath& path) @@ -17,7 +17,7 @@ bool FileMetadataParser::Parse() { std::string value; int64 size; if (file_util::GetFileSize(path_, &size)) { - properties_[MetadataParser::kPropertyFilesize] = Int64ToString(size); + properties_[MetadataParser::kPropertyFilesize] = base::Int64ToString(size); } #if defined(OS_WIN) value = WideToUTF8(path_.BaseName().value()); diff --git a/chrome/browser/parsers/metadata_parser_filebase_unittest.cc b/chrome/browser/parsers/metadata_parser_filebase_unittest.cc index 0e954e6..24e1051 100644 --- a/chrome/browser/parsers/metadata_parser_filebase_unittest.cc +++ b/chrome/browser/parsers/metadata_parser_filebase_unittest.cc @@ -8,7 +8,8 @@ #include "base/file_path.h" #include "base/file_util.h" #include "base/scoped_temp_dir.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" +#include "base/string_util.h" // TODO(brettw) remove when WideToASCII moves. #include "chrome/browser/parsers/metadata_parser_filebase.h" #include "testing/gtest/include/gtest/gtest.h" @@ -41,7 +42,7 @@ class FileMetaDataParserTest : public testing::Test { int64 size; EXPECT_TRUE(file_util::GetFileSize(test_file_, &size)); - return Int64ToString(size); + return base::Int64ToString(size); } ScopedTempDir temp_dir_; diff --git a/chrome/browser/password_manager/login_database_unittest.cc b/chrome/browser/password_manager/login_database_unittest.cc index e650042..2d8a061 100644 --- a/chrome/browser/password_manager/login_database_unittest.cc +++ b/chrome/browser/password_manager/login_database_unittest.cc @@ -7,7 +7,8 @@ #include "base/basictypes.h" #include "base/file_util.h" #include "base/path_service.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" +#include "base/string_util.h" // TODO(brettw) remove when ASCIIToUTF16 moves. #include "base/time.h" #include "chrome/browser/password_manager/login_database.h" #include "chrome/common/chrome_paths.h" @@ -21,7 +22,7 @@ class LoginDatabaseTest : public testing::Test { PathService::Get(chrome::DIR_TEST_DATA, &file_); const std::string test_db = "TestMetadataStoreMacDatabase" + - Int64ToString(base::Time::Now().ToInternalValue()) + ".db"; + base::Int64ToString(base::Time::Now().ToInternalValue()) + ".db"; file_ = file_.AppendASCII(test_db); file_util::Delete(file_, false); } diff --git a/chrome/browser/password_manager/native_backend_gnome_x.cc b/chrome/browser/password_manager/native_backend_gnome_x.cc index 667611e..aeaf40d 100644 --- a/chrome/browser/password_manager/native_backend_gnome_x.cc +++ b/chrome/browser/password_manager/native_backend_gnome_x.cc @@ -13,6 +13,7 @@ #include <vector> #include "base/logging.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/time.h" #include "base/utf_string_conversions.h" @@ -321,7 +322,7 @@ void GKRMethod::AddLogin(const PasswordForm& form) { "signon_realm", form.signon_realm.c_str(), "ssl_valid", form.ssl_valid, "preferred", form.preferred, - "date_created", Int64ToString(form.date_created.ToTimeT()).c_str(), + "date_created", base::Int64ToString(form.date_created.ToTimeT()).c_str(), "blacklisted_by_user", form.blacklisted_by_user, "scheme", form.scheme, "application", GNOME_KEYRING_APPLICATION_CHROME, diff --git a/chrome/browser/process_info_snapshot_mac.cc b/chrome/browser/process_info_snapshot_mac.cc index e7ff4db..0f20080 100644 --- a/chrome/browser/process_info_snapshot_mac.cc +++ b/chrome/browser/process_info_snapshot_mac.cc @@ -8,6 +8,7 @@ #include "base/command_line.h" #include "base/logging.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/thread.h" @@ -50,7 +51,7 @@ bool ProcessInfoSnapshot::Sample(std::vector<base::ProcessId> pid_list) { for (std::vector<base::ProcessId>::iterator it = pid_list.begin(); it != pid_list.end(); ++it) { argv.push_back("-p"); - argv.push_back(Int64ToString(static_cast<int64>(*it))); + argv.push_back(base::Int64ToString(static_cast<int64>(*it))); } std::string output; diff --git a/chrome/browser/renderer_host/render_sandbox_host_linux.cc b/chrome/browser/renderer_host/render_sandbox_host_linux.cc index 3656c47..1b07361 100644 --- a/chrome/browser/renderer_host/render_sandbox_host_linux.cc +++ b/chrome/browser/renderer_host/render_sandbox_host_linux.cc @@ -23,6 +23,7 @@ #include "base/process_util.h" #include "base/scoped_ptr.h" #include "base/shared_memory.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/unix_domain_socket_posix.h" #include "chrome/common/sandbox_methods_linux.h" @@ -336,7 +337,7 @@ class SandboxIPCProcess { std::string inode_output; std::vector<std::string> sandbox_cmd = sandbox_cmd_; - sandbox_cmd.push_back(Int64ToString(inode)); + sandbox_cmd.push_back(base::Int64ToString(inode)); CommandLine get_inode_cmd(sandbox_cmd); if (base::GetAppOutput(get_inode_cmd, &inode_output)) StringToInt(inode_output, &pid); diff --git a/chrome/browser/safe_browsing/chunk_range.cc b/chrome/browser/safe_browsing/chunk_range.cc index 112d71a..c42fab3 100644 --- a/chrome/browser/safe_browsing/chunk_range.cc +++ b/chrome/browser/safe_browsing/chunk_range.cc @@ -7,6 +7,7 @@ #include "chrome/browser/safe_browsing/chunk_range.h" #include "base/logging.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" ChunkRange::ChunkRange(int start) : start_(start), stop_(start) { @@ -61,7 +62,7 @@ void RangesToString(const std::vector<ChunkRange>& ranges, if (!result->empty()) result->append(","); if (it->start() == it->stop()) { - std::string num_buf = IntToString(it->start()); + std::string num_buf = base::IntToString(it->start()); result->append(num_buf); } else { result->append(StringPrintf("%d-%d", it->start(), it->stop())); diff --git a/chrome/browser/search_engines/template_url.cc b/chrome/browser/search_engines/template_url.cc index beed6d3..3bdd459 100644 --- a/chrome/browser/search_engines/template_url.cc +++ b/chrome/browser/search_engines/template_url.cc @@ -8,6 +8,7 @@ #include "base/i18n/icu_string_conversions.h" #include "base/i18n/rtl.h" #include "base/logging.h" +#include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/google_url_tracker.h" @@ -109,11 +110,11 @@ bool TemplateURLRef::ParseParameter(size_t start, url->insert(start, kDefaultCount); } else if (parameter == kStartIndexParameter) { if (!optional) { - url->insert(start, IntToString(index_offset_)); + url->insert(start, base::IntToString(index_offset_)); } } else if (parameter == kStartPageParameter) { if (!optional) { - url->insert(start, IntToString(page_offset_)); + url->insert(start, base::IntToString(page_offset_)); } } else if (parameter == kLanguageParameter) { replacements->push_back(Replacement(LANGUAGE, start)); diff --git a/chrome/browser/search_engines/template_url_model.cc b/chrome/browser/search_engines/template_url_model.cc index ede0ea0..9e12822 100644 --- a/chrome/browser/search_engines/template_url_model.cc +++ b/chrome/browser/search_engines/template_url_model.cc @@ -6,6 +6,7 @@ #include "app/l10n_util.h" #include "base/stl_util-inl.h" +#include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/google_url_tracker.h" @@ -818,11 +819,11 @@ void TemplateURLModel::SaveDefaultSearchProviderToPrefs( prefs->SetString(prefs::kDefaultSearchProviderName, name); const std::string id_string = - t_url ? Int64ToString(t_url->id()) : std::string(); + t_url ? base::Int64ToString(t_url->id()) : std::string(); prefs->SetString(prefs::kDefaultSearchProviderID, id_string); const std::string prepopulate_id = - t_url ? Int64ToString(t_url->prepopulate_id()) : std::string(); + t_url ? base::Int64ToString(t_url->prepopulate_id()) : std::string(); prefs->SetString(prefs::kDefaultSearchProviderPrepopulateID, prepopulate_id); prefs->ScheduleSavePersistentPrefs(); diff --git a/chrome/browser/sessions/session_service_unittest.cc b/chrome/browser/sessions/session_service_unittest.cc index 5b30328..ce7354e 100644 --- a/chrome/browser/sessions/session_service_unittest.cc +++ b/chrome/browser/sessions/session_service_unittest.cc @@ -7,7 +7,7 @@ #include "base/scoped_ptr.h" #include "base/scoped_vector.h" #include "base/stl_util-inl.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/time.h" #include "chrome/browser/defaults.h" #include "chrome/browser/sessions/session_backend.h" @@ -32,7 +32,7 @@ class SessionServiceTest : public BrowserWithTestWindowTest, protected: virtual void SetUp() { BrowserWithTestWindowTest::SetUp(); - std::string b = Int64ToString(base::Time::Now().ToInternalValue()); + std::string b = base::Int64ToString(base::Time::Now().ToInternalValue()); PathService::Get(base::DIR_TEMP, &path_); path_ = path_.Append(FILE_PATH_LITERAL("SessionTestDirs")); @@ -510,7 +510,7 @@ TEST_F(SessionServiceTest, PruneFromFront) { // Add 5 navigations, with the 4th selected. for (int i = 0; i < 5; ++i) { - TabNavigation nav(0, GURL(base_url + IntToString(i)), GURL(), + TabNavigation nav(0, GURL(base_url + base::IntToString(i)), GURL(), ASCIIToUTF16("a"), "b", PageTransition::QUALIFIER_MASK); UpdateNavigation(window_id, tab_id, nav, i, (i == 3)); } @@ -534,11 +534,11 @@ TEST_F(SessionServiceTest, PruneFromFront) { SessionTab* tab = windows[0]->tabs[0]; ASSERT_EQ(1, tab->current_navigation_index); EXPECT_EQ(3U, tab->navigations.size()); - EXPECT_TRUE(GURL(base_url + IntToString(2)) == + EXPECT_TRUE(GURL(base_url + base::IntToString(2)) == tab->navigations[0].virtual_url()); - EXPECT_TRUE(GURL(base_url + IntToString(3)) == + EXPECT_TRUE(GURL(base_url + base::IntToString(3)) == tab->navigations[1].virtual_url()); - EXPECT_TRUE(GURL(base_url + IntToString(4)) == + EXPECT_TRUE(GURL(base_url + base::IntToString(4)) == tab->navigations[2].virtual_url()); } @@ -551,7 +551,7 @@ TEST_F(SessionServiceTest, PruneToEmpty) { // Add 5 navigations, with the 4th selected. for (int i = 0; i < 5; ++i) { - TabNavigation nav(0, GURL(base_url + IntToString(i)), GURL(), + TabNavigation nav(0, GURL(base_url + base::IntToString(i)), GURL(), ASCIIToUTF16("a"), "b", PageTransition::QUALIFIER_MASK); UpdateNavigation(window_id, tab_id, nav, i, (i == 3)); } diff --git a/chrome/browser/shell_integration_linux.cc b/chrome/browser/shell_integration_linux.cc index a2b8aa8..f1dac7b 100644 --- a/chrome/browser/shell_integration_linux.cc +++ b/chrome/browser/shell_integration_linux.cc @@ -27,6 +27,7 @@ #include "base/string_util.h" #include "base/task.h" #include "base/thread.h" +#include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "chrome/browser/browser_process.h" #include "chrome/common/chrome_constants.h" @@ -303,8 +304,8 @@ FilePath ShellIntegration::GetDesktopShortcutFilename(const GURL& url) { FilePath alternative_filepath(filepath.value() + ".desktop"); for (size_t i = 1; i < 100; ++i) { if (file_util::PathExists(FilePath(alternative_filepath))) { - alternative_filepath = FilePath(filepath.value() + "_" + IntToString(i) + - ".desktop"); + alternative_filepath = FilePath( + filepath.value() + "_" + base::IntToString(i) + ".desktop"); } else { return FilePath(alternative_filepath).BaseName(); } diff --git a/chrome/browser/ssl/ssl_add_cert_handler.cc b/chrome/browser/ssl/ssl_add_cert_handler.cc index 691e8773..210c502 100644 --- a/chrome/browser/ssl/ssl_add_cert_handler.cc +++ b/chrome/browser/ssl/ssl_add_cert_handler.cc @@ -5,7 +5,7 @@ #include "chrome/browser/ssl/ssl_add_cert_handler.h" #include "app/l10n_util.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_window.h" @@ -37,7 +37,7 @@ void SSLAddCertHandler::RunUI() { // TODO(snej): Map cert_error to a more specific error message. ShowError(l10n_util::GetStringFUTF16( IDS_ADD_CERT_ERR_INVALID_CERT, - IntToString16(-cert_error), + base::IntToString16(-cert_error), ASCIIToUTF16(net::ErrorToString(cert_error)))); Finished(false); return; @@ -60,7 +60,7 @@ void SSLAddCertHandler::Finished(bool add_cert) { // TODO(snej): Map cert_error to a more specific error message. ShowError(l10n_util::GetStringFUTF16( IDS_ADD_CERT_ERR_FAILED, - IntToString16(-cert_error), + base::IntToString16(-cert_error), ASCIIToUTF16(net::ErrorToString(cert_error)))); } } diff --git a/chrome/browser/sync/engine/syncer_unittest.cc b/chrome/browser/sync/engine/syncer_unittest.cc index ae6e597..9db596a 100644 --- a/chrome/browser/sync/engine/syncer_unittest.cc +++ b/chrome/browser/sync/engine/syncer_unittest.cc @@ -14,6 +14,7 @@ #include "base/callback.h" #include "base/scoped_ptr.h" +#include "base/string_number_conversions.h" #include "build/build_config.h" #include "chrome/browser/sync/engine/conflict_resolver.h" #include "chrome/browser/sync/engine/get_commit_ids_command.h" @@ -4982,7 +4983,7 @@ class SyncerPositionUpdateTest : public SyncerTest { } void AddRootItemWithPosition(int64 position) { - string id = string("ServerId") + Int64ToString(next_update_id_++); + string id = string("ServerId") + base::Int64ToString(next_update_id_++); string name = "my name is my id -- " + id; int revision = next_revision_++; mock_server_->AddUpdateDirectory(id, kRootId, name, revision, revision); diff --git a/chrome/browser/sync/glue/http_bridge.cc b/chrome/browser/sync/glue/http_bridge.cc index a442953..e39e6ff 100644 --- a/chrome/browser/sync/glue/http_bridge.cc +++ b/chrome/browser/sync/glue/http_bridge.cc @@ -6,7 +6,7 @@ #include "base/message_loop.h" #include "base/message_loop_proxy.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/profile.h" #include "chrome/browser/chrome_thread.h" @@ -143,7 +143,7 @@ void HttpBridge::SetURL(const char* url, int port) { << "HttpBridge::SetURL called more than once?!"; GURL temp(url); GURL::Replacements replacements; - std::string port_str = IntToString(port); + std::string port_str = base::IntToString(port); replacements.SetPort(port_str.c_str(), url_parse::Component(0, port_str.length())); url_for_request_ = temp.ReplaceComponents(replacements); diff --git a/chrome/browser/sync/notifier/cache_invalidation_packet_handler.cc b/chrome/browser/sync/notifier/cache_invalidation_packet_handler.cc index 7edfc73..a4c36dd 100644 --- a/chrome/browser/sync/notifier/cache_invalidation_packet_handler.cc +++ b/chrome/browser/sync/notifier/cache_invalidation_packet_handler.cc @@ -10,7 +10,8 @@ #include "base/callback.h" #include "base/logging.h" #include "base/rand_util.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" +//#include "base/string_util.h" #include "chrome/browser/sync/sync_constants.h" #include "google/cacheinvalidation/invalidation-client.h" #include "jingle/notifier/listener/xml_element_util.h" @@ -170,7 +171,7 @@ class CacheInvalidationSendMessageTask : public buzz::XmppTask { buzz::XmlElement* cache_invalidation_iq_packet = new buzz::XmlElement(kQnData, true); iq->AddElement(cache_invalidation_iq_packet); - cache_invalidation_iq_packet->SetAttr(kQnSeq, IntToString(seq)); + cache_invalidation_iq_packet->SetAttr(kQnSeq, base::IntToString(seq)); cache_invalidation_iq_packet->SetAttr(kQnSid, sid); cache_invalidation_iq_packet->SetAttr(kQnServiceUrl, browser_sync::kSyncServiceUrl); @@ -188,7 +189,7 @@ class CacheInvalidationSendMessageTask : public buzz::XmppTask { std::string MakeSid() { uint64 sid = base::RandUint64(); - return std::string("chrome-sync-") + Uint64ToString(sid); + return std::string("chrome-sync-") + base::Uint64ToString(sid); } } // namespace diff --git a/chrome/browser/sync/syncable/directory_backing_store.cc b/chrome/browser/sync/syncable/directory_backing_store.cc index c5bfdb0..8cec2a9 100644 --- a/chrome/browser/sync/syncable/directory_backing_store.cc +++ b/chrome/browser/sync/syncable/directory_backing_store.cc @@ -16,6 +16,7 @@ #include "base/hash_tables.h" #include "base/logging.h" #include "base/stl_util-inl.h" +#include "base/string_number_conversions.h" #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" #include "chrome/browser/sync/protocol/service_constants.h" #include "chrome/browser/sync/protocol/sync.pb.h" @@ -286,7 +287,7 @@ bool DirectoryBackingStore::DeleteEntries(const MetahandleSet& handles) { ++it) { if (it != handles.begin()) query.append(","); - query.append(Int64ToString(*it)); + query.append(base::Int64ToString(*it)); } query.append(")"); SQLStatement statement; diff --git a/chrome/browser/sync/syncable/syncable.cc b/chrome/browser/sync/syncable/syncable.cc index cf19379..807abf6 100644 --- a/chrome/browser/sync/syncable/syncable.cc +++ b/chrome/browser/sync/syncable/syncable.cc @@ -31,7 +31,7 @@ #include "base/logging.h" #include "base/perftimer.h" #include "base/scoped_ptr.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/stl_util-inl.h" #include "base/time.h" #include "chrome/browser/sync/engine/syncer.h" @@ -1441,7 +1441,7 @@ Id Directory::NextId() { kernel_->info_status = KERNEL_SHARE_INFO_DIRTY; } DCHECK_LT(result, 0); - return Id::CreateFromClientString(Int64ToString(result)); + return Id::CreateFromClientString(base::Int64ToString(result)); } Id Directory::GetChildWithNullIdField(IdField field, diff --git a/chrome/browser/sync/util/fast_dump.h b/chrome/browser/sync/util/fast_dump.h index a9eff24..28d1484 100644 --- a/chrome/browser/sync/util/fast_dump.h +++ b/chrome/browser/sync/util/fast_dump.h @@ -10,7 +10,7 @@ #include <streambuf> #include <string> -#include "base/string_util.h" +#include "base/string_number_conversions.h" using std::ostream; using std::streambuf; @@ -32,7 +32,7 @@ class FastDump { inline browser_sync::FastDump& operator << (browser_sync::FastDump& dump, int64 n) { - string numbuf(Int64ToString(n)); + string numbuf(base::Int64ToString(n)); const char* number = numbuf.c_str(); dump.out_->sputn(number, numbuf.length()); return dump; @@ -40,7 +40,7 @@ inline browser_sync::FastDump& operator << inline browser_sync::FastDump& operator << (browser_sync::FastDump& dump, int32 n) { - string numbuf(IntToString(n)); + string numbuf(base::IntToString(n)); const char* number = numbuf.c_str(); dump.out_->sputn(number, numbuf.length()); return dump; diff --git a/chrome/browser/tabs/tab_strip_model_unittest.cc b/chrome/browser/tabs/tab_strip_model_unittest.cc index c864f27..c885d5f 100644 --- a/chrome/browser/tabs/tab_strip_model_unittest.cc +++ b/chrome/browser/tabs/tab_strip_model_unittest.cc @@ -148,7 +148,7 @@ class TabStripModelTest : public RenderViewHostTestHarness { if (i > 0) actual += " "; - actual += IntToString(GetID(model.GetTabContentsAt(i))); + actual += base::IntToString(GetID(model.GetTabContentsAt(i))); if (model.IsAppTab(i)) actual += "a"; @@ -171,7 +171,7 @@ class TabStripModelTest : public RenderViewHostTestHarness { for (size_t i = 0; i < indices.size(); ++i) { if (i != 0) result += " "; - result += IntToString(indices[i]); + result += base::IntToString(indices[i]); } return result; } diff --git a/chrome/browser/views/autofill_profiles_view_win.cc b/chrome/browser/views/autofill_profiles_view_win.cc index 1e53a9a..ffd477e 100644 --- a/chrome/browser/views/autofill_profiles_view_win.cc +++ b/chrome/browser/views/autofill_profiles_view_win.cc @@ -1,6 +1,7 @@ // Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. + #include "chrome/browser/views/autofill_profiles_view_win.h" #include <vsstyle.h> @@ -9,7 +10,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/message_loop.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/time.h" #include "chrome/browser/autofill/autofill_manager.h" #include "chrome/browser/autofill/phone_number.h" @@ -877,7 +878,7 @@ void AutoFillProfilesView::EditableSetViewContents::ItemChanged( } else { DCHECK(new_index < static_cast<int>(observer_->profiles_set_.size())); temporary_info_.credit_card.set_billing_address( - IntToString16( + base::IntToString16( observer_->profiles_set_[new_index].address.unique_id())); } } else if (combo_box == combo_box_month_) { diff --git a/chrome/browser/views/bookmark_bar_view_test.cc b/chrome/browser/views/bookmark_bar_view_test.cc index 5c4c722..454c194 100644 --- a/chrome/browser/views/bookmark_bar_view_test.cc +++ b/chrome/browser/views/bookmark_bar_view_test.cc @@ -3,7 +3,7 @@ // found in the LICENSE file. #include "base/keyboard_codes.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "chrome/browser/automation/ui_controls.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/bookmarks/bookmark_utils.h" @@ -221,8 +221,8 @@ class BookmarkBarViewEventTestBase : public ViewEventTestBase { model_->AddURL(f11, 0, L"f11a", GURL(test_base + "f11a")); if (big_menu) { for (int i = 1; i <= 100; ++i) { - model_->AddURL(f1, i + 1, L"f" + IntToWString(i), - GURL(test_base + "f" + IntToString(i))); + model_->AddURL(f1, i + 1, L"f" + UTF8ToWide(base::IntToString(i)), + GURL(test_base + "f" + base::IntToString(i))); } } model_->AddURL(model_->GetBookmarkBarNode(), 1, L"a", diff --git a/chrome/browser/webdata/web_database_unittest.cc b/chrome/browser/webdata/web_database_unittest.cc index ce13dbf..59a2cfa6 100644 --- a/chrome/browser/webdata/web_database_unittest.cc +++ b/chrome/browser/webdata/web_database_unittest.cc @@ -12,7 +12,7 @@ #include "base/file_util.h" #include "base/path_service.h" #include "base/stl_util-inl.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/string16.h" #include "base/time.h" #include "base/values.h" @@ -100,7 +100,7 @@ class WebDatabaseTest : public testing::Test { #endif PathService::Get(chrome::DIR_TEST_DATA, &file_); const std::string test_db = "TestWebDatabase" + - Int64ToString(base::Time::Now().ToInternalValue()) + + base::Int64ToString(base::Time::Now().ToInternalValue()) + ".db"; file_ = file_.AppendASCII(test_db); file_util::Delete(file_, false); diff --git a/chrome/browser/wrench_menu_model.cc b/chrome/browser/wrench_menu_model.cc index 27d8e09..367b700 100644 --- a/chrome/browser/wrench_menu_model.cc +++ b/chrome/browser/wrench_menu_model.cc @@ -10,6 +10,7 @@ #include "app/l10n_util.h" #include "app/menus/button_menu_item_model.h" #include "app/resource_bundle.h" +#include "base/string_number_conversions.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_process.h" @@ -354,7 +355,7 @@ void WrenchMenuModel::UpdateZoomControls() { int zoom_percent = static_cast<int>(GetZoom(&enable_increment, &enable_decrement) * 100); zoom_label_ = l10n_util::GetStringFUTF16( - IDS_ZOOM_PERCENT, IntToString16(zoom_percent)); + IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); } double WrenchMenuModel::GetZoom(bool* enable_increment, diff --git a/chrome/browser/zygote_host_linux.cc b/chrome/browser/zygote_host_linux.cc index 5c58d6c..75987a4 100644 --- a/chrome/browser/zygote_host_linux.cc +++ b/chrome/browser/zygote_host_linux.cc @@ -16,6 +16,7 @@ #include "base/path_service.h" #include "base/pickle.h" #include "base/process_util.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/unix_domain_socket_posix.h" @@ -156,7 +157,7 @@ void ZygoteHost::Init(const std::string& sandbox_cmd) { std::vector<std::string> get_inode_cmdline; get_inode_cmdline.push_back(sandbox_binary_); get_inode_cmdline.push_back(base::kFindInodeSwitch); - get_inode_cmdline.push_back(Int64ToString(inode)); + get_inode_cmdline.push_back(base::Int64ToString(inode)); CommandLine get_inode_cmd(get_inode_cmdline); if (base::GetAppOutput(get_inode_cmd, &inode_output)) { StringToInt(inode_output, &pid_); @@ -272,8 +273,8 @@ pid_t ZygoteHost::ForkRenderer( adj_oom_score_cmdline.push_back(sandbox_binary_); adj_oom_score_cmdline.push_back(base::kAdjustOOMScoreSwitch); - adj_oom_score_cmdline.push_back(Int64ToString(pid)); - adj_oom_score_cmdline.push_back(IntToString(kRendererScore)); + adj_oom_score_cmdline.push_back(base::Int64ToString(pid)); + adj_oom_score_cmdline.push_back(base::IntToString(kRendererScore)); CommandLine adj_oom_score_cmd(adj_oom_score_cmdline); if (base::LaunchApp(adj_oom_score_cmdline, dummy_map, false, &sandbox_helper_process)) { diff --git a/chrome/common/child_process.cc b/chrome/common/child_process.cc index 71d025a..e64f0f3 100644 --- a/chrome/common/child_process.cc +++ b/chrome/common/child_process.cc @@ -11,8 +11,9 @@ #include "app/l10n_util.h" #include "base/message_loop.h" #include "base/process_util.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/thread.h" +#include "base/utf_string_conversions.h" #include "chrome/common/child_thread.h" #include "grit/chromium_strings.h" @@ -76,7 +77,7 @@ void ChildProcess::WaitForDebugger(const std::wstring& label) { std::wstring title = l10n_util::GetString(IDS_PRODUCT_NAME); std::wstring message = label; message += L" starting with pid: "; - message += IntToWString(base::GetCurrentProcId()); + message += UTF8ToWide(base::IntToString(base::GetCurrentProcId())); title += L" "; title += label; // makes attaching to process easier ::MessageBox(NULL, message.c_str(), title.c_str(), diff --git a/chrome/common/child_process_logging_mac.mm b/chrome/common/child_process_logging_mac.mm index f0356cd..a53b4ed 100644 --- a/chrome/common/child_process_logging_mac.mm +++ b/chrome/common/child_process_logging_mac.mm @@ -6,7 +6,9 @@ #import <Foundation/Foundation.h> +#include "base/string_number_conversions.h" #include "base/string_util.h" +#include "base/utf_string_conversions.h" #include "chrome/common/gpu_info.h" #include "chrome/installer/util/google_update_settings.h" #include "googleurl/src/gurl.h" @@ -112,19 +114,19 @@ void SetGpuKeyValue(const char* param_name, const std::string& value_str, void SetGpuInfoImpl(const GPUInfo& gpu_info, SetCrashKeyValueFuncPtr set_key_func) { SetGpuKeyValue(kGPUVendorIdParamName, - UintToString(gpu_info.vendor_id()), + base::UintToString(gpu_info.vendor_id()), set_key_func); SetGpuKeyValue(kGPUDeviceIdParamName, - UintToString(gpu_info.device_id()), + base::UintToString(gpu_info.device_id()), set_key_func); SetGpuKeyValue(kGPUDriverVersionParamName, - WideToASCII(gpu_info.driver_version()), + WideToUTF8(gpu_info.driver_version()), set_key_func); SetGpuKeyValue(kGPUPixelShaderVersionParamName, - UintToString(gpu_info.pixel_shader_version()), + base::UintToString(gpu_info.pixel_shader_version()), set_key_func); SetGpuKeyValue(kGPUVertexShaderVersionParamName, - UintToString(gpu_info.vertex_shader_version()), + base::UintToString(gpu_info.vertex_shader_version()), set_key_func); } diff --git a/chrome/common/child_process_logging_win.cc b/chrome/common/child_process_logging_win.cc index 1b18e6e..f5ffd84 100644 --- a/chrome/common/child_process_logging_win.cc +++ b/chrome/common/child_process_logging_win.cc @@ -7,6 +7,7 @@ #include <windows.h> #include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "chrome/common/chrome_constants.h" #include "chrome/installer/util/google_update_settings.h" @@ -105,11 +106,12 @@ void SetGpuInfo(const GPUInfo& gpu_info) { if (!set_gpu_info) return; } - (set_gpu_info)(UintToWString(gpu_info.vendor_id()).c_str(), - UintToWString(gpu_info.device_id()).c_str(), - gpu_info.driver_version().c_str(), - UintToWString(gpu_info.pixel_shader_version()).c_str(), - UintToWString(gpu_info.vertex_shader_version()).c_str()); + (set_gpu_info)( + base::UintToString16(gpu_info.vendor_id()).c_str(), + base::UintToString16(gpu_info.device_id()).c_str(), + gpu_info.driver_version().c_str(), + base::UintToString16(gpu_info.pixel_shader_version()).c_str(), + base::UintToString16(gpu_info.vertex_shader_version()).c_str()); } } // namespace child_process_logging diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc index 9db8117..d32ef66 100644 --- a/chrome/common/extensions/extension.cc +++ b/chrome/common/extensions/extension.cc @@ -18,6 +18,7 @@ #include "base/stl_util-inl.h" #include "base/third_party/nss/blapi.h" #include "base/third_party/nss/sha256.h" +#include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" @@ -61,8 +62,13 @@ const int kRSAKeySize = 1024; // completely numeric host, since some software interprets that as an IP // address. static void ConvertHexadecimalToIDAlphabet(std::string* id) { - for (size_t i = 0; i < id->size(); ++i) - (*id)[i] = HexStringToInt(id->substr(i, 1)) + 'a'; + for (size_t i = 0; i < id->size(); ++i) { + int val; + if (base::HexStringToInt(id->substr(i, 1), &val)) + (*id)[i] = val + 'a'; + else + (*id)[i] = 'a'; + } } const int kValidWebExtentSchemes = @@ -221,7 +227,7 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script, std::string run_location; if (!content_script->GetString(keys::kRunAt, &run_location)) { *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidRunAt, - IntToString(definition_index)); + base::IntToString(definition_index)); return false; } @@ -233,7 +239,7 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script, result->set_run_location(UserScript::DOCUMENT_IDLE); } else { *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidRunAt, - IntToString(definition_index)); + base::IntToString(definition_index)); return false; } } @@ -243,7 +249,7 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script, bool all_frames = false; if (!content_script->GetBoolean(keys::kAllFrames, &all_frames)) { *error = ExtensionErrorUtils::FormatErrorMessage( - errors::kInvalidAllFrames, IntToString(definition_index)); + errors::kInvalidAllFrames, base::IntToString(definition_index)); return false; } result->set_match_all_frames(all_frames); @@ -253,27 +259,27 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script, ListValue* matches = NULL; if (!content_script->GetList(keys::kMatches, &matches)) { *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidMatches, - IntToString(definition_index)); + base::IntToString(definition_index)); return false; } if (matches->GetSize() == 0) { *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidMatchCount, - IntToString(definition_index)); + base::IntToString(definition_index)); return false; } for (size_t j = 0; j < matches->GetSize(); ++j) { std::string match_str; if (!matches->GetString(j, &match_str)) { *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidMatch, - IntToString(definition_index), IntToString(j)); + base::IntToString(definition_index), base::IntToString(j)); return false; } URLPattern pattern(UserScript::kValidUserScriptSchemes); if (!pattern.Parse(match_str)) { *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidMatch, - IntToString(definition_index), IntToString(j)); + base::IntToString(definition_index), base::IntToString(j)); return false; } @@ -296,7 +302,7 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script, if (content_script->HasKey(keys::kJs) && !content_script->GetList(keys::kJs, &js)) { *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidJsList, - IntToString(definition_index)); + base::IntToString(definition_index)); return false; } @@ -304,14 +310,14 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script, if (content_script->HasKey(keys::kCss) && !content_script->GetList(keys::kCss, &css)) { *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidCssList, - IntToString(definition_index)); + base::IntToString(definition_index)); return false; } // The manifest needs to have at least one js or css user script definition. if (((js ? js->GetSize() : 0) + (css ? css->GetSize() : 0)) == 0) { *error = ExtensionErrorUtils::FormatErrorMessage(errors::kMissingFile, - IntToString(definition_index)); + base::IntToString(definition_index)); return false; } @@ -322,7 +328,8 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script, std::string relative; if (!js->Get(script_index, &value) || !value->GetAsString(&relative)) { *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidJs, - IntToString(definition_index), IntToString(script_index)); + base::IntToString(definition_index), + base::IntToString(script_index)); return false; } GURL url = GetResourceURL(relative); @@ -339,7 +346,8 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script, std::string relative; if (!css->Get(script_index, &value) || !value->GetAsString(&relative)) { *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidCss, - IntToString(definition_index), IntToString(script_index)); + base::IntToString(definition_index), + base::IntToString(script_index)); return false; } GURL url = GetResourceURL(relative); @@ -365,7 +373,8 @@ bool Extension::LoadGlobsHelper( ListValue* list = NULL; if (!content_script->GetList(globs_property_name, &list)) { *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidGlobList, - IntToString(content_script_index), WideToASCII(globs_property_name)); + base::IntToString(content_script_index), + WideToUTF8(globs_property_name)); return false; } @@ -373,8 +382,9 @@ bool Extension::LoadGlobsHelper( std::string glob; if (!list->GetString(i, &glob)) { *error = ExtensionErrorUtils::FormatErrorMessage(errors::kInvalidGlob, - IntToString(content_script_index), WideToASCII(globs_property_name), - IntToString(i)); + base::IntToString(content_script_index), + WideToUTF8(globs_property_name), + base::IntToString(i)); return false; } @@ -558,14 +568,14 @@ bool Extension::LoadExtent(const DictionaryValue* manifest, std::string pattern_string; if (!pattern_list->GetString(i, &pattern_string)) { *error = ExtensionErrorUtils::FormatErrorMessage(value_error, - UintToString(i)); + base::UintToString(i)); return false; } URLPattern pattern(kValidWebExtentSchemes); if (!pattern.Parse(pattern_string)) { *error = ExtensionErrorUtils::FormatErrorMessage(value_error, - UintToString(i)); + base::UintToString(i)); return false; } @@ -573,7 +583,7 @@ bool Extension::LoadExtent(const DictionaryValue* manifest, // imply one at the end. if (pattern.path().find('*') != std::string::npos) { *error = ExtensionErrorUtils::FormatErrorMessage(value_error, - UintToString(i)); + base::UintToString(i)); return false; } pattern.set_path(pattern.path() + '*'); @@ -925,8 +935,8 @@ void Extension::DecodeIconFromPath(const FilePath& icon_path, if (decoded->width() != icon_size || decoded->height() != icon_size) { LOG(ERROR) << "Icon file has unexpected size: " - << IntToString(decoded->width()) << "x" - << IntToString(decoded->height()); + << base::IntToString(decoded->width()) << "x" + << base::IntToString(decoded->height()); return; } @@ -1074,7 +1084,7 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key, } for (size_t i = 0; i < arraysize(kIconSizes); ++i) { - std::wstring key = ASCIIToWide(IntToString(kIconSizes[i])); + std::wstring key = ASCIIToWide(base::IntToString(kIconSizes[i])); if (icons_value->HasKey(key)) { std::string icon_path; if (!icons_value->GetString(key, &icon_path)) { @@ -1199,7 +1209,7 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key, // Get plugins[i].path. if (!plugin_value->GetString(keys::kPluginsPath, &path)) { *error = ExtensionErrorUtils::FormatErrorMessage( - errors::kInvalidPluginsPath, IntToString(i)); + errors::kInvalidPluginsPath, base::IntToString(i)); return false; } @@ -1207,7 +1217,7 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key, if (plugin_value->HasKey(keys::kPluginsPublic)) { if (!plugin_value->GetBoolean(keys::kPluginsPublic, &is_public)) { *error = ExtensionErrorUtils::FormatErrorMessage( - errors::kInvalidPluginsPublic, IntToString(i)); + errors::kInvalidPluginsPublic, base::IntToString(i)); return false; } } @@ -1260,7 +1270,7 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key, if (!toolstrip_value->GetString(keys::kToolstripPath, &toolstrip_path)) { *error = ExtensionErrorUtils::FormatErrorMessage( - errors::kInvalidToolstrip, IntToString(i)); + errors::kInvalidToolstrip, base::IntToString(i)); return false; } toolstrip.toolstrip = GetResourceURL(toolstrip_path); @@ -1269,14 +1279,14 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key, if (!toolstrip_value->GetString(keys::kToolstripMolePath, &mole_path)) { *error = ExtensionErrorUtils::FormatErrorMessage( - errors::kInvalidToolstrip, IntToString(i)); + errors::kInvalidToolstrip, base::IntToString(i)); return false; } int height; if (!toolstrip_value->GetInteger(keys::kToolstripMoleHeight, &height) || (height < 0)) { *error = ExtensionErrorUtils::FormatErrorMessage( - errors::kInvalidToolstrip, IntToString(i)); + errors::kInvalidToolstrip, base::IntToString(i)); return false; } toolstrip.mole = GetResourceURL(mole_path); @@ -1284,7 +1294,7 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key, } } else { *error = ExtensionErrorUtils::FormatErrorMessage( - errors::kInvalidToolstrip, IntToString(i)); + errors::kInvalidToolstrip, base::IntToString(i)); return false; } toolstrips_.push_back(toolstrip); @@ -1303,7 +1313,7 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key, DictionaryValue* content_script; if (!list_value->GetDictionary(i, &content_script)) { *error = ExtensionErrorUtils::FormatErrorMessage( - errors::kInvalidContentScript, IntToString(i)); + errors::kInvalidContentScript, base::IntToString(i)); return false; } @@ -1391,7 +1401,7 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key, std::string permission_str; if (!permissions->GetString(i, &permission_str)) { *error = ExtensionErrorUtils::FormatErrorMessage( - errors::kInvalidPermission, IntToString(i)); + errors::kInvalidPermission, base::IntToString(i)); return false; } @@ -1407,13 +1417,13 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key, URLPattern::SCHEME_CHROMEUI); if (!pattern.Parse(permission_str)) { *error = ExtensionErrorUtils::FormatErrorMessage( - errors::kInvalidPermission, IntToString(i)); + errors::kInvalidPermission, base::IntToString(i)); return false; } if (!CanAccessURL(pattern)) { *error = ExtensionErrorUtils::FormatErrorMessage( - errors::kInvalidPermissionScheme, IntToString(i)); + errors::kInvalidPermissionScheme, base::IntToString(i)); return false; } @@ -1579,7 +1589,8 @@ void Extension::SetBackgroundPageReady() { } static std::string SizeToString(const gfx::Size& max_size) { - return IntToString(max_size.width()) + "x" + IntToString(max_size.height()); + return base::IntToString(max_size.width()) + "x" + + base::IntToString(max_size.height()); } void Extension::SetCachedImage(const ExtensionResource& source, diff --git a/chrome/common/extensions/update_manifest.cc b/chrome/common/extensions/update_manifest.cc index 4394a7b..ec8b444 100644 --- a/chrome/common/extensions/update_manifest.cc +++ b/chrome/common/extensions/update_manifest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -8,6 +8,7 @@ #include "base/stl_util-inl.h" #include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/values.h" #include "base/version.h" #include "chrome/common/libxml_utils.h" @@ -237,7 +238,7 @@ bool UpdateManifest::Parse(const std::string& manifest_xml) { xmlNode* first = daystarts[0]; std::string elapsed_seconds = GetAttribute(first, "elapsed_seconds"); int parsed_elapsed = kNoDaystart; - if (StringToInt(elapsed_seconds, &parsed_elapsed)) { + if (base::StringToInt(elapsed_seconds, &parsed_elapsed)) { results_.daystart_elapsed_seconds = parsed_elapsed; } } diff --git a/chrome/common/important_file_writer.cc b/chrome/common/important_file_writer.cc index 3466958..adda9fd 100644 --- a/chrome/common/important_file_writer.cc +++ b/chrome/common/important_file_writer.cc @@ -13,7 +13,7 @@ #include "base/file_util.h" #include "base/logging.h" #include "base/message_loop_proxy.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/task.h" #include "base/thread.h" #include "base/time.h" @@ -52,8 +52,8 @@ class WriteToDiskTask : public Task { } if (bytes_written < data_.length()) { file_util::Delete(tmp_file_path, false); - LogFailure("error writing, bytes_written=" + UintToString( - static_cast<unsigned int>(bytes_written))); + LogFailure("error writing, bytes_written=" + + base::Uint64ToString(bytes_written)); return; } diff --git a/chrome/common/logging_chrome.cc b/chrome/common/logging_chrome.cc index 9591170..b93ca60 100644 --- a/chrome/common/logging_chrome.cc +++ b/chrome/common/logging_chrome.cc @@ -38,6 +38,7 @@ #include "base/file_util.h" #include "base/logging.h" #include "base/path_service.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/time.h" #include "base/utf_string_conversions.h" @@ -210,7 +211,7 @@ void InitChromeLogging(const CommandLine& command_line, std::string log_level = command_line.GetSwitchValueASCII( switches::kLoggingLevel); int level = 0; - if (StringToInt(log_level, &level)) { + if (base::StringToInt(log_level, &level)) { if ((level >= 0) && (level < LOG_NUM_SEVERITIES)) logging::SetMinLogLevel(level); } else { diff --git a/chrome/common/metrics_helpers.cc b/chrome/common/metrics_helpers.cc index 3bbaf3b..ee465e4 100644 --- a/chrome/common/metrics_helpers.cc +++ b/chrome/common/metrics_helpers.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -17,7 +17,8 @@ #include "base/md5.h" #include "base/perftimer.h" #include "base/scoped_ptr.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" +#include "base/string_util.h" // TODO(brettw) remove when ASCIIToUTF16 moves. #include "base/sys_info.h" #include "base/utf_string_conversions.h" #include "base/third_party/nspr/prtime.h" @@ -100,7 +101,7 @@ MetricsLogBase::MetricsLogBase(const std::string& client_id, int session_id, const std::string& version_string) : start_time_(Time::Now()), client_id_(client_id), - session_id_(IntToString(session_id)), + session_id_(base::IntToString(session_id)), locked_(false), xml_wrapper_(new XmlWrapper), num_events_(0) { @@ -238,7 +239,7 @@ void MetricsLogBase::RecordLoadEvent(int window_id, WriteAttribute("action", "load"); WriteIntAttribute("docid", session_index); WriteIntAttribute("window", window_id); - WriteAttribute("loadtime", Int64ToString(load_time.InMilliseconds())); + WriteAttribute("loadtime", base::Int64ToString(load_time.InMilliseconds())); std::string origin_string; @@ -295,16 +296,16 @@ void MetricsLogBase::RecordWindowEvent(WindowEventType type, OPEN_ELEMENT_FOR_SCOPE("window"); WriteAttribute("action", WindowEventTypeToString(type)); - WriteAttribute("windowid", IntToString(window_id)); + WriteAttribute("windowid", base::IntToString(window_id)); if (parent_id >= 0) - WriteAttribute("parent", IntToString(parent_id)); + WriteAttribute("parent", base::IntToString(parent_id)); WriteCommonEventAttributes(); ++num_events_; } std::string MetricsLogBase::GetCurrentTimeString() { - return Uint64ToString(Time::Now().ToTimeT()); + return base::Uint64ToString(Time::Now().ToTimeT()); } // These are the attributes that are common to every event. @@ -325,11 +326,11 @@ void MetricsLogBase::WriteAttribute(const std::string& name, } void MetricsLogBase::WriteIntAttribute(const std::string& name, int value) { - WriteAttribute(name, IntToString(value)); + WriteAttribute(name, base::IntToString(value)); } void MetricsLogBase::WriteInt64Attribute(const std::string& name, int64 value) { - WriteAttribute(name, Int64ToString(value)); + WriteAttribute(name, base::Int64ToString(value)); } // static diff --git a/chrome/common/plugin_messages.h b/chrome/common/plugin_messages.h index 315a5d3..3cf8739 100644 --- a/chrome/common/plugin_messages.h +++ b/chrome/common/plugin_messages.h @@ -15,6 +15,8 @@ #include <vector> #include "base/basictypes.h" +#include "base/string_number_conversions.h" +#include "base/utf_string_conversions.h" #include "chrome/common/common_param_traits.h" #include "chrome/common/webkit_param_traits.h" #include "gfx/native_widget_types.h" @@ -304,8 +306,8 @@ struct ParamTraits<NPIdentifier_Param> { l->append(UTF8ToWide(str)); NPN_MemFree(str); } else { - l->append(IntToWString( - WebKit::WebBindings::intFromIdentifier(p.identifier))); + l->append(UTF8ToWide(base::IntToString( + WebKit::WebBindings::intFromIdentifier(p.identifier)))); } } }; diff --git a/chrome/test/automation/autocomplete_edit_proxy.h b/chrome/test/automation/autocomplete_edit_proxy.h index 5dcf8af..7f5aa90 100644 --- a/chrome/test/automation/autocomplete_edit_proxy.h +++ b/chrome/test/automation/autocomplete_edit_proxy.h @@ -91,13 +91,13 @@ struct ParamTraits<AutocompleteMatchData> { l->append(L"["); l->append(UTF8ToWide(p.provider_name)); l->append(L" "); - l->append(IntToWString(p.relevance)); + l->append(UTF8ToWide(base::IntToString(p.relevance))); l->append(L" "); l->append(p.deletable ? L"true" : L"false"); l->append(L" "); l->append(p.fill_into_edit); l->append(L" "); - l->append(IntToWString(p.inline_autocomplete_offset)); + l->append(UTF8ToWide(base::IntToString(p.inline_autocomplete_offset))); l->append(L" "); l->append(UTF8ToWide(p.destination_url.spec())); l->append(L" "); diff --git a/chrome/test/in_process_browser_test.cc b/chrome/test/in_process_browser_test.cc index 8c37bc5..5d7e2be 100644 --- a/chrome/test/in_process_browser_test.cc +++ b/chrome/test/in_process_browser_test.cc @@ -9,6 +9,7 @@ #include "base/file_util.h" #include "base/path_service.h" #include "base/scoped_nsautorelease_pool.h" +#include "base/string_number_conversions.h" #include "base/test/test_file_util.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" @@ -330,7 +331,7 @@ void InProcessBrowserTest::QuitBrowsers() { void InProcessBrowserTest::TimedOut() { std::string error_message = "Test timed out. Each test runs for a max of "; - error_message += IntToString(initial_timeout_); + error_message += base::IntToString(initial_timeout_); error_message += " ms (kInitialTimeoutInMS)."; GTEST_NONFATAL_FAILURE_(error_message.c_str()); diff --git a/chrome/test/interactive_ui/view_event_test_base.cc b/chrome/test/interactive_ui/view_event_test_base.cc index 8936d57..476445f 100644 --- a/chrome/test/interactive_ui/view_event_test_base.cc +++ b/chrome/test/interactive_ui/view_event_test_base.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -10,7 +10,7 @@ #include "base/compiler_specific.h" #include "base/message_loop.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "chrome/browser/automation/ui_controls.h" #include "chrome/test/ui_test_utils.h" #include "views/view.h" @@ -165,7 +165,7 @@ void ViewEventTestBase::RunTestMethod(Task* task) { void ViewEventTestBase::TimedOut() { std::string error_message = "Test timed out. Each test runs for a max of "; - error_message += IntToString(kTimeoutInMS); + error_message += base::IntToString(kTimeoutInMS); error_message += " ms (kTimeoutInMS)."; GTEST_NONFATAL_FAILURE_(error_message.c_str()); diff --git a/chrome/test/page_cycler/page_cycler_test.cc b/chrome/test/page_cycler/page_cycler_test.cc index 276c446..a980139 100644 --- a/chrome/test/page_cycler/page_cycler_test.cc +++ b/chrome/test/page_cycler/page_cycler_test.cc @@ -8,7 +8,7 @@ #include "base/file_util.h" #include "base/path_service.h" #include "base/process_util.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/sys_string_conversions.h" #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/common/chrome_constants.h" @@ -215,7 +215,7 @@ class PageCyclerTest : public UITest { // run N iterations GURL::Replacements replacements; const std::string query_string = - "iterations=" + IntToString(GetTestIterations()) + "&auto=1"; + "iterations=" + base::IntToString(GetTestIterations()) + "&auto=1"; replacements.SetQuery( query_string.c_str(), url_parse::Component(0, query_string.length())); diff --git a/chrome/test/reliability/page_load_test.cc b/chrome/test/reliability/page_load_test.cc index f2eba67..148eb54 100644 --- a/chrome/test/reliability/page_load_test.cc +++ b/chrome/test/reliability/page_load_test.cc @@ -627,10 +627,10 @@ void SetPageRange(const CommandLine& parsed_command_line) { if (parsed_command_line.HasSwitch(kStartPageSwitch)) { ASSERT_TRUE(parsed_command_line.HasSwitch(kEndPageSwitch)); ASSERT_TRUE( - StringToInt(WideToUTF16(parsed_command_line.GetSwitchValue( + base::StringToInt(WideToUTF16(parsed_command_line.GetSwitchValue( kStartPageSwitch)), &g_start_page)); ASSERT_TRUE( - StringToInt(WideToUTF16(parsed_command_line.GetSwitchValue( + base::StringToInt(WideToUTF16(parsed_command_line.GetSwitchValue( kEndPageSwitch)), &g_end_page)); ASSERT_TRUE(g_start_page > 0 && g_end_page > 0); ASSERT_TRUE(g_start_page < g_end_page); @@ -645,14 +645,14 @@ void SetPageRange(const CommandLine& parsed_command_line) { if (parsed_command_line.HasSwitch(kStartIndexSwitch)) { ASSERT_TRUE( - StringToInt(WideToUTF16(parsed_command_line.GetSwitchValue( + base::StringToInt(WideToUTF16(parsed_command_line.GetSwitchValue( kStartIndexSwitch)), &g_start_index)); ASSERT_GT(g_start_index, 0); } if (parsed_command_line.HasSwitch(kEndIndexSwitch)) { ASSERT_TRUE( - StringToInt(WideToUTF16(parsed_command_line.GetSwitchValue( + base::StringToInt(WideToUTF16(parsed_command_line.GetSwitchValue( kEndIndexSwitch)), &g_end_index)); ASSERT_GT(g_end_index, 0); } @@ -664,7 +664,7 @@ void SetPageRange(const CommandLine& parsed_command_line) { if (parsed_command_line.HasSwitch(kIterationSwitch)) { ASSERT_TRUE( - StringToInt(WideToUTF16(parsed_command_line.GetSwitchValue( + base::StringToInt(WideToUTF16(parsed_command_line.GetSwitchValue( kIterationSwitch)), &g_iterations)); ASSERT_GT(g_iterations, 0); } @@ -685,7 +685,7 @@ void SetPageRange(const CommandLine& parsed_command_line) { if (parsed_command_line.HasSwitch(kTimeoutSwitch)) { ASSERT_TRUE( - StringToInt(WideToUTF16(parsed_command_line.GetSwitchValue( + base::StringToInt(WideToUTF16(parsed_command_line.GetSwitchValue( kTimeoutSwitch)), &g_timeout_ms)); ASSERT_GT(g_timeout_ms, 0); } diff --git a/chrome/test/startup/startup_test.cc b/chrome/test/startup/startup_test.cc index a4ec1b9..ef25566 100644 --- a/chrome/test/startup/startup_test.cc +++ b/chrome/test/startup/startup_test.cc @@ -6,6 +6,7 @@ #include "base/file_util.h" #include "base/path_service.h" #include "base/platform_thread.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/sys_info.h" #include "base/test/test_file_util.h" @@ -226,7 +227,7 @@ class StartupTest : public UITest { if (nth_timed_tab > 0) { // Display only the time necessary to load the first n tabs. times.clear(); - name = name_base + "-" + IntToString(nth_timed_tab); + name = name_base + "-" + base::IntToString(nth_timed_tab); for (int i = 0; i < numCycles; ++i) StringAppendF(×, "%.2f,", timings[i].nth_tab_stop_ms); PrintResultList(graph, "", name.c_str(), times, "ms", important); diff --git a/chrome/test/sync/engine/test_id_factory.h b/chrome/test/sync/engine/test_id_factory.h index 70f4bba..9ae0469 100644 --- a/chrome/test/sync/engine/test_id_factory.h +++ b/chrome/test/sync/engine/test_id_factory.h @@ -10,7 +10,7 @@ #include <string> -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "chrome/browser/sync/syncable/syncable_id.h" namespace browser_sync { @@ -33,9 +33,9 @@ class TestIdFactory { if (value == 0) return root(); else if (value < 0) - return syncable::Id::CreateFromClientString(Int64ToString(value)); + return syncable::Id::CreateFromClientString(base::Int64ToString(value)); else - return syncable::Id::CreateFromServerId(Int64ToString(value)); + return syncable::Id::CreateFromServerId(base::Int64ToString(value)); } // Create a local ID from a name. @@ -51,13 +51,13 @@ class TestIdFactory { // Autogenerate a fresh local ID. syncable::Id NewLocalId() { return syncable::Id::CreateFromClientString( - std::string("_auto ") + IntToString(-next_value())); + std::string("_auto ") + base::IntToString(-next_value())); } // Autogenerate a fresh server ID. syncable::Id NewServerId() { return syncable::Id::CreateFromServerId( - std::string("_auto ") + IntToString(next_value())); + std::string("_auto ") + base::IntToString(next_value())); } private: diff --git a/chrome/test/ui/npapi_uitest.cc b/chrome/test/ui/npapi_uitest.cc index 440faf2..253532d 100644 --- a/chrome/test/ui/npapi_uitest.cc +++ b/chrome/test/ui/npapi_uitest.cc @@ -21,6 +21,7 @@ #include "base/file_path.h" #include "base/keyboard_codes.h" +#include "base/string_number_conversions.h" #include "chrome/browser/net/url_request_mock_http_job.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/url_constants.h" @@ -54,7 +55,7 @@ TEST_F(NPAPITester, FLAKY_ManyPlugins) { for (int i = 1; i <= 15; i++) { SCOPED_TRACE(StringPrintf("Waiting for plugin #%d", i)); - ASSERT_NO_FATAL_FAILURE(WaitForFinish("arguments", IntToString(i), + ASSERT_NO_FATAL_FAILURE(WaitForFinish("arguments", base::IntToString(i), url, kTestCompleteCookie, kTestCompleteSuccess, action_max_timeout_ms())); diff --git a/chrome/test/ui/ui_layout_test.cc b/chrome/test/ui/ui_layout_test.cc index 6c5415f..59486f6 100644 --- a/chrome/test/ui/ui_layout_test.cc +++ b/chrome/test/ui/ui_layout_test.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,7 +6,7 @@ #include "base/file_util.h" #include "base/path_service.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/test/test_file_util.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" @@ -175,7 +175,7 @@ void UILayoutTest::RunLayoutTest(const std::string& test_case_file_name, // Creates a new cookie name. We will have to use a new cookie because // this function could be called multiple times. std::string status_cookie(kTestCompleteCookie); - status_cookie += IntToString(test_count_); + status_cookie += base::IntToString(test_count_); test_count_++; // Reads the layout test HTML file. diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc index dde980e..e29c373 100644 --- a/chrome/test/ui/ui_test.cc +++ b/chrome/test/ui/ui_test.cc @@ -22,7 +22,7 @@ #include "base/process_util.h" #include "base/scoped_ptr.h" #include "base/scoped_temp_dir.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/test/test_file_util.h" #include "base/time.h" #include "chrome/app/chrome_dll_resource.h" @@ -738,7 +738,7 @@ DictionaryValue* UITestBase::GetLocalState() { DictionaryValue* UITestBase::GetDefaultProfilePreferences() { FilePath path; PathService::Get(chrome::DIR_USER_DATA, &path); - path = path.AppendASCII(WideToASCII(chrome::kNotSignedInProfile)); + path = path.AppendASCII(WideToUTF8(chrome::kNotSignedInProfile)); return LoadDictionaryValueFromPath(path.Append(chrome::kPreferencesFilename)); } @@ -1228,7 +1228,7 @@ void UITestBase::UpdateHistoryDates() { ASSERT_TRUE(db.Open(history)); Time yesterday = Time::Now() - TimeDelta::FromDays(1); - std::string yesterday_str = Int64ToString(yesterday.ToInternalValue()); + std::string yesterday_str = base::Int64ToString(yesterday.ToInternalValue()); std::string query = StringPrintf( "UPDATE segment_usage " "SET time_slot = %s " diff --git a/chrome_frame/metrics_service.cc b/chrome_frame/metrics_service.cc index cb36245..bac5005 100644 --- a/chrome_frame/metrics_service.cc +++ b/chrome_frame/metrics_service.cc @@ -52,6 +52,7 @@ #include "base/file_version_info.h" #include "base/string_util.h" #include "base/thread.h" +#include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "chrome/common/chrome_version_info.h" #include "chrome/installer/util/browser_distribution.h" @@ -170,7 +171,7 @@ class ChromeFrameMetricsDataUploader : public BSCBImpl { LPWSTR* additional_headers) { std::string new_headers; new_headers = StringPrintf("Content-Length: %s\r\n", - Int64ToString(upload_data_size_).c_str()); + base::Int64ToString(upload_data_size_).c_str()); new_headers += kMetricsType; *additional_headers = reinterpret_cast<wchar_t*>( diff --git a/chrome_frame/np_proxy_service.cc b/chrome_frame/np_proxy_service.cc index 2e648ca..b1eadde 100644 --- a/chrome_frame/np_proxy_service.cc +++ b/chrome_frame/np_proxy_service.cc @@ -1,8 +1,8 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "chrome/common/automation_constants.h" #include "chrome/common/json_value_serializer.h" #include "chrome_frame/np_proxy_service.h" @@ -276,7 +276,7 @@ DictionaryValue* NpProxyService::BuildProxyValueSet() { manual_proxy_settings += "="; manual_proxy_settings += iter->url; manual_proxy_settings += ":"; - manual_proxy_settings += IntToString(iter->port); + manual_proxy_settings += base::IntToString(iter->port); manual_proxy_settings += ";"; } diff --git a/chrome_frame/npapi_url_request.cc b/chrome_frame/npapi_url_request.cc index 7f7faf7..dce5d01 100644 --- a/chrome_frame/npapi_url_request.cc +++ b/chrome_frame/npapi_url_request.cc @@ -4,7 +4,7 @@ #include "chrome_frame/npapi_url_request.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "chrome_frame/np_browser_functions.h" #include "chrome_frame/np_utils.h" #include "net/base/net_errors.h" @@ -74,7 +74,7 @@ bool NPAPIUrlRequest::Start() { // Firefox looks specifically for "Content-length: \d+\r\n\r\n" // to detect if extra headers are added to the message buffer. buffer += "\r\nContent-length: "; - buffer += IntToString(data_len); + buffer += base::IntToString(data_len); buffer += "\r\n\r\n"; } diff --git a/chrome_frame/urlmon_url_request.cc b/chrome_frame/urlmon_url_request.cc index e951f18..da255b5 100644 --- a/chrome_frame/urlmon_url_request.cc +++ b/chrome_frame/urlmon_url_request.cc @@ -7,10 +7,10 @@ #include <wininet.h> #include <urlmon.h> -#include "base/scoped_ptr.h" -#include "base/string_util.h" #include "base/logging.h" #include "base/message_loop.h" +#include "base/scoped_ptr.h" +#include "base/string_number_conversions.h" #include "chrome_frame/bind_context_info.h" #include "chrome_frame/chrome_frame_activex_base.h" #include "chrome_frame/extra_system_apis.h" @@ -450,7 +450,7 @@ STDMETHODIMP UrlmonUrlRequest::GetBindInfo(DWORD* bind_flags, if (get_upload_data(&bind_info->stgmedData.pstm) == S_OK) { bind_info->stgmedData.tymed = TYMED_ISTREAM; DLOG(INFO) << __FUNCTION__ << me() << method() - << " request with " << Int64ToString(post_data_len()) + << " request with " << base::Int64ToString(post_data_len()) << " bytes. url=" << url(); } else { DLOG(INFO) << __FUNCTION__ << me() << "POST request with no data!"; @@ -543,7 +543,7 @@ STDMETHODIMP UrlmonUrlRequest::BeginningTransaction(const wchar_t* url, // Tack on the Content-Length header since when using an IStream type // STGMEDIUM, it looks like it doesn't get set for us :( new_headers = StringPrintf("Content-Length: %s\r\n", - Int64ToString(post_data_len()).c_str()); + base::Int64ToString(post_data_len()).c_str()); } if (!extra_headers().empty()) { diff --git a/courgette/ensemble.cc b/courgette/ensemble.cc index a9b7f38..4051cfc 100644 --- a/courgette/ensemble.cc +++ b/courgette/ensemble.cc @@ -2,13 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// *** File comments - #include "courgette/ensemble.h" #include "base/basictypes.h" #include "base/logging.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "courgette/image_info.h" #include "courgette/region.h" @@ -23,9 +21,9 @@ Element::Element(Kind kind, Ensemble* ensemble, const Region& region) std::string Element::Name() const { return ensemble_->name() + "(" - + IntToString(kind()) + "," - + Uint64ToString(offset_in_ensemble()) + "," - + Uint64ToString(region().length()) + ")"; + + base::IntToString(kind()) + "," + + base::Uint64ToString(offset_in_ensemble()) + "," + + base::Uint64ToString(region().length()) + ")"; } // A subclass of Element that has a PEInfo. diff --git a/gpu/command_buffer/service/program_manager.cc b/gpu/command_buffer/service/program_manager.cc index 81bab30..d9ad80e 100644 --- a/gpu/command_buffer/service/program_manager.cc +++ b/gpu/command_buffer/service/program_manager.cc @@ -3,11 +3,13 @@ // found in the LICENSE file. #include "gpu/command_buffer/service/program_manager.h" + #include <algorithm> + #include "base/basictypes.h" #include "base/logging.h" #include "base/scoped_ptr.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "gpu/command_buffer/service/gles2_cmd_decoder.h" namespace gpu { @@ -227,7 +229,7 @@ const ProgramManager::ProgramInfo::UniformInfo* } } for (GLsizei ii = 1; ii < info.size; ++ii) { - std::string element_name(base_name + "[" + IntToString(ii) + "]"); + std::string element_name(base_name + "[" + base::IntToString(ii) + "]"); info.element_locations[ii] = glGetUniformLocation(service_id_, element_name.c_str()); } diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h index aab80ee..1aab1b3 100644 --- a/ipc/ipc_message_utils.h +++ b/ipc/ipc_message_utils.h @@ -16,6 +16,7 @@ #include "base/format_macros.h" #include "base/nullable_string16.h" #include "base/string16.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "base/time.h" @@ -209,7 +210,7 @@ struct ParamTraits<long long> { return m->ReadInt64(iter, reinterpret_cast<int64*>(r)); } static void Log(const param_type& p, std::wstring* l) { - l->append(Int64ToWString(static_cast<int64>(p))); + l->append(UTF8ToWide(base::Int64ToString(static_cast<int64>(p)))); } }; @@ -223,7 +224,7 @@ struct ParamTraits<unsigned long long> { return m->ReadInt64(iter, reinterpret_cast<int64*>(r)); } static void Log(const param_type& p, std::wstring* l) { - l->append(Uint64ToWString(p)); + l->append(UTF8ToWide(base::Uint64ToString(p))); } }; diff --git a/jingle/notifier/listener/xml_element_util.cc b/jingle/notifier/listener/xml_element_util.cc index 9db99c9..653b769 100644 --- a/jingle/notifier/listener/xml_element_util.cc +++ b/jingle/notifier/listener/xml_element_util.cc @@ -7,7 +7,7 @@ #include <sstream> #include <string> -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "talk/xmllite/qname.h" #include "talk/xmllite/xmlconstants.h" #include "talk/xmllite/xmlelement.h" @@ -35,7 +35,7 @@ buzz::XmlElement* MakeIntXmlElement(const char* name, int value) { const buzz::QName intAttrQName(buzz::STR_EMPTY, "int"); buzz::XmlElement* int_xml_element = new buzz::XmlElement(elementQName, true); - int_xml_element->AddAttr(intAttrQName, IntToString(value)); + int_xml_element->AddAttr(intAttrQName, base::IntToString(value)); return int_xml_element; } diff --git a/net/ftp/ftp_auth_cache_unittest.cc b/net/ftp/ftp_auth_cache_unittest.cc index 005de89..3971b32 100644 --- a/net/ftp/ftp_auth_cache_unittest.cc +++ b/net/ftp/ftp_auth_cache_unittest.cc @@ -4,6 +4,7 @@ #include "net/ftp/ftp_auth_cache.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "googleurl/src/gurl.h" #include "testing/gtest/include/gtest/gtest.h" @@ -132,12 +133,14 @@ TEST(FtpAuthCacheTest, OnlyRemoveMatching) { TEST(FtpAuthCacheTest, EvictOldEntries) { FtpAuthCache cache; - for (size_t i = 0; i < FtpAuthCache::kMaxEntries; i++) - cache.Add(GURL("ftp://host" + IntToString(i)), kUsername, kPassword); + for (size_t i = 0; i < FtpAuthCache::kMaxEntries; i++) { + cache.Add(GURL("ftp://host" + base::IntToString(i)), + kUsername, kPassword); + } // No entries should be evicted before reaching the limit. for (size_t i = 0; i < FtpAuthCache::kMaxEntries; i++) { - EXPECT_TRUE(cache.Lookup(GURL("ftp://host" + IntToString(i)))); + EXPECT_TRUE(cache.Lookup(GURL("ftp://host" + base::IntToString(i)))); } // Adding one entry should cause eviction of the first entry. @@ -146,7 +149,7 @@ TEST(FtpAuthCacheTest, EvictOldEntries) { // Remaining entries should not get evicted. for (size_t i = 1; i < FtpAuthCache::kMaxEntries; i++) { - EXPECT_TRUE(cache.Lookup(GURL("ftp://host" + IntToString(i)))); + EXPECT_TRUE(cache.Lookup(GURL("ftp://host" + base::IntToString(i)))); } EXPECT_TRUE(cache.Lookup(GURL("ftp://last_host"))); } diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc index dbd6bf1..ad72bea 100644 --- a/net/http/http_cache.cc +++ b/net/http/http_cache.cc @@ -19,6 +19,7 @@ #include "base/ref_counted.h" #include "base/stl_util-inl.h" #include "base/string_util.h" +#include "base/string_number_conversions.h" #include "net/base/io_buffer.h" #include "net/base/load_flags.h" #include "net/base/net_errors.h" @@ -466,7 +467,7 @@ std::string HttpCache::GenerateCacheKey(const HttpRequestInfo* request) { (*playback_cache_map_)[url] = generation + 1; // The key into the cache is GENERATION # + METHOD + URL. - std::string result = IntToString(generation); + std::string result = base::IntToString(generation); result.append(request->method); result.append(url); return result; diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc index a9d557f..f54db4f 100644 --- a/net/http/http_network_transaction.cc +++ b/net/http/http_network_transaction.cc @@ -15,6 +15,7 @@ #include "base/stats_counters.h" #include "base/stl_util-inl.h" #include "base/string_util.h" +#include "base/string_number_conversions.h" #include "build/build_config.h" #include "googleurl/src/gurl.h" #include "net/base/connection_type_histograms.h" @@ -650,7 +651,7 @@ int HttpNetworkTransaction::DoResolveProxy() { if (g_host_mapping_rules && g_host_mapping_rules->RewriteHost(&endpoint_)) { url_canon::Replacements<char> replacements; - const std::string port_str = IntToString(endpoint_.port()); + const std::string port_str = base::IntToString(endpoint_.port()); replacements.SetPort(port_str.c_str(), url_parse::Component(0, port_str.size())); replacements.SetHost(endpoint_.host().c_str(), @@ -677,7 +678,7 @@ int HttpNetworkTransaction::DoResolveProxy() { url_canon::Replacements<char> replacements; replacements.SetScheme("https", url_parse::Component(0, strlen("https"))); - const std::string port_str = IntToString(endpoint_.port()); + const std::string port_str = base::IntToString(endpoint_.port()); replacements.SetPort(port_str.c_str(), url_parse::Component(0, port_str.size())); alternate_endpoint_url = diff --git a/net/http/partial_data.cc b/net/http/partial_data.cc index 49d68d2..8964903 100644 --- a/net/http/partial_data.cc +++ b/net/http/partial_data.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009-2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,6 +6,7 @@ #include "base/format_macros.h" #include "base/logging.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "net/base/net_errors.h" #include "net/disk_cache/disk_cache.h" @@ -25,9 +26,9 @@ void AddRangeHeader(int64 start, int64 end, HttpRequestHeaders* headers) { DCHECK(start >= 0 || end >= 0); std::string my_start, my_end; if (start >= 0) - my_start = Int64ToString(start); + my_start = base::Int64ToString(start); if (end >= 0) - my_end = Int64ToString(end); + my_end = base::Int64ToString(end); headers->SetHeader( HttpRequestHeaders::kRange, diff --git a/net/proxy/proxy_config.cc b/net/proxy/proxy_config.cc index 6e73101..f27fbc4 100644 --- a/net/proxy/proxy_config.cc +++ b/net/proxy/proxy_config.cc @@ -1,9 +1,11 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "net/proxy/proxy_config.h" +#include "base/logging.h" +#include "base/string_number_conversions.h" #include "base/string_tokenizer.h" #include "base/string_util.h" #include "net/proxy/proxy_info.h" @@ -176,7 +178,7 @@ std::ostream& operator<<(std::ostream& out, type = "TYPE_SINGLE_PROXY"; break; default: - type = IntToString(rules.type); + type = base::IntToString(rules.type); break; } return out << " {\n" diff --git a/net/proxy/proxy_config_service_linux.cc b/net/proxy/proxy_config_service_linux.cc index e33a487..c2f9a94 100644 --- a/net/proxy/proxy_config_service_linux.cc +++ b/net/proxy/proxy_config_service_linux.cc @@ -20,6 +20,7 @@ #include "base/file_util.h" #include "base/logging.h" #include "base/message_loop.h" +#include "base/string_number_conversions.h" #include "base/string_tokenizer.h" #include "base/string_util.h" #include "base/task.h" @@ -903,7 +904,7 @@ bool ProxyConfigServiceLinux::Delegate::GetProxyFromGConf( gconf_getter_->GetInt((key + "port").c_str(), &port); if (port != 0) { // If a port is set and non-zero: - host += ":" + IntToString(port); + host += ":" + base::IntToString(port); } host = FixupProxyHostScheme( is_socks ? ProxyServer::SCHEME_SOCKS4 : ProxyServer::SCHEME_HTTP, diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc index 5d6fb02..9f2b82f 100644 --- a/net/spdy/spdy_session.cc +++ b/net/spdy/spdy_session.cc @@ -11,6 +11,7 @@ #include "base/rand_util.h" #include "base/stats_counters.h" #include "base/stl_util-inl.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/time.h" #include "base/values.h" @@ -613,7 +614,7 @@ void SpdySession::OnWriteComplete(int result) { LOG(INFO) << "Spdy write complete (result=" << result << ")" << (stream ? std::string(" for stream ") + - IntToString(stream->stream_id()) : ""); + base::IntToString(stream->stream_id()) : ""); if (result >= 0) { // It should not be possible to have written more bytes than our diff --git a/net/test/test_server.cc b/net/test/test_server.cc index 3432368..683cde2 100644 --- a/net/test/test_server.cc +++ b/net/test/test_server.cc @@ -21,7 +21,7 @@ #include "base/leak_annotations.h" #include "base/logging.h" #include "base/path_service.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "net/base/cert_test_util.h" #include "net/base/host_resolver.h" @@ -134,7 +134,7 @@ bool TestServerLauncher::Start(Protocol protocol, return false; } - std::string port_str = IntToString(port); + std::string port_str = base::IntToString(port); // Get path to python server script FilePath testserver_path; diff --git a/net/tools/fetch/http_listen_socket.cc b/net/tools/fetch/http_listen_socket.cc index d0d6b97..fd788c8 100644 --- a/net/tools/fetch/http_listen_socket.cc +++ b/net/tools/fetch/http_listen_socket.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,7 +9,7 @@ #include "base/compiler_specific.h" #include "base/logging.h" #include "base/message_loop.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "net/tools/fetch/http_server_request_info.h" #include "net/tools/fetch/http_server_response_info.h" @@ -37,8 +37,10 @@ void HttpListenSocket::Accept() { } } -HttpListenSocket* HttpListenSocket::Listen(const std::string& ip, int port, - HttpListenSocket::Delegate* delegate) { +HttpListenSocket* HttpListenSocket::Listen( + const std::string& ip, + int port, + HttpListenSocket::Delegate* delegate) { SOCKET s = ListenSocket::Listen(ip, port); if (s == ListenSocket::kInvalidSocket) { // TODO (ibrar): error handling @@ -227,7 +229,7 @@ void HttpListenSocket::Respond(HttpServerResponseInfo* info, response += "Content-type: " + info->content_type + "\r\n"; if (info->content_length > 0) - response += "Content-length: " + IntToString(info->content_length) + + response += "Content-length: " + base::IntToString(info->content_length) + "\r\n"; if (info->connection_close) diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc index b232db4..48f5351 100644 --- a/net/url_request/url_request_unittest.cc +++ b/net/url_request/url_request_unittest.cc @@ -22,7 +22,7 @@ #include "base/path_service.h" #include "base/process_util.h" #include "base/string_piece.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "net/base/cookie_monster.h" #include "net/base/cookie_policy.h" #include "net/base/load_flags.h" @@ -172,7 +172,7 @@ TEST_F(URLRequestTestHTTP, ProxyTunnelRedirectTest) { { URLRequest r(GURL("https://www.redirect.com/"), &d); std::string proxy("localhost:"); - proxy.append(IntToString(kHTTPDefaultPort)); + proxy.append(base::IntToString(kHTTPDefaultPort)); r.set_context(new TestURLRequestContext(proxy)); r.Start(); @@ -197,7 +197,7 @@ TEST_F(URLRequestTestHTTP, UnexpectedServerAuthTest) { { URLRequest r(GURL("https://www.server-auth.com/"), &d); std::string proxy("localhost:"); - proxy.append(IntToString(kHTTPDefaultPort)); + proxy.append(base::IntToString(kHTTPDefaultPort)); r.set_context(new TestURLRequestContext(proxy)); r.Start(); @@ -1761,7 +1761,7 @@ TEST_F(URLRequestTestHTTP, Post307RedirectPost) { req.set_upload(CreateSimpleUploadData(kData).get()); net::HttpRequestHeaders headers; headers.SetHeader(net::HttpRequestHeaders::kContentLength, - UintToString(arraysize(kData) - 1)); + base::UintToString(arraysize(kData) - 1)); req.SetExtraRequestHeaders(headers); req.Start(); MessageLoop::current()->Run(); diff --git a/net/websockets/websocket_handshake.cc b/net/websockets/websocket_handshake.cc index 5adfa67..e6f0aa8 100644 --- a/net/websockets/websocket_handshake.cc +++ b/net/websockets/websocket_handshake.cc @@ -7,9 +7,11 @@ #include <algorithm> #include <vector> +#include "base/logging.h" #include "base/md5.h" #include "base/rand_util.h" #include "base/ref_counted.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "net/http/http_response_headers.h" #include "net/http/http_util.h" @@ -134,7 +136,7 @@ std::string WebSocketHandshake::GetHostFieldValue() const { (secure && port != kSecureWebSocketPort && port != url_parse::PORT_UNSPECIFIED)) { host += ":"; - host += IntToString(port); + host += base::IntToString(port); } } return host; diff --git a/tools/memory_watcher/call_stack.cc b/tools/memory_watcher/call_stack.cc index 460695d..15ca917 100644 --- a/tools/memory_watcher/call_stack.cc +++ b/tools/memory_watcher/call_stack.cc @@ -1,13 +1,14 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "call_stack.h" +#include "tools/memory_watcher/call_stack.h" + #include <shlwapi.h> #include <tlhelp32.h> -#include "memory_hook.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" +#include "tools/memory_watcher/memory_hook.h" // Typedefs for explicit dynamic linking with functions exported from // dbghelp.dll. @@ -341,7 +342,7 @@ void CallStack::ToString(PrivateAllocatorString* output) { // TODO(jar): get something like this template to work :-/ // line += IntToCustomString<PrivateAllocatorString>(Line.LineNumber); // ...and then delete this line, which uses std::string. - line += IntToString(Line.LineNumber).c_str(); + line += base::IntToString(Line.LineNumber).c_str(); line += "): "; line += symbol->Name; line += "\n"; diff --git a/tools/memory_watcher/call_stack.h b/tools/memory_watcher/call_stack.h index 264ad901..12a0114 100644 --- a/tools/memory_watcher/call_stack.h +++ b/tools/memory_watcher/call_stack.h @@ -8,8 +8,8 @@ // http://www.codeproject.com/KB/threads/StackWalker.aspx // by Jochen Kalmbach -#ifndef MEMORY_WATCHER_CALL_STACK_H_ -#define MEMORY_WATCHER_CALL_STACK_H_ +#ifndef TOOLS_MEMORY_WATCHER_CALL_STACK_H_ +#define TOOLS_MEMORY_WATCHER_CALL_STACK_H_ #include <windows.h> #include <dbghelp.h> @@ -17,9 +17,9 @@ #include <map> #include <string> -#include "memory_watcher.h" #include "base/lock.h" #include "base/logging.h" +#include "tools/memory_watcher/memory_watcher.h" // The CallStack Class // A stack where memory has been allocated. @@ -165,4 +165,4 @@ class AllocationStack : public CallStack { DISALLOW_COPY_AND_ASSIGN(AllocationStack); }; -#endif // MEMORY_WATCHER_CALL_STACK_H_ +#endif // TOOLS_MEMORY_WATCHER_CALL_STACK_H_ diff --git a/tools/memory_watcher/memory_watcher.h b/tools/memory_watcher/memory_watcher.h index 9609ce2..8cee2b80 100644 --- a/tools/memory_watcher/memory_watcher.h +++ b/tools/memory_watcher/memory_watcher.h @@ -8,11 +8,12 @@ // and track call stacks for any allocations that are made. It can // then be used to see what memory is in use. -#ifndef MEMORY_WATCHER_MEMORY_WATCHER_ -#define MEMORY_WATCHER_MEMORY_WATCHER_ +#ifndef TOOLS_MEMORY_WATCHER_MEMORY_WATCHER_ +#define TOOLS_MEMORY_WATCHER_MEMORY_WATCHER_ #include <map> #include <functional> + #include "base/lock.h" #include "tools/memory_watcher/memory_hook.h" @@ -91,4 +92,4 @@ class MemoryWatcher : MemoryObserver { -#endif // MEMORY_WATCHER_ +#endif // TOOLS_MEMORY_WATCHER_MEMORY_WATCHER_ diff --git a/webkit/appcache/appcache_disk_cache.cc b/webkit/appcache/appcache_disk_cache.cc index 3785baf..dbba211 100644 --- a/webkit/appcache/appcache_disk_cache.cc +++ b/webkit/appcache/appcache_disk_cache.cc @@ -6,7 +6,7 @@ #include "base/file_path.h" #include "base/logging.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "net/base/net_errors.h" namespace appcache { @@ -62,7 +62,7 @@ int AppCacheDiskCache::CreateEntry(int64 key, disk_cache::Entry** entry, if (!disk_cache_.get()) return net::ERR_FAILED; - return disk_cache_->CreateEntry(Int64ToString(key), entry, callback); + return disk_cache_->CreateEntry(base::Int64ToString(key), entry, callback); } int AppCacheDiskCache::OpenEntry(int64 key, disk_cache::Entry** entry, @@ -78,7 +78,7 @@ int AppCacheDiskCache::OpenEntry(int64 key, disk_cache::Entry** entry, if (!disk_cache_.get()) return net::ERR_FAILED; - return disk_cache_->OpenEntry(Int64ToString(key), entry, callback); + return disk_cache_->OpenEntry(base::Int64ToString(key), entry, callback); } int AppCacheDiskCache::DoomEntry(int64 key, @@ -94,7 +94,7 @@ int AppCacheDiskCache::DoomEntry(int64 key, if (!disk_cache_.get()) return net::ERR_FAILED; - return disk_cache_->DoomEntry(Int64ToString(key), callback); + return disk_cache_->DoomEntry(base::Int64ToString(key), callback); } int AppCacheDiskCache::Init(net::CacheType cache_type, diff --git a/webkit/database/database_tracker.cc b/webkit/database/database_tracker.cc index f18189b..d109064 100644 --- a/webkit/database/database_tracker.cc +++ b/webkit/database/database_tracker.cc @@ -13,7 +13,7 @@ #include "app/sql/transaction.h" #include "base/basictypes.h" #include "base/file_util.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "net/base/net_errors.h" #include "webkit/database/databases_table.h" @@ -196,7 +196,7 @@ string16 DatabaseTracker::GetOriginDirectory( return it->second; string16 origin_directory = - IntToString16(incognito_origin_directories_generator_++); + base::IntToString16(incognito_origin_directories_generator_++); incognito_origin_directories_[origin_identifier] = origin_directory; return origin_directory; } diff --git a/webkit/glue/dom_operations.cc b/webkit/glue/dom_operations.cc index 82e5e3a..b39943f 100644 --- a/webkit/glue/dom_operations.cc +++ b/webkit/glue/dom_operations.cc @@ -2,10 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "webkit/glue/dom_operations.h" + #include <set> #include "base/compiler_specific.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "third_party/WebKit/WebKit/chromium/public/WebAnimationController.h" #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" #include "third_party/WebKit/WebKit/chromium/public/WebElement.h" @@ -17,7 +19,6 @@ #include "third_party/WebKit/WebKit/chromium/public/WebNodeList.h" #include "third_party/WebKit/WebKit/chromium/public/WebVector.h" #include "third_party/WebKit/WebKit/chromium/public/WebView.h" -#include "webkit/glue/dom_operations.h" #include "webkit/glue/form_data.h" #include "webkit/glue/password_form_dom_manager.h" #include "webkit/glue/webpasswordautocompletelistener_impl.h" @@ -405,7 +406,7 @@ static int ParseSingleIconSize(const string16& text) { return 0; } int output; - if (!StringToInt(text, &output)) + if (!base::StringToInt(text, &output)) return 0; return output; } diff --git a/webkit/glue/multipart_response_delegate.cc b/webkit/glue/multipart_response_delegate.cc index 0b37050..f7ba56f 100644 --- a/webkit/glue/multipart_response_delegate.cc +++ b/webkit/glue/multipart_response_delegate.cc @@ -5,6 +5,7 @@ #include "webkit/glue/multipart_response_delegate.h" #include "base/logging.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "net/base/net_util.h" #include "net/http/http_util.h" @@ -363,9 +364,9 @@ bool MultipartResponseDelegate::ReadContentRanges( content_range.substr(byte_range_upper_bound_start_offset, byte_range_upper_bound_characters); - if (!StringToInt(byte_range_lower_bound, content_range_lower_bound)) + if (!base::StringToInt(byte_range_lower_bound, content_range_lower_bound)) return false; - if (!StringToInt(byte_range_upper_bound, content_range_upper_bound)) + if (!base::StringToInt(byte_range_upper_bound, content_range_upper_bound)) return false; return true; } diff --git a/webkit/glue/plugins/pepper_var.cc b/webkit/glue/plugins/pepper_var.cc index 414df7b..78e9479 100644 --- a/webkit/glue/plugins/pepper_var.cc +++ b/webkit/glue/plugins/pepper_var.cc @@ -6,6 +6,7 @@ #include "base/logging.h" #include "base/scoped_ptr.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "third_party/ppapi/c/pp_var.h" #include "third_party/ppapi/c/ppb_var.h" @@ -200,7 +201,7 @@ PP_Var NPIdentifierToPPVarString(NPIdentifier id) { if (var.type == PP_VARTYPE_STRING) return var; DCHECK(var.type == PP_VARTYPE_INT32); - const std::string& str = IntToString(var.value.as_int); + const std::string& str = base::IntToString(var.value.as_int); return VarFromUtf8(str.data(), str.size()); } diff --git a/webkit/glue/plugins/plugin_instance.cc b/webkit/glue/plugins/plugin_instance.cc index 8506623..f7b3bf7 100644 --- a/webkit/glue/plugins/plugin_instance.cc +++ b/webkit/glue/plugins/plugin_instance.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -8,7 +8,7 @@ #include "base/file_util.h" #include "base/message_loop.h" -#include "base/string_util.h" +#include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/plugins/plugin_host.h" @@ -489,13 +489,13 @@ void PluginInstance::RequestRead(NPStream* stream, NPByteRange* range_list) { std::string range_info = "bytes="; while (range_list) { - range_info += IntToString(range_list->offset); - range_info += "-"; - range_info += IntToString(range_list->offset + range_list->length - 1); + range_info += base::IntToString(range_list->offset); + range_info.push_back('-'); + range_info += + base::IntToString(range_list->offset + range_list->length - 1); range_list = range_list->next; - if (range_list) { - range_info += ","; - } + if (range_list) + range_info.push_back(','); } if (plugin_data_stream_) { diff --git a/webkit/glue/plugins/plugin_list_win.cc b/webkit/glue/plugins/plugin_list_win.cc index 1c91916..9821928 100644 --- a/webkit/glue/plugins/plugin_list_win.cc +++ b/webkit/glue/plugins/plugin_list_win.cc @@ -14,6 +14,7 @@ #include "base/path_service.h" #include "base/registry.h" #include "base/scoped_ptr.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "webkit/glue/plugins/plugin_constants_win.h" #include "webkit/glue/plugins/plugin_lib.h" @@ -313,8 +314,10 @@ bool IsNewerVersion(const std::wstring& a, const std::wstring& b) { if (a_ver.size() != b_ver.size()) return false; for (size_t i = 0; i < a_ver.size(); i++) { - int cur_a = StringToInt(a_ver[i]); - int cur_b = StringToInt(b_ver[i]); + int cur_a, cur_b; + base::StringToInt(a_ver[i], &cur_a); + base::StringToInt(b_ver[i], &cur_b); + if (cur_a > cur_b) return false; if (cur_a < cur_b) @@ -370,9 +373,9 @@ bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info, SplitString(info.version, '.', &ver); int major, minor, update; if (ver.size() == 4 && - StringToInt(ver[0], &major) && - StringToInt(ver[1], &minor) && - StringToInt(ver[2], &update)) { + base::StringToInt(ver[0], &major) && + base::StringToInt(ver[1], &minor) && + base::StringToInt(ver[2], &update)) { if (major == 6 && minor == 0 && update < 120) return false; // Java SE6 Update 11 or older. } diff --git a/webkit/glue/plugins/webplugin_delegate_impl_win.cc b/webkit/glue/plugins/webplugin_delegate_impl_win.cc index 09184ab..df75cc0 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl_win.cc +++ b/webkit/glue/plugins/webplugin_delegate_impl_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -15,6 +15,7 @@ #include "base/registry.h" #include "base/scoped_ptr.h" #include "base/stats_counters.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/win_util.h" #include "skia/ext/platform_canvas.h" @@ -285,7 +286,8 @@ WebPluginDelegateImpl::WebPluginDelegateImpl( std::vector<std::wstring> version; SplitString(plugin_info.version, L'.', &version); if (version.size() > 0) { - int major = static_cast<int>(StringToInt64(version[0])); + int major; + base::StringToInt(version[0], &major); if (major >= 9) { quirks_ |= PLUGIN_QUIRK_DIE_AFTER_UNLOAD; diff --git a/webkit/glue/webkitclient_impl.cc b/webkit/glue/webkitclient_impl.cc index cfc197b..7e4c871 100644 --- a/webkit/glue/webkitclient_impl.cc +++ b/webkit/glue/webkitclient_impl.cc @@ -18,6 +18,7 @@ #include "base/platform_file.h" #include "base/singleton.h" #include "base/stats_counters.h" +#include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/time.h" #include "base/utf_string_conversions.h" @@ -307,7 +308,7 @@ WebString WebKitClientImpl::queryLocalizedString( if (message_id < 0) return WebString(); return ReplaceStringPlaceholders(GetLocalizedString(message_id), - IntToString16(numeric_value), + base::IntToString16(numeric_value), NULL); } diff --git a/webkit/tools/test_shell/node_leak_test.cc b/webkit/tools/test_shell/node_leak_test.cc index 6d303f1..7dee5aa 100644 --- a/webkit/tools/test_shell/node_leak_test.cc +++ b/webkit/tools/test_shell/node_leak_test.cc @@ -5,6 +5,7 @@ #include "base/command_line.h" #include "base/file_path.h" #include "base/path_service.h" +#include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "net/http/http_cache.h" #include "net/url_request/url_request_context.h" @@ -42,9 +43,9 @@ class NodeLeakTest : public TestShellTest { if (parsed_command_line.HasSwitch(test_shell::kTestShellTimeOut)) { const std::wstring timeout_str = parsed_command_line.GetSwitchValue( test_shell::kTestShellTimeOut); - int timeout_ms = - static_cast<int>(StringToInt64(WideToUTF16Hack(timeout_str.c_str()))); - if (timeout_ms > 0) + int timeout_ms; + if (base::StringToInt(WideToUTF8(timeout_str), &timeout_ms) && + timeout_ms > 0) TestShell::SetFileTestTimeout(timeout_ms); } diff --git a/webkit/tools/test_shell/test_shell_main.cc b/webkit/tools/test_shell/test_shell_main.cc index 6d9bac7..8eb549e 100644 --- a/webkit/tools/test_shell/test_shell_main.cc +++ b/webkit/tools/test_shell/test_shell_main.cc @@ -16,6 +16,7 @@ #include "base/process_util.h" #include "base/rand_util.h" #include "base/stats_table.h" +#include "base/string_number_conversions.h" #include "base/sys_info.h" #include "base/trace_event.h" #include "base/utf_string_conversions.h" @@ -261,8 +262,8 @@ int main(int argc, char* argv[]) { // truncate the random # to 32 bits for the benefit of Mac OS X, to // avoid tripping over its maximum shared memory segment name length - std::string stats_filename = - kStatsFilePrefix + Uint64ToString(base::RandUint64() & 0xFFFFFFFFL); + std::string stats_filename = kStatsFilePrefix + + base::Uint64ToString(base::RandUint64() & 0xFFFFFFFFL); RemoveSharedMemoryFile(stats_filename); StatsTable *table = new StatsTable(stats_filename, kStatsFileThreads, |