#include "chrome/browser/android/profile_key_startup_accessor.h"
#include <type_traits>
#include "base/check.h"
#include "base/no_destructor.h"
ProfileKeyStartupAccessor::ProfileKeyStartupAccessor() : key_(nullptr) {}
template <typename T>
T* GetInstanceTemplated() {
if constexpr (std::is_trivially_destructible_v<T>) {
static T instance;
return &instance;
} else {
static base::NoDestructor<T> instance;
return instance.get();
}
}
ProfileKeyStartupAccessor* ProfileKeyStartupAccessor::GetInstance() {
return GetInstanceTemplated<ProfileKeyStartupAccessor>();
}
void ProfileKeyStartupAccessor::SetProfileKey(ProfileKey* key) {
DCHECK(!key_);
key_ = key;
}
void ProfileKeyStartupAccessor::Reset() {
key_ = nullptr;
}