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 "platform/scheduler/CancellableTaskFactory.h" | |
6 | |
7 #include "public/platform/Platform.h" | |
8 | |
9 namespace blink { | |
10 | |
11 void CancellableTaskFactory::cancel() { | |
12 m_weakPtrFactory.revokeAll(); | |
13 } | |
14 | |
15 WebTaskRunner::Task* CancellableTaskFactory::cancelAndCreate() { | |
16 cancel(); | |
17 return new CancellableTask(m_weakPtrFactory.createWeakPtr()); | |
18 } | |
19 | |
20 void CancellableTaskFactory::CancellableTask::run() { | |
21 if (CancellableTaskFactory* taskFactory = m_weakPtr.get()) { | |
22 WTF::Closure* closure = taskFactory->m_closure.get(); | |
23 taskFactory->m_weakPtrFactory.revokeAll(); | |
24 (*closure)(); | |
25 } | |
26 } | |
27 | |
28 } // namespace blink | |
OLD | NEW |