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