1*6777b538SAndroid Build Coastguard Worker// Copyright 2024 The Chromium Authors 2*6777b538SAndroid Build Coastguard Worker// Use of this source code is governed by a BSD-style license that can be 3*6777b538SAndroid Build Coastguard Worker// found in the LICENSE file. 4*6777b538SAndroid Build Coastguard Worker 5*6777b538SAndroid Build Coastguard Worker#include "crypto/scoped_lacontext.h" 6*6777b538SAndroid Build Coastguard Worker 7*6777b538SAndroid Build Coastguard Worker#include <memory> 8*6777b538SAndroid Build Coastguard Worker 9*6777b538SAndroid Build Coastguard Worker#include <LocalAuthentication/LocalAuthentication.h> 10*6777b538SAndroid Build Coastguard Worker 11*6777b538SAndroid Build Coastguard Worker#include "base/check.h" 12*6777b538SAndroid Build Coastguard Worker 13*6777b538SAndroid Build Coastguard Workernamespace crypto { 14*6777b538SAndroid Build Coastguard Worker 15*6777b538SAndroid Build Coastguard Workerstruct ScopedLAContext::ObjCStorage { 16*6777b538SAndroid Build Coastguard Worker LAContext* __strong context; 17*6777b538SAndroid Build Coastguard Worker}; 18*6777b538SAndroid Build Coastguard Worker 19*6777b538SAndroid Build Coastguard WorkerScopedLAContext::ScopedLAContext(LAContext* lacontext) 20*6777b538SAndroid Build Coastguard Worker : storage_(std::make_unique<ObjCStorage>()) { 21*6777b538SAndroid Build Coastguard Worker storage_->context = lacontext; 22*6777b538SAndroid Build Coastguard Worker} 23*6777b538SAndroid Build Coastguard Worker 24*6777b538SAndroid Build Coastguard WorkerScopedLAContext::ScopedLAContext(ScopedLAContext&&) = default; 25*6777b538SAndroid Build Coastguard WorkerScopedLAContext& ScopedLAContext::operator=(ScopedLAContext&& other) = default; 26*6777b538SAndroid Build Coastguard WorkerScopedLAContext::~ScopedLAContext() = default; 27*6777b538SAndroid Build Coastguard Worker 28*6777b538SAndroid Build Coastguard WorkerLAContext* ScopedLAContext::release() { 29*6777b538SAndroid Build Coastguard Worker CHECK(storage_); 30*6777b538SAndroid Build Coastguard Worker LAContext* context = storage_->context; 31*6777b538SAndroid Build Coastguard Worker storage_.reset(); 32*6777b538SAndroid Build Coastguard Worker return context; 33*6777b538SAndroid Build Coastguard Worker} 34*6777b538SAndroid Build Coastguard Worker 35*6777b538SAndroid Build Coastguard Worker} // namespace crypto 36