Skip to content

Commit

Permalink
Use base:: on string16 and char16 in net/ and url/
Browse files Browse the repository at this point in the history
BUG=none
TEST=no change
TBR=brettw@chromium.org

Review URL: https://codereview.chromium.org/16413006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205636 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
avi@chromium.org committed Jun 11, 2013
1 parent e8eecbf commit 3774f83
Show file tree
Hide file tree
Showing 34 changed files with 277 additions and 260 deletions.
10 changes: 5 additions & 5 deletions net/base/net_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ UScriptCode NormalizeScript(UScriptCode code) {
}
}

bool IsIDNComponentInSingleScript(const char16* str, int str_len) {
bool IsIDNComponentInSingleScript(const base::char16* str, int str_len) {
UScriptCode first_script = USCRIPT_INVALID_CODE;
bool is_first = true;

Expand Down Expand Up @@ -301,7 +301,7 @@ bool IsComponentCoveredByLang(const icu::UnicodeSet& component_characters,

// Returns true if the given Unicode host component is safe to display to the
// user.
bool IsIDNComponentSafe(const char16* str,
bool IsIDNComponentSafe(const base::char16* str,
int str_len,
const std::string& languages) {
// Most common cases (non-IDN) do not reach here so that we don't
Expand Down Expand Up @@ -399,7 +399,7 @@ bool IsIDNComponentSafe(const char16* str,
// will be APPENDED to the given output string and will be the same as the input
// if it is not IDN or the IDN is unsafe to display. Returns whether any
// conversion was performed.
bool IDNToUnicodeOneComponent(const char16* comp,
bool IDNToUnicodeOneComponent(const base::char16* comp,
size_t comp_len,
const std::string& languages,
base::string16* out) {
Expand All @@ -408,9 +408,9 @@ bool IDNToUnicodeOneComponent(const char16* comp,
return false;

// Only transform if the input can be an IDN component.
static const char16 kIdnPrefix[] = {'x', 'n', '-', '-'};
static const base::char16 kIdnPrefix[] = {'x', 'n', '-', '-'};
if ((comp_len > arraysize(kIdnPrefix)) &&
!memcmp(comp, kIdnPrefix, arraysize(kIdnPrefix) * sizeof(char16))) {
!memcmp(comp, kIdnPrefix, arraysize(kIdnPrefix) * sizeof(base::char16))) {
// Repeatedly expand the output string until it's big enough. It looks like
// ICU will return the required size of the buffer, but that's not
// documented, so we'll just grow by 2x. This should be rare and is not on a
Expand Down
2 changes: 1 addition & 1 deletion net/base/zap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void ZapString(std::string* s) {

void ZapString(base::string16* s) {
if (!s->empty())
ZapBuf(&(*s)[0], s->length() * sizeof(char16));
ZapBuf(&(*s)[0], s->length() * sizeof(base::char16));
}

} // net
9 changes: 5 additions & 4 deletions net/cert/x509_cert_types_mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ std::string Latin1DataToUTF8String(CSSM_DATA data) {

// Converts big-endian UTF-16 to UTF-8 in a std::string.
// Note: The byte-order flipping is done in place on the input buffer!
bool UTF16BigEndianToUTF8(char16* chars, size_t length,
bool UTF16BigEndianToUTF8(base::char16* chars, size_t length,
std::string* out_string) {
for (size_t i = 0; i < length; i++)
chars[i] = EndianU16_BtoN(chars[i]);
Expand Down Expand Up @@ -241,9 +241,10 @@ bool CertPrincipal::ParseDistinguishedName(const void* ber_name_data,
break;
case BER_TAG_PKIX_BMP_STRING: { // UTF-16, big-endian
std::string value;
UTF16BigEndianToUTF8(reinterpret_cast<char16*>(pair->value.Data),
pair->value.Length / sizeof(char16),
&value);
UTF16BigEndianToUTF8(
reinterpret_cast<base::char16*>(pair->value.Data),
pair->value.Length / sizeof(base::char16),
&value);
AddTypeValuePair(pair->type, value, values);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion net/http/http_auth_handler_ntlm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int HttpAuthHandlerNTLM::GenerateAuthTokenImpl(
base::string16 domain;
base::string16 user;
const base::string16& username = credentials->username();
const char16 backslash_character = '\\';
const base::char16 backslash_character = '\\';
size_t backslash_idx = username.find(backslash_character);
if (backslash_idx == base::string16::npos) {
user = username;
Expand Down
8 changes: 4 additions & 4 deletions url/gurl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ GURL::GURL(const std::string& url_string) : inner_url_(NULL) {
}
}

GURL::GURL(const string16& url_string) : inner_url_(NULL) {
GURL::GURL(const base::string16& url_string) : inner_url_(NULL) {
is_valid_ = InitCanonical(url_string, &spec_, &parsed_);
if (is_valid_ && SchemeIsFileSystem()) {
inner_url_ =
Expand Down Expand Up @@ -179,7 +179,7 @@ const std::string& GURL::spec() const {
GURL GURL::Resolve(const std::string& relative) const {
return ResolveWithCharsetConverter(relative, NULL);
}
GURL GURL::Resolve(const string16& relative) const {
GURL GURL::Resolve(const base::string16& relative) const {
return ResolveWithCharsetConverter(relative, NULL);
}

Expand Down Expand Up @@ -217,7 +217,7 @@ GURL GURL::ResolveWithCharsetConverter(

// Note: code duplicated above (it's inconvenient to use a template here).
GURL GURL::ResolveWithCharsetConverter(
const string16& relative,
const base::string16& relative,
url_canon::CharsetConverter* charset_converter) const {
// Not allowed for invalid URLs.
if (!is_valid_)
Expand Down Expand Up @@ -275,7 +275,7 @@ GURL GURL::ReplaceComponents(

// Note: code duplicated above (it's inconvenient to use a template here).
GURL GURL::ReplaceComponents(
const url_canon::Replacements<char16>& replacements) const {
const url_canon::Replacements<base::char16>& replacements) const {
GURL result;

// Not allowed for invalid URLs.
Expand Down
10 changes: 5 additions & 5 deletions url/gurl.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class URL_EXPORT GURL {
public:
typedef url_canon::StdStringReplacements<std::string> Replacements;
typedef url_canon::StdStringReplacements<string16> ReplacementsW;
typedef url_canon::StdStringReplacements<base::string16> ReplacementsW;

// Creates an empty, invalid URL.
GURL();
Expand All @@ -34,7 +34,7 @@ class URL_EXPORT GURL {
// version to assume the query parameter encoding should be the same as the
// input encoding.
explicit GURL(const std::string& url_string /*, output_param_encoding*/);
explicit GURL(const string16& url_string /*, output_param_encoding*/);
explicit GURL(const base::string16& url_string /*, output_param_encoding*/);

// Constructor for URLs that have already been parsed and canonicalized. This
// is used for conversions from KURL, for example. The caller must supply all
Expand Down Expand Up @@ -129,7 +129,7 @@ class URL_EXPORT GURL {
// It is an error to resolve a URL relative to an invalid URL. The result
// will be the empty URL.
GURL Resolve(const std::string& relative) const;
GURL Resolve(const string16& relative) const;
GURL Resolve(const base::string16& relative) const;

// Like Resolve() above but takes a character set encoder which will be used
// for any query text specified in the input. The charset converter parameter
Expand All @@ -142,7 +142,7 @@ class URL_EXPORT GURL {
const std::string& relative,
url_canon::CharsetConverter* charset_converter) const;
GURL ResolveWithCharsetConverter(
const string16& relative,
const base::string16& relative,
url_canon::CharsetConverter* charset_converter) const;

// Creates a new GURL by replacing the current URL's components with the
Expand All @@ -159,7 +159,7 @@ class URL_EXPORT GURL {
GURL ReplaceComponents(
const url_canon::Replacements<char>& replacements) const;
GURL ReplaceComponents(
const url_canon::Replacements<char16>& replacements) const;
const url_canon::Replacements<base::char16>& replacements) const;

// A helper function that is equivalent to replacing the path with a slash
// and clearing out everything after that. We sometimes need to know just the
Expand Down
Loading

0 comments on commit 3774f83

Please sign in to comment.