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.
|
|
|
|
|
|
|
|
#include "include/cef_task.h"
|
2013-01-03 18:24:24 +01:00
|
|
|
#include "libcef/common/task_runner_impl.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
#include "base/bind.h"
|
2013-01-03 18:24:24 +01:00
|
|
|
#include "base/location.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);
|
|
|
|
if (task_runner.get())
|
2017-09-06 23:40:58 +02:00
|
|
|
return task_runner->RunsTasksInCurrentSequence();
|
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,
|
2017-05-17 11:29:28 +02:00
|
|
|
base::Bind(&CefTask::Execute, task.get()));
|
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,
|
|
|
|
int64 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(
|
|
|
|
FROM_HERE, base::Bind(&CefTask::Execute, task.get()),
|
2013-01-03 18:24:24 +01:00
|
|
|
base::TimeDelta::FromMilliseconds(delay_ms));
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|