#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "base/threading/scoped_blocking_call_internal.h"
#include <algorithm>
#include <utility>
#include "base/check_op.h"
#include "base/compiler_specific.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/no_destructor.h"
#include "base/numerics/safe_conversions.h"
#include "base/scoped_clear_last_error.h"
#include "base/task/scoped_set_task_priority_for_current_thread.h"
#include "base/task/thread_pool.h"
#include "base/task/thread_pool/environment_config.h"
#include "base/task/thread_pool/thread_pool_instance.h"
#include "base/threading/scoped_blocking_call.h"
#include "build/build_config.h"
#include "third_party/abseil-cpp/absl/base/attributes.h"
namespace base {
namespace internal {
namespace {
ABSL_CONST_INIT thread_local BlockingObserver* blocking_observer = …;
ABSL_CONST_INIT thread_local UncheckedScopedBlockingCall*
last_scoped_blocking_call = …;
BlockingObserver* GetBlockingObserver() { … }
UncheckedScopedBlockingCall* GetLastScopedBlockingCall() { … }
bool g_only_monitor_observed_threads = …;
bool IsBackgroundPriorityWorker() { … }
}
void SetBlockingObserverForCurrentThread(
BlockingObserver* new_blocking_observer) { … }
void ClearBlockingObserverForCurrentThread() { … }
IOJankMonitoringWindow::ScopedMonitoredCall::ScopedMonitoredCall()
: … { … }
IOJankMonitoringWindow::ScopedMonitoredCall::~ScopedMonitoredCall() { … }
void IOJankMonitoringWindow::ScopedMonitoredCall::Cancel() { … }
IOJankMonitoringWindow::IOJankMonitoringWindow(TimeTicks start_time)
: … { … }
void IOJankMonitoringWindow::CancelMonitoringForTesting() { … }
constexpr TimeDelta IOJankMonitoringWindow::kIOJankInterval;
constexpr TimeDelta IOJankMonitoringWindow::kMonitoringWindow;
constexpr TimeDelta IOJankMonitoringWindow::kTimeDiscrepancyTimeout;
constexpr int IOJankMonitoringWindow::kNumIntervals;
scoped_refptr<IOJankMonitoringWindow>
IOJankMonitoringWindow::MonitorNextJankWindowIfNecessary(TimeTicks recent_now) { … }
IOJankMonitoringWindow::~IOJankMonitoringWindow() NO_THREAD_SAFETY_ANALYSIS { … }
void IOJankMonitoringWindow::OnBlockingCallCompleted(TimeTicks call_start,
TimeTicks call_end) { … }
void IOJankMonitoringWindow::AddJank(int local_jank_start_index,
int num_janky_intervals) { … }
Lock& IOJankMonitoringWindow::current_jank_window_lock() { … }
scoped_refptr<IOJankMonitoringWindow>&
IOJankMonitoringWindow::current_jank_window_storage() { … }
IOJankReportingCallback& IOJankMonitoringWindow::reporting_callback_storage() { … }
UncheckedScopedBlockingCall::UncheckedScopedBlockingCall(
BlockingType blocking_type,
BlockingCallType blocking_call_type)
: … { … }
UncheckedScopedBlockingCall::~UncheckedScopedBlockingCall() { … }
}
void EnableIOJankMonitoringForProcess(
IOJankReportingCallback reporting_callback,
OnlyObservedThreadsForTest only_observed_threads) { … }
}