OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "config.h" |
| 6 #include "platform/scheduler/CancellableTaskFactory.h" |
| 7 |
| 8 #include "platform/TraceLocation.h" |
| 9 #include "public/platform/Platform.h" |
| 10 #include "wtf/InstanceCounter.h" |
| 11 |
| 12 namespace blink { |
| 13 |
| 14 void CancellableTaskFactory::cancel() |
| 15 { |
| 16 m_weakPtrFactory.revokeAll(); |
| 17 } |
| 18 |
| 19 WebThread::Task* CancellableTaskFactory::task() |
| 20 { |
| 21 cancel(); |
| 22 return new CancellableTask(m_weakPtrFactory.createWeakPtr()); |
| 23 } |
| 24 |
| 25 void CancellableTaskFactory::CancellableTask::run() |
| 26 { |
| 27 if (m_weakPtr.get()) { |
| 28 Closure* closure = m_weakPtr->m_closure.get(); |
| 29 m_weakPtr->m_weakPtrFactory.revokeAll(); |
| 30 (*closure)(); |
| 31 } |
| 32 } |
| 33 |
| 34 } // namespace blink |
OLD | NEW |