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