summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-30 19:28:44 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-30 19:28:44 +0000
commit528c56de01bbbd38788ed6cf8d2eea4c56cbe19e (patch)
treeac4f7a001affd772c4ab89701d3d46109b5f9e19 /webkit
parent5c86ada8d84f6e67d17b027d347052ef451241c4 (diff)
downloadchromium_src-528c56de01bbbd38788ed6cf8d2eea4c56cbe19e.zip
chromium_src-528c56de01bbbd38788ed6cf8d2eea4c56cbe19e.tar.gz
chromium_src-528c56de01bbbd38788ed6cf8d2eea4c56cbe19e.tar.bz2
Move the number conversions from string_util to a new file.
Use the base namespace in the new file. Update callers. I removed all wstring variants and also the string->number ones that ignore the return value. That encourages people to write code and forget about error handling. TEST=included unit tests BUG=none Review URL: http://codereview.chromium.org/3056029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54355 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/appcache/appcache_disk_cache.cc8
-rw-r--r--webkit/database/database_tracker.cc4
-rw-r--r--webkit/glue/dom_operations.cc7
-rw-r--r--webkit/glue/multipart_response_delegate.cc5
-rw-r--r--webkit/glue/plugins/pepper_var.cc3
-rw-r--r--webkit/glue/plugins/plugin_instance.cc16
-rw-r--r--webkit/glue/plugins/plugin_list_win.cc13
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_win.cc6
-rw-r--r--webkit/glue/webkitclient_impl.cc3
-rw-r--r--webkit/tools/test_shell/node_leak_test.cc7
-rw-r--r--webkit/tools/test_shell/test_shell_main.cc5
11 files changed, 44 insertions, 33 deletions
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,