#ifndef BASE_THREADING_THREAD_RESTRICTIONS_H_
#define BASE_THREADING_THREAD_RESTRICTIONS_H_
#include "base/auto_reset.h"
#include "base/base_export.h"
#include "base/compiler_specific.h"
#include "base/dcheck_is_on.h"
#include "base/gtest_prod_util.h"
#include "base/location.h"
#include "build/build_config.h"
#if DCHECK_IS_ON()
#include "base/debug/stack_trace.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#endif
class BrowserProcessImpl;
class BrowserThemePack;
class ChromeNSSCryptoModuleDelegate;
class DesktopNotificationBalloon;
class FirefoxProfileLock;
class KeyStorageLinux;
class NativeBackendKWallet;
class NativeDesktopMediaList;
class Profile;
class ProfileImpl;
class StartupTabProviderImpl;
class GaiaConfig;
class WebEngineBrowserMainParts;
class ScopedAllowBlockingForProfile;
#if defined(OHOS_COOKIE)
class CefCookieManagerImpl;
#endif
#if defined(OHOS_MSGPORT)
class CefBrowserHostBase;
#endif
namespace base {
class File;
class FilePath;
}
#if defined(OHOS_INCOGNITO_MODE)
class CefIncognitoCookieManagerImpl;
#endif
Profile* GetLastProfileMac();
bool EnsureBrowserStateDirectoriesCreated(const base::FilePath&,
const base::FilePath&,
const base::FilePath&);
namespace android_webview {
class AwFormDatabaseService;
class CookieManager;
class JsSandboxIsolate;
class ScopedAllowInitGLBindings;
class VizCompositorThreadRunnerWebView;
}
namespace ash {
class MojoUtils;
class BrowserDataBackMigrator;
class LoginEventRecorder;
class StartupCustomizationDocument;
class StartupUtils;
bool CameraAppUIShouldEnableLocalOverride(const std::string&);
namespace system {
class StatisticsProviderImpl;
}
}
namespace audio {
class OutputDevice;
}
namespace blink {
class DiskDataAllocator;
class IdentifiabilityActiveSampler;
class RTCVideoDecoderAdapter;
class RTCVideoEncoder;
class SourceStream;
class VideoFrameResourceProvider;
class WebRtcVideoFrameAdapter;
class LegacyWebRtcVideoFrameAdapter;
class VideoTrackRecorderImplContextProvider;
class WorkerThread;
namespace scheduler {
class NonMainThreadImpl;
}
}
namespace cc {
class CategorizedWorkerPoolImpl;
class CategorizedWorkerPoolJob;
class CategorizedWorkerPool;
class CompletionEvent;
class TileTaskManagerImpl;
}
namespace chrome {
bool PathProvider(int, base::FilePath*);
void SessionEnding();
}
namespace chromecast {
class CrashUtil;
}
namespace chromeos {
class BlockingMethodCaller;
namespace system {
bool IsCoreSchedulingAvailable();
int NumberOfPhysicalCores();
}
}
namespace chrome_cleaner {
class ResetShortcutsComponent;
class SystemReportComponent;
}
namespace content {
class BrowserGpuChannelHostFactory;
class BrowserMainLoop;
class BrowserProcessIOThread;
class BrowserTestBase;
#if BUILDFLAG(IS_IOS)
class ContentMainRunnerImpl;
#endif
class DesktopCaptureDevice;
class DWriteFontCollectionProxy;
class DWriteFontProxyImpl;
class EmergencyTraceFinalisationCoordinator;
class InProcessUtilityThread;
class NestedMessagePumpAndroid;
class NetworkServiceInstancePrivate;
class PepperPrintSettingsManagerImpl;
class RenderProcessHostImpl;
class RenderProcessHost;
class RenderWidgetHostViewMac;
class RendererBlinkPlatformImpl;
class RTCVideoDecoder;
class SandboxHostLinux;
class ScopedAllowWaitForDebugURL;
class ServiceWorkerContextClient;
class ShellPathProvider;
class SynchronousCompositor;
class SynchronousCompositorHost;
class SynchronousCompositorSyncCallBridge;
class ScopedAllowBlockingForViewAura;
class TextInputClientMac;
class WebContentsImpl;
class WebContentsViewMac;
base::File CreateFileForDrop(base::FilePath*);
}
namespace cronet {
class CronetPrefsManager;
class CronetContext;
}
namespace crosapi {
class LacrosThreadTypeDelegate;
}
namespace crypto {
class ScopedAllowBlockingForNSS;
}
namespace dbus {
class Bus;
}
namespace drive {
class FakeDriveService;
}
namespace device {
class UsbContext;
}
namespace discardable_memory {
class ClientDiscardableSharedMemoryManager;
}
namespace disk_cache {
class BackendImpl;
class InFlightIO;
bool CleanupDirectorySync(const base::FilePath&);
}
namespace enterprise_connectors {
class LinuxKeyRotationCommand;
}
namespace extensions {
class InstalledLoader;
class UnpackedInstaller;
}
namespace font_service::internal {
class MappedFontFile;
}
namespace functions {
class ExecScriptScopedAllowBaseSyncPrimitives;
}
namespace gl {
struct GLImplementationParts;
namespace init {
bool InitializeStaticGLBindings(GLImplementationParts);
}
}
namespace history_report {
class HistoryReportJniBridge;
}
namespace ios_web_view {
class WebViewBrowserState;
}
namespace io_thread {
class IOSIOThread;
}
namespace leveldb::port {
class CondVar;
}
namespace nearby::chrome {
class ScheduledExecutor;
class SubmittableExecutor;
}
namespace media {
class AudioInputDevice;
class AudioOutputDevice;
class BlockingUrlProtocol;
class FileVideoCaptureDeviceFactory;
class MojoVideoEncodeAccelerator;
class PaintCanvasVideoRenderer;
}
namespace memory_instrumentation {
class OSMetrics;
}
namespace memory_pressure {
class UserLevelMemoryPressureSignalGenerator;
}
namespace metrics {
class AndroidMetricsServiceClient;
class CleanExitBeacon;
}
namespace midi {
class TaskService;
}
namespace module_installer {
class ScopedAllowModulePakLoad;
}
namespace mojo {
class CoreLibraryInitializer;
class SyncCallRestrictions;
namespace core {
class ScopedIPCSupport;
namespace ipcz_driver {
class MojoTrap;
}
}
}
namespace printing {
class LocalPrinterHandlerDefault;
#if BUILDFLAG(IS_MAC)
class PrintBackendServiceImpl;
#endif
class PrintBackendServiceManager;
class PrinterQuery;
}
namespace rlz_lib {
class FinancialPing;
}
namespace storage {
class ObfuscatedFileUtil;
}
namespace syncer {
class GetLocalChangesRequest;
class HttpBridge;
}
namespace ui {
class DrmThreadProxy;
class DrmDisplayHostManager;
class SelectFileDialogLinux;
class ScopedAllowBlockingForGbmSurface;
}
namespace weblayer {
class BrowserContextImpl;
class ContentBrowserClientImpl;
class ProfileImpl;
class WebLayerPathProvider;
}
namespace net {
class GSSAPISharedLibrary;
class MultiThreadedCertVerifierScopedAllowBaseSyncPrimitives;
class MultiThreadedProxyResolverScopedAllowJoinOnIO;
class NetworkChangeNotifierMac;
class NetworkConfigWatcherMacThread;
class ProxyConfigServiceWin;
class ScopedAllowBlockingForSettingGetter;
namespace internal {
class AddressTrackerLinux;
}
}
namespace proxy_resolver {
class ScopedAllowThreadJoinForProxyResolverV8Tracing;
}
namespace remote_cocoa {
class DroppedScreenShotCopierMac;
class SelectFileDialogBridge;
}
namespace remoting {
class AutoThread;
class ScopedBypassIOThreadRestrictions;
namespace protocol {
class ScopedAllowSyncPrimitivesForWebRtcDataStreamAdapter;
class ScopedAllowSyncPrimitivesForWebRtcTransport;
class ScopedAllowThreadJoinForWebRtcTransport;
}
}
namespace service_manager {
class ServiceProcessLauncher;
}
namespace shell_integration_linux {
class LaunchXdgUtilityScopedAllowBaseSyncPrimitives;
}
namespace tracing {
class FuchsiaPerfettoProducerConnector;
}
namespace ui {
class WindowResizeHelperMac;
}
namespace updater {
class SystemctlLauncherScopedAllowBaseSyncPrimitives;
}
namespace viz {
class HostGpuMemoryBufferManager;
class ClientGpuMemoryBufferManager;
}
namespace vr {
class VrShell;
}
namespace web {
class WebMainLoop;
}
namespace webrtc {
class DesktopConfigurationMonitor;
}
namespace base {
class Environment;
}
bool HasWaylandDisplay(base::Environment* env);
namespace base {
namespace sequence_manager::internal {
class TaskQueueImpl;
}
namespace android {
class JavaHandlerThread;
class ScopedAllowBlockingForImportantFileWriter;
}
namespace internal {
class GetAppOutputScopedAllowBaseSyncPrimitives;
class JobTaskSource;
class TaskTracker;
bool ReadProcFile(const FilePath& file, std::string* buffer);
}
namespace subtle {
class PlatformSharedMemoryRegion;
}
namespace debug {
class StackTrace;
}
namespace win {
class OSInfo;
class ScopedAllowBlockingForUserAccountControl;
}
class AdjustOOMScoreHelper;
class ChromeOSVersionInfo;
class FileDescriptorWatcher;
class FilePath;
class Process;
class ScopedAllowBlockingForProc;
class ScopedAllowBlockingForProcessMetrics;
class ScopedAllowThreadRecallForStackSamplingProfiler;
class SimpleThread;
class StackSamplingProfiler;
class TestCustomDisallow;
class Thread;
void GetNSExecutablePath(base::FilePath* path);
#if DCHECK_IS_ON()
#define INLINE_OR_NOT_TAIL_CALLED NOT_TAIL_CALLED BASE_EXPORT
#define EMPTY_BODY_IF_DCHECK_IS_OFF
#define DEFAULT_IF_DCHECK_IS_OFF
class BooleanWithStack {
public:
BooleanWithStack() = default;
explicit BooleanWithStack(bool value);
explicit operator bool() const { return value_; }
friend std::ostream& operator<<(std::ostream& out,
const BooleanWithStack& bws);
private:
bool value_ = false;
absl::optional<debug::StackTrace> stack_;
};
#else
#define INLINE_OR_NOT_TAIL_CALLED inline
#define EMPTY_BODY_IF_DCHECK_IS_OFF \
{} \
static_assert(true)
#define DEFAULT_IF_DCHECK_IS_OFF = default
#endif
namespace internal {
INLINE_OR_NOT_TAIL_CALLED void AssertBlockingAllowed()
EMPTY_BODY_IF_DCHECK_IS_OFF;
INLINE_OR_NOT_TAIL_CALLED void AssertBlockingDisallowedForTesting()
EMPTY_BODY_IF_DCHECK_IS_OFF;
}
INLINE_OR_NOT_TAIL_CALLED void DisallowBlocking() EMPTY_BODY_IF_DCHECK_IS_OFF;
class BASE_EXPORT [[maybe_unused, nodiscard]] ScopedDisallowBlocking {
public:
ScopedDisallowBlocking() DEFAULT_IF_DCHECK_IS_OFF;
ScopedDisallowBlocking(const ScopedDisallowBlocking&) = delete;
ScopedDisallowBlocking& operator=(const ScopedDisallowBlocking&) = delete;
~ScopedDisallowBlocking() DEFAULT_IF_DCHECK_IS_OFF;
private:
#if DCHECK_IS_ON()
const AutoReset<BooleanWithStack> resetter_;
#endif
};
class BASE_EXPORT [[maybe_unused, nodiscard]] ScopedAllowBlocking {
public:
ScopedAllowBlocking(const ScopedAllowBlocking&) = delete;
ScopedAllowBlocking& operator=(const ScopedAllowBlocking&) = delete;
private:
FRIEND_TEST_ALL_PREFIXES(ThreadRestrictionsTest,
NestedAllowRestoresPreviousStack);
FRIEND_TEST_ALL_PREFIXES(ThreadRestrictionsTest, ScopedAllowBlocking);
friend class ScopedAllowBlockingForTesting;
friend class ::BrowserThemePack;
friend class ::DesktopNotificationBalloon;
friend class ::FirefoxProfileLock;
friend class ::GaiaConfig;
friend class ::ProfileImpl;
friend class ::ScopedAllowBlockingForProfile;
friend class ::StartupTabProviderImpl;
friend class ::WebEngineBrowserMainParts;
friend class android_webview::ScopedAllowInitGLBindings;
friend class ash::BrowserDataBackMigrator;
friend class ash::LoginEventRecorder;
friend class ash::MojoUtils;
friend class ash::StartupCustomizationDocument;
friend class ash::StartupUtils;
friend class base::AdjustOOMScoreHelper;
friend class base::ChromeOSVersionInfo;
friend class base::Process;
friend class base::ScopedAllowBlockingForProc;
friend class base::ScopedAllowBlockingForProcessMetrics;
friend class base::StackSamplingProfiler;
friend class base::android::ScopedAllowBlockingForImportantFileWriter;
friend class base::debug::StackTrace;
friend class base::subtle::PlatformSharedMemoryRegion;
friend class base::win::ScopedAllowBlockingForUserAccountControl;
friend class blink::DiskDataAllocator;
friend class chromecast::CrashUtil;
friend class content::BrowserProcessIOThread;
friend class content::DWriteFontProxyImpl;
friend class content::NetworkServiceInstancePrivate;
friend class content::PepperPrintSettingsManagerImpl;
friend class content::RenderProcessHostImpl;
friend class content::RenderWidgetHostViewMac;
friend class content::
ScopedAllowBlockingForViewAura;
friend class content::ShellPathProvider;
friend class content::WebContentsViewMac;
friend class cronet::CronetContext;
friend class cronet::CronetPrefsManager;
friend class crosapi::LacrosThreadTypeDelegate;
friend class crypto::ScopedAllowBlockingForNSS;
friend class drive::FakeDriveService;
friend class extensions::InstalledLoader;
friend class extensions::UnpackedInstaller;
friend class font_service::internal::MappedFontFile;
friend class ios_web_view::WebViewBrowserState;
friend class io_thread::IOSIOThread;
friend class media::FileVideoCaptureDeviceFactory;
friend class memory_instrumentation::OSMetrics;
friend class memory_pressure::UserLevelMemoryPressureSignalGenerator;
friend class metrics::AndroidMetricsServiceClient;
friend class metrics::CleanExitBeacon;
friend class module_installer::ScopedAllowModulePakLoad;
friend class mojo::CoreLibraryInitializer;
friend class net::GSSAPISharedLibrary;
friend class net::ProxyConfigServiceWin;
friend class net::
ScopedAllowBlockingForSettingGetter;
friend class printing::LocalPrinterHandlerDefault;
friend class printing::PrintBackendServiceManager;
friend class printing::PrinterQuery;
friend class remote_cocoa::
DroppedScreenShotCopierMac;
friend class remote_cocoa::SelectFileDialogBridge;
friend class remoting::
ScopedBypassIOThreadRestrictions;
friend class ui::DrmDisplayHostManager;
friend class ui::ScopedAllowBlockingForGbmSurface;
friend class ui::SelectFileDialogLinux;
friend class weblayer::BrowserContextImpl;
friend class weblayer::ContentBrowserClientImpl;
friend class weblayer::ProfileImpl;
friend class weblayer::WebLayerPathProvider;
#if defined(OHOS_MSGPORT)
friend class ::CefBrowserHostBase;
#endif
#if BUILDFLAG(IS_MAC)
friend class printing::PrintBackendServiceImpl;
#endif
#if BUILDFLAG(IS_WIN)
friend class base::win::OSInfo;
friend class content::WebContentsImpl;
#endif
friend bool ::EnsureBrowserStateDirectoriesCreated(const base::FilePath&,
const base::FilePath&,
const base::FilePath&);
friend Profile* ::GetLastProfileMac();
friend bool ::HasWaylandDisplay(
base::Environment* env);
friend bool ash::CameraAppUIShouldEnableLocalOverride(const std::string&);
friend void base::GetNSExecutablePath(base::FilePath*);
friend bool base::internal::ReadProcFile(const FilePath& file,
std::string* buffer);
friend bool chrome::PathProvider(int,
base::FilePath*);
friend void chrome::SessionEnding();
friend bool chromeos::system::IsCoreSchedulingAvailable();
friend int chromeos::system::NumberOfPhysicalCores();
friend base::File content::CreateFileForDrop(
base::FilePath* file_path);
friend bool disk_cache::CleanupDirectorySync(const base::FilePath&);
friend bool gl::init::InitializeStaticGLBindings(gl::GLImplementationParts);
ScopedAllowBlocking(const Location& from_here = Location::Current());
~ScopedAllowBlocking();
#if DCHECK_IS_ON()
const AutoReset<BooleanWithStack> resetter_;
#endif
};
class [[maybe_unused, nodiscard]] ScopedAllowBlockingForTesting {
public:
ScopedAllowBlockingForTesting() = default;
ScopedAllowBlockingForTesting(const ScopedAllowBlockingForTesting&) = delete;
ScopedAllowBlockingForTesting& operator=(
const ScopedAllowBlockingForTesting&) = delete;
~ScopedAllowBlockingForTesting() = default;
private:
#if DCHECK_IS_ON()
ScopedAllowBlocking scoped_allow_blocking_;
#endif
};
INLINE_OR_NOT_TAIL_CALLED void DisallowBaseSyncPrimitives()
EMPTY_BODY_IF_DCHECK_IS_OFF;
class BASE_EXPORT [[maybe_unused, nodiscard]] ScopedDisallowBaseSyncPrimitives {
public:
ScopedDisallowBaseSyncPrimitives() DEFAULT_IF_DCHECK_IS_OFF;
ScopedDisallowBaseSyncPrimitives(const ScopedDisallowBaseSyncPrimitives&) =
delete;
ScopedDisallowBaseSyncPrimitives& operator=(
const ScopedDisallowBaseSyncPrimitives&) = delete;
~ScopedDisallowBaseSyncPrimitives() DEFAULT_IF_DCHECK_IS_OFF;
private:
#if DCHECK_IS_ON()
const AutoReset<BooleanWithStack> resetter_;
#endif
};
class BASE_EXPORT [[maybe_unused, nodiscard]] ScopedAllowBaseSyncPrimitives {
public:
ScopedAllowBaseSyncPrimitives(const ScopedAllowBaseSyncPrimitives&) = delete;
ScopedAllowBaseSyncPrimitives& operator=(
const ScopedAllowBaseSyncPrimitives&) = delete;
private:
FRIEND_TEST_ALL_PREFIXES(ThreadRestrictionsTest,
ScopedAllowBaseSyncPrimitives);
FRIEND_TEST_ALL_PREFIXES(ThreadRestrictionsTest,
ScopedAllowBaseSyncPrimitivesResetsState);
FRIEND_TEST_ALL_PREFIXES(ThreadRestrictionsTest,
ScopedAllowBaseSyncPrimitivesWithBlockingDisallowed);
friend class ::ChromeNSSCryptoModuleDelegate;
friend class ::tracing::FuchsiaPerfettoProducerConnector;
friend class android_webview::JsSandboxIsolate;
friend class base::SimpleThread;
friend class base::internal::GetAppOutputScopedAllowBaseSyncPrimitives;
friend class blink::IdentifiabilityActiveSampler;
friend class blink::SourceStream;
friend class blink::VideoTrackRecorderImplContextProvider;
friend class blink::WorkerThread;
friend class blink::scheduler::NonMainThreadImpl;
friend class cc::CategorizedWorkerPoolImpl;
friend class cc::CategorizedWorkerPoolJob;
friend class chrome_cleaner::ResetShortcutsComponent;
friend class chrome_cleaner::SystemReportComponent;
friend class content::BrowserMainLoop;
friend class content::BrowserProcessIOThread;
friend class content::DWriteFontCollectionProxy;
friend class content::RendererBlinkPlatformImpl;
friend class content::ServiceWorkerContextClient;
friend class device::UsbContext;
friend class enterprise_connectors::LinuxKeyRotationCommand;
friend class functions::ExecScriptScopedAllowBaseSyncPrimitives;
friend class history_report::HistoryReportJniBridge;
friend class internal::TaskTracker;
friend class leveldb::port::CondVar;
friend class nearby::chrome::ScheduledExecutor;
friend class nearby::chrome::SubmittableExecutor;
friend class media::AudioOutputDevice;
friend class media::BlockingUrlProtocol;
friend class media::MojoVideoEncodeAccelerator;
friend class mojo::core::ScopedIPCSupport;
friend class net::MultiThreadedCertVerifierScopedAllowBaseSyncPrimitives;
friend class rlz_lib::FinancialPing;
friend class shell_integration_linux::
LaunchXdgUtilityScopedAllowBaseSyncPrimitives;
friend class storage::ObfuscatedFileUtil;
friend class syncer::HttpBridge;
friend class syncer::GetLocalChangesRequest;
friend class updater::SystemctlLauncherScopedAllowBaseSyncPrimitives;
friend class viz::ClientGpuMemoryBufferManager;
friend class webrtc::DesktopConfigurationMonitor;
friend class ::NativeBackendKWallet;
friend class ::ash::system::
StatisticsProviderImpl;
friend class blink::VideoFrameResourceProvider;
ScopedAllowBaseSyncPrimitives() DEFAULT_IF_DCHECK_IS_OFF;
~ScopedAllowBaseSyncPrimitives() DEFAULT_IF_DCHECK_IS_OFF;
#if DCHECK_IS_ON()
const AutoReset<BooleanWithStack> resetter_;
#endif
};
class BASE_EXPORT
[[maybe_unused,
nodiscard]] ScopedAllowBaseSyncPrimitivesOutsideBlockingScope {
public:
ScopedAllowBaseSyncPrimitivesOutsideBlockingScope(
const ScopedAllowBaseSyncPrimitivesOutsideBlockingScope&) = delete;
ScopedAllowBaseSyncPrimitivesOutsideBlockingScope& operator=(
const ScopedAllowBaseSyncPrimitivesOutsideBlockingScope&) = delete;
private:
FRIEND_TEST_ALL_PREFIXES(ThreadRestrictionsTest,
ScopedAllowBaseSyncPrimitivesOutsideBlockingScope);
FRIEND_TEST_ALL_PREFIXES(
ThreadRestrictionsTest,
ScopedAllowBaseSyncPrimitivesOutsideBlockingScopeResetsState);
friend class ::BrowserProcessImpl;
friend class ::KeyStorageLinux;
friend class ::NativeDesktopMediaList;
friend class android::JavaHandlerThread;
friend class android_webview::
AwFormDatabaseService;
friend class android_webview::CookieManager;
#if defined(OHOS_COOKIE)
friend class ::CefCookieManagerImpl;
#endif
#if defined(OHOS_INCOGNITO_MODE)
friend class ::CefIncognitoCookieManagerImpl;
#endif
friend class android_webview::VizCompositorThreadRunnerWebView;
friend class audio::OutputDevice;
friend class base::FileDescriptorWatcher;
friend class base::ScopedAllowThreadRecallForStackSamplingProfiler;
friend class base::StackSamplingProfiler;
friend class base::internal::JobTaskSource;
friend class base::sequence_manager::internal::TaskQueueImpl;
friend class blink::LegacyWebRtcVideoFrameAdapter;
friend class blink::RTCVideoDecoderAdapter;
friend class blink::RTCVideoEncoder;
friend class blink::WebRtcVideoFrameAdapter;
friend class cc::CategorizedWorkerPoolImpl;
friend class cc::CategorizedWorkerPoolJob;
friend class cc::CategorizedWorkerPool;
friend class cc::TileTaskManagerImpl;
friend class content::DesktopCaptureDevice;
friend class content::EmergencyTraceFinalisationCoordinator;
friend class content::InProcessUtilityThread;
friend class content::RenderProcessHost;
friend class content::RTCVideoDecoder;
friend class content::SandboxHostLinux;
friend class content::ScopedAllowWaitForDebugURL;
friend class content::SynchronousCompositor;
friend class content::SynchronousCompositorHost;
friend class content::SynchronousCompositorSyncCallBridge;
friend class media::AudioInputDevice;
friend class media::AudioOutputDevice;
friend class media::PaintCanvasVideoRenderer;
friend class mojo::SyncCallRestrictions;
friend class mojo::core::ipcz_driver::MojoTrap;
friend class net::NetworkConfigWatcherMacThread;
friend class ui::DrmThreadProxy;
friend class viz::HostGpuMemoryBufferManager;
friend class vr::VrShell;
friend class ::chromeos::BlockingMethodCaller;
friend class base::Thread;
friend class cc::CompletionEvent;
friend class content::
BrowserGpuChannelHostFactory;
friend class content::TextInputClientMac;
friend class dbus::Bus;
friend class discardable_memory::
ClientDiscardableSharedMemoryManager;
friend class disk_cache::BackendImpl;
friend class disk_cache::InFlightIO;
friend class midi::TaskService;
friend class net::
MultiThreadedProxyResolverScopedAllowJoinOnIO;
friend class net::NetworkChangeNotifierMac;
friend class net::internal::AddressTrackerLinux;
friend class proxy_resolver::
ScopedAllowThreadJoinForProxyResolverV8Tracing;
friend class remoting::AutoThread;
friend class remoting::protocol::
ScopedAllowSyncPrimitivesForWebRtcDataStreamAdapter;
friend class remoting::protocol::
ScopedAllowSyncPrimitivesForWebRtcTransport;
friend class remoting::protocol::
ScopedAllowThreadJoinForWebRtcTransport;
friend class service_manager::ServiceProcessLauncher;
friend class ui::WindowResizeHelperMac;
ScopedAllowBaseSyncPrimitivesOutsideBlockingScope(
const Location& from_here = Location::Current());
~ScopedAllowBaseSyncPrimitivesOutsideBlockingScope();
#if DCHECK_IS_ON()
const AutoReset<BooleanWithStack> resetter_;
#endif
};
class BASE_EXPORT
[[maybe_unused, nodiscard]] ScopedAllowBaseSyncPrimitivesForTesting {
public:
ScopedAllowBaseSyncPrimitivesForTesting() DEFAULT_IF_DCHECK_IS_OFF;
ScopedAllowBaseSyncPrimitivesForTesting(
const ScopedAllowBaseSyncPrimitivesForTesting&) = delete;
ScopedAllowBaseSyncPrimitivesForTesting& operator=(
const ScopedAllowBaseSyncPrimitivesForTesting&) = delete;
~ScopedAllowBaseSyncPrimitivesForTesting() DEFAULT_IF_DCHECK_IS_OFF;
private:
#if DCHECK_IS_ON()
const AutoReset<BooleanWithStack> resetter_;
#endif
};
class BASE_EXPORT
[[maybe_unused, nodiscard]] ScopedAllowUnresponsiveTasksForTesting {
public:
ScopedAllowUnresponsiveTasksForTesting() DEFAULT_IF_DCHECK_IS_OFF;
ScopedAllowUnresponsiveTasksForTesting(
const ScopedAllowUnresponsiveTasksForTesting&) = delete;
ScopedAllowUnresponsiveTasksForTesting& operator=(
const ScopedAllowUnresponsiveTasksForTesting&) = delete;
~ScopedAllowUnresponsiveTasksForTesting() DEFAULT_IF_DCHECK_IS_OFF;
private:
#if DCHECK_IS_ON()
const AutoReset<BooleanWithStack> base_sync_resetter_;
const AutoReset<BooleanWithStack> blocking_resetter_;
const AutoReset<BooleanWithStack> cpu_resetter_;
#endif
};
namespace internal {
INLINE_OR_NOT_TAIL_CALLED void AssertBaseSyncPrimitivesAllowed()
EMPTY_BODY_IF_DCHECK_IS_OFF;
INLINE_OR_NOT_TAIL_CALLED void ResetThreadRestrictionsForTesting()
EMPTY_BODY_IF_DCHECK_IS_OFF;
INLINE_OR_NOT_TAIL_CALLED void AssertSingletonAllowed()
EMPTY_BODY_IF_DCHECK_IS_OFF;
}
INLINE_OR_NOT_TAIL_CALLED void DisallowSingleton() EMPTY_BODY_IF_DCHECK_IS_OFF;
class BASE_EXPORT [[maybe_unused, nodiscard]] ScopedDisallowSingleton {
public:
ScopedDisallowSingleton() DEFAULT_IF_DCHECK_IS_OFF;
ScopedDisallowSingleton(const ScopedDisallowSingleton&) = delete;
ScopedDisallowSingleton& operator=(const ScopedDisallowSingleton&) = delete;
~ScopedDisallowSingleton() DEFAULT_IF_DCHECK_IS_OFF;
private:
#if DCHECK_IS_ON()
const AutoReset<BooleanWithStack> resetter_;
#endif
};
INLINE_OR_NOT_TAIL_CALLED void AssertLongCPUWorkAllowed()
EMPTY_BODY_IF_DCHECK_IS_OFF;
INLINE_OR_NOT_TAIL_CALLED void DisallowUnresponsiveTasks()
EMPTY_BODY_IF_DCHECK_IS_OFF;
class BASE_EXPORT PermanentThreadAllowance {
public:
PermanentThreadAllowance() = delete;
private:
friend class base::TestCustomDisallow;
friend class content::BrowserMainLoop;
friend class content::BrowserTestBase;
#if BUILDFLAG(IS_IOS)
friend class content::ContentMainRunnerImpl;
#endif
friend class web::WebMainLoop;
static void AllowBlocking() EMPTY_BODY_IF_DCHECK_IS_OFF;
static void AllowBaseSyncPrimitives() EMPTY_BODY_IF_DCHECK_IS_OFF;
};
#undef INLINE_OR_NOT_TAIL_CALLED
#undef EMPTY_BODY_IF_DCHECK_IS_OFF
#undef DEFAULT_IF_DCHECK_IS_OFF
}
#endif