2013-01-03 18:24:24 +01:00
|
|
|
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
2012-04-03 03:34:16 +02:00
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that can
|
|
|
|
// be found in the LICENSE file.
|
|
|
|
|
2023-01-30 18:43:54 +01:00
|
|
|
#include "base/functional/bind.h"
|
2013-01-03 18:24:24 +01:00
|
|
|
#include "base/location.h"
|
2020-09-25 03:40:47 +02:00
|
|
|
#include "base/logging.h"
|
2022-02-21 23:23:40 +01:00
|
|
|
#include "base/time/time.h"
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/include/cef_task.h"
|
|
|
|
#include "cef/libcef/common/task_runner_impl.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
bool CefCurrentlyOn(CefThreadId threadId) {
|
2013-01-03 18:24:24 +01:00
|
|
|
scoped_refptr<base::SequencedTaskRunner> task_runner =
|
|
|
|
CefTaskRunnerImpl::GetTaskRunner(threadId);
|
2020-09-25 03:40:47 +02:00
|
|
|
if (task_runner.get()) {
|
2017-09-06 23:40:58 +02:00
|
|
|
return task_runner->RunsTasksInCurrentSequence();
|
2020-09-25 03:40:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
LOG(WARNING) << "No task runner for threadId " << threadId;
|
2012-04-03 03:34:16 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefPostTask(CefThreadId threadId, CefRefPtr<CefTask> task) {
|
2013-01-03 18:24:24 +01:00
|
|
|
scoped_refptr<base::SequencedTaskRunner> task_runner =
|
|
|
|
CefTaskRunnerImpl::GetTaskRunner(threadId);
|
|
|
|
if (task_runner.get()) {
|
|
|
|
return task_runner->PostTask(FROM_HERE,
|
2021-06-04 03:34:56 +02:00
|
|
|
base::BindOnce(&CefTask::Execute, task.get()));
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
2020-09-25 03:40:47 +02:00
|
|
|
|
|
|
|
LOG(WARNING) << "No task runner for threadId " << threadId;
|
2012-04-03 03:34:16 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
bool CefPostDelayedTask(CefThreadId threadId,
|
|
|
|
CefRefPtr<CefTask> task,
|
2023-06-01 16:06:15 +02:00
|
|
|
int64_t delay_ms) {
|
2013-01-03 18:24:24 +01:00
|
|
|
scoped_refptr<base::SequencedTaskRunner> task_runner =
|
|
|
|
CefTaskRunnerImpl::GetTaskRunner(threadId);
|
|
|
|
if (task_runner.get()) {
|
2017-05-17 11:29:28 +02:00
|
|
|
return task_runner->PostDelayedTask(
|
2021-06-04 03:34:56 +02:00
|
|
|
FROM_HERE, base::BindOnce(&CefTask::Execute, task.get()),
|
2021-10-19 00:17:16 +02:00
|
|
|
base::Milliseconds(delay_ms));
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
2020-09-25 03:40:47 +02:00
|
|
|
|
|
|
|
LOG(WARNING) << "No task runner for threadId " << threadId;
|
2012-04-03 03:34:16 +02:00
|
|
|
return false;
|
|
|
|
}
|