chromium/base/threading/thread_restrictions.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/threading/thread_restrictions.h"

#include "base/threading/hang_watcher.h"
#include "base/trace_event/base_tracing.h"
#include "build/build_config.h"

#if DCHECK_IS_ON()
#include "base/check_op.h"
#include "third_party/abseil-cpp/absl/base/attributes.h"

// NaCL doesn't support stack sampling and Android is slow at stack sampling and
// this causes timeouts (crbug.com/959139).
#if BUILDFLAG(IS_NACL) || BUILDFLAG(IS_ANDROID)
constexpr bool kCaptureStackTraces = false;
#else
// Always disabled when !EXPENSIVE_DCHECKS_ARE_ON() because user-facing builds
// typically drop log strings anyways.
constexpr bool kCaptureStackTraces =;
#endif

namespace base {

BooleanWithStack::BooleanWithStack(bool value) :{}

std::ostream& operator<<(std::ostream& out, const BooleanWithStack& bws) {}

namespace {

ABSL_CONST_INIT thread_local BooleanWithStack tls_blocking_disallowed;
ABSL_CONST_INIT thread_local BooleanWithStack tls_singleton_disallowed;
ABSL_CONST_INIT thread_local BooleanWithStack
    tls_base_sync_primitives_disallowed;
ABSL_CONST_INIT thread_local BooleanWithStack tls_cpu_intensive_work_disallowed;

}  // namespace

namespace internal {

void AssertBlockingAllowed() {}

void AssertBlockingDisallowedForTesting() {}

}  // namespace internal

void DisallowBlocking() {}

ScopedDisallowBlocking::ScopedDisallowBlocking()
    :{}

ScopedDisallowBlocking::~ScopedDisallowBlocking() {}

void DisallowBaseSyncPrimitives() {}

ScopedDisallowBaseSyncPrimitives::ScopedDisallowBaseSyncPrimitives()
    :{}

ScopedDisallowBaseSyncPrimitives::~ScopedDisallowBaseSyncPrimitives() {}

ScopedAllowBaseSyncPrimitives::ScopedAllowBaseSyncPrimitives()
    :{}

ScopedAllowBaseSyncPrimitives::~ScopedAllowBaseSyncPrimitives() {}

ScopedAllowBaseSyncPrimitivesForTesting::
    ScopedAllowBaseSyncPrimitivesForTesting()
    :{}

ScopedAllowBaseSyncPrimitivesForTesting::
    ~ScopedAllowBaseSyncPrimitivesForTesting() {}

ScopedAllowUnresponsiveTasksForTesting::ScopedAllowUnresponsiveTasksForTesting()
    :{}

ScopedAllowUnresponsiveTasksForTesting::
    ~ScopedAllowUnresponsiveTasksForTesting() {}

namespace internal {

void AssertBaseSyncPrimitivesAllowed() {}

void ResetThreadRestrictionsForTesting() {}

void AssertSingletonAllowed() {}

}  // namespace internal

void DisallowSingleton() {}

ScopedDisallowSingleton::ScopedDisallowSingleton()
    :{}

ScopedDisallowSingleton::~ScopedDisallowSingleton() {}

void AssertLongCPUWorkAllowed() {}

void DisallowUnresponsiveTasks() {}

// static
void PermanentThreadAllowance::AllowBlocking() {}

// static
void PermanentThreadAllowance::AllowBaseSyncPrimitives() {}

}  // namespace base

#endif  // DCHECK_IS_ON()

namespace base {

ScopedAllowBlocking::ScopedAllowBlocking(const Location& from_here)
#if DCHECK_IS_ON()
    :{}

ScopedAllowBlocking::~ScopedAllowBlocking() {}

ScopedAllowBaseSyncPrimitivesOutsideBlockingScope::
    ScopedAllowBaseSyncPrimitivesOutsideBlockingScope(const Location& from_here)
#if DCHECK_IS_ON()
    :{}

ScopedAllowBaseSyncPrimitivesOutsideBlockingScope::
    ~ScopedAllowBaseSyncPrimitivesOutsideBlockingScope() {}

}  // namespace base