Chromium Code Reviews| Index: chromecast/base/task_runner_impl.cc |
| diff --git a/chromecast/base/task_runner_impl.cc b/chromecast/base/task_runner_impl.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b926215e3f48036d7fe2a19f897b7545ea160c5e |
| --- /dev/null |
| +++ b/chromecast/base/task_runner_impl.cc |
| @@ -0,0 +1,35 @@ |
| +// Copyright 2015 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 "chromecast/base/task_runner_impl.h" |
| + |
| +#include "base/bind.h" |
| +#include "base/location.h" |
| +#include "base/single_thread_task_runner.h" |
| +#include "base/thread_task_runner_handle.h" |
| + |
| +namespace chromecast { |
| + |
| +TaskRunnerImpl::TaskRunnerImpl() |
| + : runner_(base::ThreadTaskRunnerHandle::Get()) { |
| + DCHECK(runner_.get()); |
| +} |
| + |
| +TaskRunnerImpl::~TaskRunnerImpl() {} |
| + |
| +bool TaskRunnerImpl::PostTask(Task* task, uint64_t delay_milliseconds) { |
| + // TODO(halliwell): FROM_HERE is misleading, we should consider a macro for |
| + // vendor backends to send the callsite info. |
|
byungchul
2015/07/30 00:32:30
move this TODO inside else clause.
halliwell
2015/07/30 03:08:10
Done.
|
| + if (delay_milliseconds == 0 && runner_->BelongsToCurrentThread()) { |
|
byungchul
2015/07/30 00:32:30
Would it make sense to run task if milliseconds <
halliwell
2015/07/30 03:08:10
ms is uint, so always >= 0. I think this change i
byungchul
2015/07/30 05:22:53
My point was, vendor cannot do PostTask(0) on same
halliwell
2015/07/30 05:40:19
Yes, agreed ... but I think that's ok. Current an
|
| + task->Run(); |
| + delete task; |
| + return true; |
| + } else { |
|
byungchul
2015/07/30 00:32:30
not else after return.
halliwell
2015/07/30 03:08:10
Done.
|
| + return runner_->PostDelayedTask( |
| + FROM_HERE, base::Bind(&Task::Run, base::Owned(task)), |
| + base::TimeDelta::FromMilliseconds(delay_milliseconds)); |
| + } |
| +} |
| + |
| +} // namespace chromecast |