Commit e176f8b9 authored by Daniel Bratell's avatar Daniel Bratell Committed by Commit Bot

Give two cert testing classes unique names

A second WrappedTestingCertVerifier and
g_cert_verifier_for_testing just arrived and in some
extreme (non standard) jumbo build configurations those
ended up in the same translation unit. Since translation units
only have one common anonymous namespace, there was a symbol clash.

This patch renames the global variables to
g_cert_verifier_for_io_thread_testing and
g_cert_verifier_for_profile_io_data_testing and renames the classes
to WrappedCertVerifierForIoThreadTesting and
WrappedCertVerifierForProfileIoDataTesting.

Change-Id: I41549bc81943864f64ce304220e20ab00d91c889
Reviewed-on: https://chromium-review.googlesource.com/992494Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Reviewed-by: default avatarMatt Mueller <mattm@chromium.org>
Commit-Queue: Daniel Bratell <bratell@opera.com>
Cr-Commit-Position: refs/heads/master@{#548029}
parent 6e1e31ed
...@@ -145,15 +145,15 @@ class SafeBrowsingURLRequestContext; ...@@ -145,15 +145,15 @@ class SafeBrowsingURLRequestContext;
namespace { namespace {
net::CertVerifier* g_cert_verifier_for_testing = nullptr; net::CertVerifier* g_cert_verifier_for_io_thread_testing = nullptr;
// A CertVerifier that forwards all requests to |g_cert_verifier_for_testing|. // A CertVerifier that forwards all requests to
// This is used to allow IOThread to have its own // |g_cert_verifier_for_io_thread_testing|. This is used to allow IOThread to
// std::unique_ptr<net::CertVerifier> while forwarding calls to the static // have its own std::unique_ptr<net::CertVerifier> while forwarding calls to the
// verifier. // static verifier.
class WrappedTestingCertVerifier : public net::CertVerifier { class WrappedCertVerifierForIOThreadTesting : public net::CertVerifier {
public: public:
~WrappedTestingCertVerifier() override = default; ~WrappedCertVerifierForIOThreadTesting() override = default;
// CertVerifier implementation // CertVerifier implementation
int Verify(const RequestParams& params, int Verify(const RequestParams& params,
...@@ -163,15 +163,15 @@ class WrappedTestingCertVerifier : public net::CertVerifier { ...@@ -163,15 +163,15 @@ class WrappedTestingCertVerifier : public net::CertVerifier {
std::unique_ptr<Request>* out_req, std::unique_ptr<Request>* out_req,
const net::NetLogWithSource& net_log) override { const net::NetLogWithSource& net_log) override {
verify_result->Reset(); verify_result->Reset();
if (!g_cert_verifier_for_testing) if (!g_cert_verifier_for_io_thread_testing)
return net::ERR_FAILED; return net::ERR_FAILED;
return g_cert_verifier_for_testing->Verify(params, crl_set, verify_result, return g_cert_verifier_for_io_thread_testing->Verify(
callback, out_req, net_log); params, crl_set, verify_result, callback, out_req, net_log);
} }
bool SupportsOCSPStapling() override { bool SupportsOCSPStapling() override {
if (!g_cert_verifier_for_testing) if (!g_cert_verifier_for_io_thread_testing)
return false; return false;
return g_cert_verifier_for_testing->SupportsOCSPStapling(); return g_cert_verifier_for_io_thread_testing->SupportsOCSPStapling();
} }
}; };
...@@ -628,7 +628,7 @@ void IOThread::RegisterPrefs(PrefRegistrySimple* registry) { ...@@ -628,7 +628,7 @@ void IOThread::RegisterPrefs(PrefRegistrySimple* registry) {
// static // static
void IOThread::SetCertVerifierForTesting(net::CertVerifier* cert_verifier) { void IOThread::SetCertVerifierForTesting(net::CertVerifier* cert_verifier) {
g_cert_verifier_for_testing = cert_verifier; g_cert_verifier_for_io_thread_testing = cert_verifier;
} }
void IOThread::UpdateServerWhitelist() { void IOThread::UpdateServerWhitelist() {
...@@ -796,8 +796,8 @@ void IOThread::ConstructSystemRequestContext() { ...@@ -796,8 +796,8 @@ void IOThread::ConstructSystemRequestContext() {
builder->set_host_resolver(std::move(host_resolver)); builder->set_host_resolver(std::move(host_resolver));
std::unique_ptr<net::CertVerifier> cert_verifier; std::unique_ptr<net::CertVerifier> cert_verifier;
if (g_cert_verifier_for_testing) { if (g_cert_verifier_for_io_thread_testing) {
cert_verifier = std::make_unique<WrappedTestingCertVerifier>(); cert_verifier = std::make_unique<WrappedCertVerifierForIOThreadTesting>();
} else { } else {
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
// Creates a CertVerifyProc that doesn't allow any profile-provided certs. // Creates a CertVerifyProc that doesn't allow any profile-provided certs.
......
...@@ -184,15 +184,15 @@ using content::ResourceContext; ...@@ -184,15 +184,15 @@ using content::ResourceContext;
namespace { namespace {
net::CertVerifier* g_cert_verifier_for_testing = nullptr; net::CertVerifier* g_cert_verifier_for_profile_io_data_testing = nullptr;
// A CertVerifier that forwards all requests to |g_cert_verifier_for_testing|. // A CertVerifier that forwards all requests to
// This is used to allow Profiles to have their own // |g_cert_verifier_for_profile_io_data_testing|. This is used to allow Profiles
// std::unique_ptr<net::CertVerifier> while forwarding calls to the shared // to have their own std::unique_ptr<net::CertVerifier> while forwarding calls
// verifier. // to the shared verifier.
class WrappedTestingCertVerifier : public net::CertVerifier { class WrappedCertVerifierForProfileIODataTesting : public net::CertVerifier {
public: public:
~WrappedTestingCertVerifier() override = default; ~WrappedCertVerifierForProfileIODataTesting() override = default;
// CertVerifier implementation // CertVerifier implementation
int Verify(const RequestParams& params, int Verify(const RequestParams& params,
...@@ -202,15 +202,15 @@ class WrappedTestingCertVerifier : public net::CertVerifier { ...@@ -202,15 +202,15 @@ class WrappedTestingCertVerifier : public net::CertVerifier {
std::unique_ptr<Request>* out_req, std::unique_ptr<Request>* out_req,
const net::NetLogWithSource& net_log) override { const net::NetLogWithSource& net_log) override {
verify_result->Reset(); verify_result->Reset();
if (!g_cert_verifier_for_testing) if (!g_cert_verifier_for_profile_io_data_testing)
return net::ERR_FAILED; return net::ERR_FAILED;
return g_cert_verifier_for_testing->Verify(params, crl_set, verify_result, return g_cert_verifier_for_profile_io_data_testing->Verify(
callback, out_req, net_log); params, crl_set, verify_result, callback, out_req, net_log);
} }
bool SupportsOCSPStapling() override { bool SupportsOCSPStapling() override {
if (!g_cert_verifier_for_testing) if (!g_cert_verifier_for_profile_io_data_testing)
return false; return false;
return g_cert_verifier_for_testing->SupportsOCSPStapling(); return g_cert_verifier_for_profile_io_data_testing->SupportsOCSPStapling();
} }
}; };
...@@ -541,7 +541,7 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) { ...@@ -541,7 +541,7 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) {
network_prediction_options_.MoveToThread(io_task_runner); network_prediction_options_.MoveToThread(io_task_runner);
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
if (!g_cert_verifier_for_testing) { if (!g_cert_verifier_for_profile_io_data_testing) {
profile_params_->policy_cert_verifier = profile_params_->policy_cert_verifier =
policy::PolicyCertServiceFactory::CreateForProfile(profile); policy::PolicyCertServiceFactory::CreateForProfile(profile);
} }
...@@ -851,7 +851,7 @@ void ProfileIOData::AddProtocolHandlersToBuilder( ...@@ -851,7 +851,7 @@ void ProfileIOData::AddProtocolHandlersToBuilder(
// static // static
void ProfileIOData::SetCertVerifierForTesting( void ProfileIOData::SetCertVerifierForTesting(
net::CertVerifier* cert_verifier) { net::CertVerifier* cert_verifier) {
g_cert_verifier_for_testing = cert_verifier; g_cert_verifier_for_profile_io_data_testing = cert_verifier;
} }
content::ResourceContext* ProfileIOData::GetResourceContext() const { content::ResourceContext* ProfileIOData::GetResourceContext() const {
...@@ -1143,8 +1143,9 @@ void ProfileIOData::Init( ...@@ -1143,8 +1143,9 @@ void ProfileIOData::Init(
certificate_provider_ = std::move(profile_params_->certificate_provider); certificate_provider_ = std::move(profile_params_->certificate_provider);
#endif #endif
if (g_cert_verifier_for_testing) { if (g_cert_verifier_for_profile_io_data_testing) {
builder->SetCertVerifier(std::make_unique<WrappedTestingCertVerifier>()); builder->SetCertVerifier(
std::make_unique<WrappedCertVerifierForProfileIODataTesting>());
} else { } else {
std::unique_ptr<net::CertVerifier> cert_verifier; std::unique_ptr<net::CertVerifier> cert_verifier;
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
......
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