| // Copyright 2022 The Chromium Authors |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| #include "components/file_access/scoped_file_access.h" |
| #if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) |
| ScopedFileAccess::ScopedFileAccess(bool allowed, base::ScopedFD fd) |
| : allowed_(allowed), lifeline_fd_(std::move(fd)) {} |
| ScopedFileAccess::ScopedFileAccess(bool allowed) : allowed_(allowed) {} |
| ScopedFileAccess::ScopedFileAccess(ScopedFileAccess&& other) = default; |
| ScopedFileAccess& ScopedFileAccess::operator=(ScopedFileAccess&& other) = |
| ScopedFileAccess::~ScopedFileAccess() = default; |
| ScopedFileAccess ScopedFileAccess::Allowed() { |
| #if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) |
| return ScopedFileAccess(/*allowed=*/true, base::ScopedFD()); |
| return ScopedFileAccess(/*allowed=*/true); |
| ScopedFileAccess ScopedFileAccess::Denied() { |
| #if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) |
| return ScopedFileAccess(/*allowed=*/false, base::ScopedFD()); |
| return ScopedFileAccess(/*allowed=*/false); |
| } // namespace file_access |