mirror of
https://github.com/aphrody-labs/cef.git
synced 2026-10-14 05:09:23 +00:00
Remove thread-check early logging (fixes #4043)
This commit is contained in:
1 parent
463fb90cea
commit
cf5ee9bf86
5 files changed
+45
-4
No files matched your search
@@ -851,6 +851,7 @@ source_set("libcef_static") {
|
||||
"libcef/common/task_runner_impl.h",
|
||||
"libcef/common/task_runner_manager.cc",
|
||||
"libcef/common/task_runner_manager.h",
|
||||
"libcef/common/task_util.h",
|
||||
"libcef/common/thread_impl.cc",
|
||||
"libcef/common/thread_impl.h",
|
||||
"libcef/common/time_impl.cc",
|
||||
|
||||
@@ -6,13 +6,14 @@
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/logging.h"
|
||||
#include "cef/include/cef_file_util.h"
|
||||
#include "cef/include/cef_task.h"
|
||||
#include "cef/libcef/common/task_util.h"
|
||||
#include "third_party/zlib/google/zip.h"
|
||||
|
||||
namespace {
|
||||
|
||||
bool AllowFileIO() {
|
||||
if (CefCurrentlyOn(TID_UI) || CefCurrentlyOn(TID_IO)) {
|
||||
// Use internal variant that doesn't log before CefInitialize.
|
||||
if (cef::CurrentlyOnThread(TID_UI) || cef::CurrentlyOnThread(TID_IO)) {
|
||||
DCHECK(false) << "file IO is not allowed on the current thread";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "base/time/time.h"
|
||||
#include "cef/include/cef_task.h"
|
||||
#include "cef/libcef/common/task_runner_impl.h"
|
||||
#include "cef/libcef/common/task_util.h"
|
||||
|
||||
bool CefCurrentlyOn(CefThreadId threadId) {
|
||||
scoped_refptr<base::SequencedTaskRunner> task_runner =
|
||||
@@ -46,3 +47,19 @@ bool CefPostDelayedTask(CefThreadId threadId,
|
||||
LOG(WARNING) << "No task runner for threadId " << threadId;
|
||||
return false;
|
||||
}
|
||||
|
||||
namespace cef {
|
||||
|
||||
bool CurrentlyOnThread(CefThreadId thread_id) {
|
||||
scoped_refptr<base::SequencedTaskRunner> task_runner =
|
||||
CefTaskRunnerImpl::GetTaskRunner(thread_id);
|
||||
if (task_runner.get()) {
|
||||
return task_runner->RunsTasksInCurrentSequence();
|
||||
}
|
||||
|
||||
// Return false silently when task runners are not initialized (before
|
||||
// CefInitialize). This avoids logging that cannot be configured.
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace cef
|
||||
@@ -0,0 +1,21 @@
|
||||
// Copyright 2025 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that can
|
||||
// be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_COMMON_TASK_UTIL_H_
|
||||
#define CEF_LIBCEF_COMMON_TASK_UTIL_H_
|
||||
#pragma once
|
||||
|
||||
#include "cef/include/cef_task.h"
|
||||
|
||||
namespace cef {
|
||||
|
||||
// Internal variant of CefCurrentlyOn that does not log when called before
|
||||
// CefInitialize (when task runners are not yet initialized). Should only be
|
||||
// used by libcef internal code that may be called before initialization.
|
||||
// Returns false when task runners are not initialized.
|
||||
bool CurrentlyOnThread(CefThreadId thread_id);
|
||||
|
||||
} // namespace cef
|
||||
|
||||
#endif // CEF_LIBCEF_COMMON_TASK_UTIL_H_
|
||||
@@ -6,12 +6,13 @@
|
||||
|
||||
#include "base/notreached.h"
|
||||
#include "base/time/time.h"
|
||||
#include "cef/include/cef_task.h"
|
||||
#include "cef/libcef/common/task_util.h"
|
||||
|
||||
namespace {
|
||||
|
||||
bool AllowWait() {
|
||||
if (CefCurrentlyOn(TID_UI) || CefCurrentlyOn(TID_IO)) {
|
||||
// Use internal variant that doesn't log before CefInitialize.
|
||||
if (cef::CurrentlyOnThread(TID_UI) || cef::CurrentlyOnThread(TID_IO)) {
|
||||
DCHECK(false) << "waiting is not allowed on the current thread";
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user