Commit 36172580 authored by Vasilii Sukhanov's avatar Vasilii Sukhanov Committed by Commit Bot

Instantiate field trials for 'Leak detection' feature right before it's used.

That way the experiment group 'Enable' will only apply to those who use the
feature.

Bug: 986298
Change-Id: I282b75c43ecfd941c032a6d3f275e46fb5d5e82d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1777926
Commit-Queue: Vasilii Sukhanov <vasilii@chromium.org>
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: default avatarJan Wilken Dörrie <jdoerrie@chromium.org>
Auto-Submit: Vasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#692054}
parent 78ba8b7b
...@@ -21,13 +21,14 @@ LeakDetectionCheckFactoryImpl::TryCreateLeakCheck( ...@@ -21,13 +21,14 @@ LeakDetectionCheckFactoryImpl::TryCreateLeakCheck(
LeakDetectionDelegateInterface* delegate, LeakDetectionDelegateInterface* delegate,
signin::IdentityManager* identity_manager, signin::IdentityManager* identity_manager,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory) const { scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory) const {
if (!base::FeatureList::IsEnabled(features::kLeakDetection))
return nullptr;
if (!AuthenticatedLeakCheck::HasAccountForRequest(identity_manager)) { if (!AuthenticatedLeakCheck::HasAccountForRequest(identity_manager)) {
delegate->OnError(LeakDetectionError::kNotSignIn); delegate->OnError(LeakDetectionError::kNotSignIn);
return nullptr; return nullptr;
} }
// Instantiate the field trial right before the feature can be used. Thus,
// the experiment groups will only contain the users who can use the feature.
if (!base::FeatureList::IsEnabled(features::kLeakDetection))
return nullptr;
return std::make_unique<AuthenticatedLeakCheck>( return std::make_unique<AuthenticatedLeakCheck>(
delegate, identity_manager, std::move(url_loader_factory)); delegate, identity_manager, std::move(url_loader_factory));
} }
......
...@@ -49,6 +49,7 @@ TEST_F(LeakDetectionCheckFactoryImplTest, DisabledFeature) { ...@@ -49,6 +49,7 @@ TEST_F(LeakDetectionCheckFactoryImplTest, DisabledFeature) {
base::test::ScopedFeatureList feature_list; base::test::ScopedFeatureList feature_list;
feature_list.InitAndDisableFeature(features::kLeakDetection); feature_list.InitAndDisableFeature(features::kLeakDetection);
identity_env().SetPrimaryAccount(kTestAccount);
EXPECT_FALSE(request_factory().TryCreateLeakCheck( EXPECT_FALSE(request_factory().TryCreateLeakCheck(
&delegate(), identity_env().identity_manager(), url_loader_factory())); &delegate(), identity_env().identity_manager(), url_loader_factory()));
} }
......
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