summaryrefslogtreecommitdiffstats
path: root/net/base
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-23 01:10:46 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-23 01:10:46 +0000
commitb8c1eb454dc4f246c64a6b1b5b472af102e88103 (patch)
tree6413d1400ee4ade44838ecd530736840d1f4f64b /net/base
parentbe2da4de5227f4f1cbb8455a58045c5e51076474 (diff)
downloadchromium_src-b8c1eb454dc4f246c64a6b1b5b472af102e88103.zip
chromium_src-b8c1eb454dc4f246c64a6b1b5b472af102e88103.tar.gz
chromium_src-b8c1eb454dc4f246c64a6b1b5b472af102e88103.tar.bz2
base: Add IsHexDigit function to string_util.h
Removed duplicated IsHex functions and converted the callers along the way. (Note: this was a TODO for jungshik). BUG=None TEST=trybots Signed-off-by: Thiago Farina <tfarina@chromium.org> Review URL: http://codereview.chromium.org/2870058 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53428 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base')
-rw-r--r--net/base/escape.cc12
-rw-r--r--net/base/net_util.cc7
2 files changed, 3 insertions, 16 deletions
diff --git a/net/base/escape.cc b/net/base/escape.cc
index bc01e11..d9bfcee 100644
--- a/net/base/escape.cc
+++ b/net/base/escape.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,19 +9,13 @@
#include "base/i18n/icu_string_conversions.h"
#include "base/logging.h"
#include "base/string_piece.h"
+#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "base/utf_offset_string_conversions.h"
namespace {
template <class char_type>
-inline bool IsHex(char_type ch) {
- return (ch >= '0' && ch <= '9') ||
- (ch >= 'A' && ch <= 'F') ||
- (ch >= 'a' && ch <= 'f');
-}
-
-template <class char_type>
inline char_type HexToInt(char_type ch) {
if (ch >= '0' && ch <= '9')
return ch - '0';
@@ -141,7 +135,7 @@ STR UnescapeURLImpl(const STR& escaped_text,
static_cast<typename STR::value_type>(escaped_text[i + 1]));
const typename STR::value_type least_sig_digit(
static_cast<typename STR::value_type>(escaped_text[i + 2]));
- if (IsHex(most_sig_digit) && IsHex(least_sig_digit)) {
+ if (IsHexDigit(most_sig_digit) && IsHexDigit(least_sig_digit)) {
unsigned char value = HexToInt(most_sig_digit) * 16 +
HexToInt(least_sig_digit);
if (value >= 0x80 || // Unescape all high-bit characters.
diff --git a/net/base/net_util.cc b/net/base/net_util.cc
index c7b6a6f..d521439 100644
--- a/net/base/net_util.cc
+++ b/net/base/net_util.cc
@@ -184,13 +184,6 @@ STR GetSpecificHeaderT(const STR& headers, const STR& name) {
return ret;
}
-// TODO(jungshik): We have almost identical hex-decoding code else where.
-// Consider refactoring and moving it somewhere(base?). Bug 1224311
-inline bool IsHexDigit(unsigned char c) {
- return (('0' <= c && c <= '9') || ('A' <= c && c <= 'F') ||
- ('a' <= c && c <= 'f'));
-}
-
inline unsigned char HexToInt(unsigned char c) {
DCHECK(IsHexDigit(c));
static unsigned char kOffset[4] = {0, 0x30u, 0x37u, 0x57u};