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, ...@@ -68,8 +68,8 @@ base::Value ContextAttributesToValue(SSPILibrary* library,
handle, SECPKG_ATTR_NATIVE_NAMES, &native_names, sizeof(native_names)); handle, SECPKG_ATTR_NATIVE_NAMES, &native_names, sizeof(native_names));
if (qc_result == SEC_E_OK && native_names.sClientName && if (qc_result == SEC_E_OK && native_names.sClientName &&
native_names.sServerName) { native_names.sServerName) {
params.SetStringKey("source", native_names.sClientName); params.SetStringKey("source", base::as_u16cstr(native_names.sClientName));
params.SetStringKey("target", native_names.sServerName); params.SetStringKey("target", base::as_u16cstr(native_names.sServerName));
} }
SecPkgContext_NegotiationInfo negotiation_info = {0}; SecPkgContext_NegotiationInfo negotiation_info = {0};
...@@ -78,7 +78,8 @@ base::Value ContextAttributesToValue(SSPILibrary* library, ...@@ -78,7 +78,8 @@ base::Value ContextAttributesToValue(SSPILibrary* library,
sizeof(negotiation_info)); sizeof(negotiation_info));
if (qc_result == SEC_E_OK && negotiation_info.PackageInfo && if (qc_result == SEC_E_OK && negotiation_info.PackageInfo &&
negotiation_info.PackageInfo->Name) { 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 != params.SetBoolKey("open", negotiation_info.NegotiationState !=
SECPKG_NEGOTIATION_COMPLETE); SECPKG_NEGOTIATION_COMPLETE);
} }
...@@ -87,7 +88,8 @@ base::Value ContextAttributesToValue(SSPILibrary* library, ...@@ -87,7 +88,8 @@ base::Value ContextAttributesToValue(SSPILibrary* library,
qc_result = library->QueryContextAttributesEx(handle, SECPKG_ATTR_AUTHORITY, qc_result = library->QueryContextAttributesEx(handle, SECPKG_ATTR_AUTHORITY,
&authority, sizeof(authority)); &authority, sizeof(authority));
if (qc_result == SEC_E_OK && authority.sAuthorityName) { 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)); params.SetKey("flags", ContextFlagsToValue(attributes));
......
...@@ -88,7 +88,7 @@ struct MockContext { ...@@ -88,7 +88,7 @@ struct MockContext {
return base::StringPrintf( return base::StringPrintf(
"%s's token #%d for %S", "%s's token #%d for %S",
base::UTF16ToUTF8(credential->source_principal).c_str(), rounds + 1, base::UTF16ToUTF8(credential->source_principal).c_str(), rounds + 1,
target_principal.c_str()); base::as_wcstr(target_principal));
} }
static MockContext* FromHandle(PCtxtHandle handle) { static MockContext* FromHandle(PCtxtHandle handle) {
...@@ -120,8 +120,9 @@ SECURITY_STATUS MockSSPILibrary::AcquireCredentialsHandle( ...@@ -120,8 +120,9 @@ SECURITY_STATUS MockSSPILibrary::AcquireCredentialsHandle(
PTimeStamp ptsExpiry) { PTimeStamp ptsExpiry) {
DCHECK(!SecIsValidHandle(phCredential)); DCHECK(!SecIsValidHandle(phCredential));
auto* credential = new MockCredential; auto* credential = new MockCredential;
credential->source_principal = pszPrincipal ? pszPrincipal : L"<Default>"; credential->source_principal = pszPrincipal ? base::as_u16cstr(pszPrincipal)
credential->package = pszPackage; : STRING16_LITERAL("<Default>");
credential->package = base::as_u16cstr(pszPackage);
credential->has_explicit_credentials = !!pvAuthData; credential->has_explicit_credentials = !!pvAuthData;
credential->StoreInHandle(phCredential); credential->StoreInHandle(phCredential);
...@@ -150,7 +151,7 @@ SECURITY_STATUS MockSSPILibrary::InitializeSecurityContext( ...@@ -150,7 +151,7 @@ SECURITY_STATUS MockSSPILibrary::InitializeSecurityContext(
PTimeStamp ptsExpiry) { PTimeStamp ptsExpiry) {
MockContext* new_context = new MockContext; MockContext* new_context = new MockContext;
new_context->credential = MockCredential::FromHandle(phCredential); new_context->credential = MockCredential::FromHandle(phCredential);
new_context->target_principal = pszTargetName; new_context->target_principal = base::as_u16cstr(pszTargetName);
new_context->rounds = 0; new_context->rounds = 0;
// Always rotate contexts. That way tests will fail if the caller's context // Always rotate contexts. That way tests will fail if the caller's context
...@@ -200,9 +201,9 @@ SECURITY_STATUS MockSSPILibrary::QueryContextAttributesEx(PCtxtHandle phContext, ...@@ -200,9 +201,9 @@ SECURITY_STATUS MockSSPILibrary::QueryContextAttributesEx(PCtxtHandle phContext,
reinterpret_cast<SecPkgContext_NativeNames*>(pBuffer); reinterpret_cast<SecPkgContext_NativeNames*>(pBuffer);
DCHECK_EQ(sizeof(*native_names), cbBuffer); DCHECK_EQ(sizeof(*native_names), cbBuffer);
native_names->sClientName = native_names->sClientName =
const_cast<SEC_WCHAR*>(context->credential->source_principal.c_str()); base::as_writable_wcstr(context->credential->source_principal);
native_names->sServerName = native_names->sServerName =
const_cast<SEC_WCHAR*>(context->target_principal.c_str()); base::as_writable_wcstr(context->target_principal);
return SEC_E_OK; return SEC_E_OK;
} }
......
...@@ -65,8 +65,8 @@ std::unique_ptr<ProofSource> CreateDefaultProofSourceImpl() { ...@@ -65,8 +65,8 @@ std::unique_ptr<ProofSource> CreateDefaultProofSourceImpl() {
auto proof_source = std::make_unique<net::ProofSourceChromium>(); auto proof_source = std::make_unique<net::ProofSourceChromium>();
CHECK(proof_source->Initialize( CHECK(proof_source->Initialize(
#if defined(OS_WIN) #if defined(OS_WIN)
base::FilePath(base::UTF8ToWide(GetQuicFlag(FLAGS_certificate_file))), base::FilePath(base::UTF8ToUTF16(GetQuicFlag(FLAGS_certificate_file))),
base::FilePath(base::UTF8ToWide(GetQuicFlag(FLAGS_key_file))), base::FilePath(base::UTF8ToUTF16(GetQuicFlag(FLAGS_key_file))),
base::FilePath())); base::FilePath()));
#else #else
base::FilePath(GetQuicFlag(FLAGS_certificate_file)), base::FilePath(GetQuicFlag(FLAGS_certificate_file)),
......
...@@ -21,7 +21,8 @@ TEST(PythonUtils, SetPythonPathInEnvironment) { ...@@ -21,7 +21,8 @@ TEST(PythonUtils, SetPythonPathInEnvironment) {
base::FilePath(FILE_PATH_LITERAL("test/path2"))}, base::FilePath(FILE_PATH_LITERAL("test/path2"))},
&env); &env);
#if defined(OS_WIN) #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 #else
EXPECT_EQ("test/path1:test/path2", env["PYTHONPATH"]); EXPECT_EQ("test/path1:test/path2", env["PYTHONPATH"]);
#endif #endif
......
...@@ -212,7 +212,7 @@ int main(int argc, char* argv[]) { ...@@ -212,7 +212,7 @@ int main(int argc, char* argv[]) {
std::vector<std::string> args; std::vector<std::string> args;
base::CommandLine::StringVector wide_args = command_line.GetArgs(); base::CommandLine::StringVector wide_args = command_line.GetArgs();
for (const auto& arg : wide_args) { for (const auto& arg : wide_args) {
args.push_back(base::WideToUTF8(arg)); args.push_back(base::UTF16ToUTF8(arg));
} }
#else #else
base::CommandLine::StringVector args = command_line.GetArgs(); 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