Commit 2e290878 authored by Jan Wilken Dörrie's avatar Jan Wilken Dörrie Committed by Commit Bot

[string16] Fix //net for string16 switch

This change contains a small number fixes for the upcoming
base::string16 switch to std::u16string.

Bug: 911896
Change-Id: I2fabb795c61d6711f0818d655b400593398fd779
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1773223Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#691630}
parent 43ca4133
......@@ -68,8 +68,8 @@ base::Value ContextAttributesToValue(SSPILibrary* library,
handle, SECPKG_ATTR_NATIVE_NAMES, &native_names, sizeof(native_names));
if (qc_result == SEC_E_OK && native_names.sClientName &&
native_names.sServerName) {
params.SetStringKey("source", native_names.sClientName);
params.SetStringKey("target", native_names.sServerName);
params.SetStringKey("source", base::as_u16cstr(native_names.sClientName));
params.SetStringKey("target", base::as_u16cstr(native_names.sServerName));
}
SecPkgContext_NegotiationInfo negotiation_info = {0};
......@@ -78,7 +78,8 @@ base::Value ContextAttributesToValue(SSPILibrary* library,
sizeof(negotiation_info));
if (qc_result == SEC_E_OK && negotiation_info.PackageInfo &&
negotiation_info.PackageInfo->Name) {
params.SetStringKey("mechanism", negotiation_info.PackageInfo->Name);
params.SetStringKey("mechanism",
base::as_u16cstr(negotiation_info.PackageInfo->Name));
params.SetBoolKey("open", negotiation_info.NegotiationState !=
SECPKG_NEGOTIATION_COMPLETE);
}
......@@ -87,7 +88,8 @@ base::Value ContextAttributesToValue(SSPILibrary* library,
qc_result = library->QueryContextAttributesEx(handle, SECPKG_ATTR_AUTHORITY,
&authority, sizeof(authority));
if (qc_result == SEC_E_OK && authority.sAuthorityName) {
params.SetStringKey("authority", authority.sAuthorityName);
params.SetStringKey("authority",
base::as_u16cstr(authority.sAuthorityName));
}
params.SetKey("flags", ContextFlagsToValue(attributes));
......
......@@ -88,7 +88,7 @@ struct MockContext {
return base::StringPrintf(
"%s's token #%d for %S",
base::UTF16ToUTF8(credential->source_principal).c_str(), rounds + 1,
target_principal.c_str());
base::as_wcstr(target_principal));
}
static MockContext* FromHandle(PCtxtHandle handle) {
......@@ -120,8 +120,9 @@ SECURITY_STATUS MockSSPILibrary::AcquireCredentialsHandle(
PTimeStamp ptsExpiry) {
DCHECK(!SecIsValidHandle(phCredential));
auto* credential = new MockCredential;
credential->source_principal = pszPrincipal ? pszPrincipal : L"<Default>";
credential->package = pszPackage;
credential->source_principal = pszPrincipal ? base::as_u16cstr(pszPrincipal)
: STRING16_LITERAL("<Default>");
credential->package = base::as_u16cstr(pszPackage);
credential->has_explicit_credentials = !!pvAuthData;
credential->StoreInHandle(phCredential);
......@@ -150,7 +151,7 @@ SECURITY_STATUS MockSSPILibrary::InitializeSecurityContext(
PTimeStamp ptsExpiry) {
MockContext* new_context = new MockContext;
new_context->credential = MockCredential::FromHandle(phCredential);
new_context->target_principal = pszTargetName;
new_context->target_principal = base::as_u16cstr(pszTargetName);
new_context->rounds = 0;
// Always rotate contexts. That way tests will fail if the caller's context
......@@ -200,9 +201,9 @@ SECURITY_STATUS MockSSPILibrary::QueryContextAttributesEx(PCtxtHandle phContext,
reinterpret_cast<SecPkgContext_NativeNames*>(pBuffer);
DCHECK_EQ(sizeof(*native_names), cbBuffer);
native_names->sClientName =
const_cast<SEC_WCHAR*>(context->credential->source_principal.c_str());
base::as_writable_wcstr(context->credential->source_principal);
native_names->sServerName =
const_cast<SEC_WCHAR*>(context->target_principal.c_str());
base::as_writable_wcstr(context->target_principal);
return SEC_E_OK;
}
......
......@@ -65,8 +65,8 @@ std::unique_ptr<ProofSource> CreateDefaultProofSourceImpl() {
auto proof_source = std::make_unique<net::ProofSourceChromium>();
CHECK(proof_source->Initialize(
#if defined(OS_WIN)
base::FilePath(base::UTF8ToWide(GetQuicFlag(FLAGS_certificate_file))),
base::FilePath(base::UTF8ToWide(GetQuicFlag(FLAGS_key_file))),
base::FilePath(base::UTF8ToUTF16(GetQuicFlag(FLAGS_certificate_file))),
base::FilePath(base::UTF8ToUTF16(GetQuicFlag(FLAGS_key_file))),
base::FilePath()));
#else
base::FilePath(GetQuicFlag(FLAGS_certificate_file)),
......
......@@ -21,7 +21,8 @@ TEST(PythonUtils, SetPythonPathInEnvironment) {
base::FilePath(FILE_PATH_LITERAL("test/path2"))},
&env);
#if defined(OS_WIN)
EXPECT_EQ(L"test/path1;test/path2", env[L"PYTHONPATH"]);
EXPECT_EQ(FILE_PATH_LITERAL("test/path1;test/path2"),
env[FILE_PATH_LITERAL("PYTHONPATH")]);
#else
EXPECT_EQ("test/path1:test/path2", env["PYTHONPATH"]);
#endif
......
......@@ -212,7 +212,7 @@ int main(int argc, char* argv[]) {
std::vector<std::string> args;
base::CommandLine::StringVector wide_args = command_line.GetArgs();
for (const auto& arg : wide_args) {
args.push_back(base::WideToUTF8(arg));
args.push_back(base::UTF16ToUTF8(arg));
}
#else
base::CommandLine::StringVector args = command_line.GetArgs();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment