| Index: Source/platform/scheduler/CancellableTaskFactory.cpp
|
| diff --git a/Source/platform/scheduler/CancellableTaskFactory.cpp b/Source/platform/scheduler/CancellableTaskFactory.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..4fd4ae29ae61c636e6e7c51929b3220dc2944c91
|
| --- /dev/null
|
| +++ b/Source/platform/scheduler/CancellableTaskFactory.cpp
|
| @@ -0,0 +1,34 @@
|
| +// 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 "config.h"
|
| +#include "platform/scheduler/CancellableTaskFactory.h"
|
| +
|
| +#include "platform/TraceLocation.h"
|
| +#include "public/platform/Platform.h"
|
| +#include "wtf/InstanceCounter.h"
|
| +
|
| +namespace blink {
|
| +
|
| +void CancellableTaskFactory::cancel()
|
| +{
|
| + m_weakPtrFactory.revokeAll();
|
| +}
|
| +
|
| +WebThread::Task* CancellableTaskFactory::task()
|
| +{
|
| + cancel();
|
| + return new CancellableTask(m_weakPtrFactory.createWeakPtr());
|
| +}
|
| +
|
| +void CancellableTaskFactory::CancellableTask::run()
|
| +{
|
| + if (m_weakPtr.get()) {
|
| + Closure* closure = m_weakPtr->m_closure.get();
|
| + m_weakPtr->m_weakPtrFactory.revokeAll();
|
| + (*closure)();
|
| + }
|
| +}
|
| +
|
| +} // namespace blink
|
|
|