blob: 527425f7fdb46630bd76fa188e27473b30cd318d [file] [log] [blame]
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/variations/synthetic_trials_active_group_id_provider.h"
#include "base/memory/singleton.h"
#include "components/variations/variations_associated_data.h"
#include "components/variations/variations_util.h"
namespace variations {
SyntheticTrialsActiveGroupIdProvider*
SyntheticTrialsActiveGroupIdProvider::GetInstance() {
return base::Singleton<SyntheticTrialsActiveGroupIdProvider>::get();
}
SyntheticTrialsActiveGroupIdProvider::SyntheticTrialsActiveGroupIdProvider() {}
SyntheticTrialsActiveGroupIdProvider::~SyntheticTrialsActiveGroupIdProvider() {}
void SyntheticTrialsActiveGroupIdProvider::OnSyntheticTrialsChanged(
const std::vector<SyntheticTrialGroup>& groups) {
{
base::AutoLock scoped_lock(lock_);
synthetic_trials_.clear();
for (const auto& group : groups)
synthetic_trials_.push_back(group.id);
}
// Update the experiments lists for crash reports to include the newly added
// group.
SetVariationListCrashKeys();
}
void SyntheticTrialsActiveGroupIdProvider::GetActiveGroupIds(
std::vector<ActiveGroupId>* output) {
base::AutoLock scoped_lock(lock_);
for (const auto& group_id : synthetic_trials_)
output->push_back(group_id);
}
} // namespace variations