mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
41 lines
1000 B
C++
41 lines
1000 B
C++
// Copyright 2016 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "flutter/glue/task_runner_adaptor.h"
|
|
|
|
#include <utility>
|
|
|
|
#include "base/bind.h"
|
|
#include "base/location.h"
|
|
#include "base/task_runner.h"
|
|
|
|
namespace glue {
|
|
namespace {
|
|
|
|
void RunClosure(ftl::Closure task) {
|
|
task();
|
|
}
|
|
|
|
} // namespace
|
|
|
|
TaskRunnerAdaptor::TaskRunnerAdaptor(scoped_refptr<base::TaskRunner> runner)
|
|
: runner_(std::move(runner)) {
|
|
FTL_DCHECK(runner_);
|
|
}
|
|
|
|
TaskRunnerAdaptor::~TaskRunnerAdaptor() {}
|
|
|
|
void TaskRunnerAdaptor::PostTask(ftl::Closure task) {
|
|
runner_->PostTask(FROM_HERE, base::Bind(RunClosure, task));
|
|
}
|
|
|
|
void TaskRunnerAdaptor::PostDelayedTask(ftl::Closure task,
|
|
ftl::TimeDelta delay) {
|
|
runner_->PostDelayedTask(
|
|
FROM_HERE, base::Bind(RunClosure, task),
|
|
base::TimeDelta::FromMicroseconds(delay.ToMicroseconds()));
|
|
}
|
|
|
|
} // namespace glue
|