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 #ifndef CancellableTaskFactory_h | 5 #ifndef CancellableTaskFactory_h |
6 #define CancellableTaskFactory_h | 6 #define CancellableTaskFactory_h |
7 | 7 |
8 #include "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
9 #include "public/platform/WebScheduler.h" | 9 #include "public/platform/WebScheduler.h" |
10 #include "wtf/AddressSanitizer.h" | 10 #include "wtf/AddressSanitizer.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 bool isPending() const | 34 bool isPending() const |
35 { | 35 { |
36 return m_weakPtrFactory.hasWeakPtrs(); | 36 return m_weakPtrFactory.hasWeakPtrs(); |
37 } | 37 } |
38 | 38 |
39 void cancel(); | 39 void cancel(); |
40 | 40 |
41 // Returns a task that can be disabled by calling cancel(). The user takes | 41 // Returns a task that can be disabled by calling cancel(). The user takes |
42 // ownership of the task. Creating a new task cancels any previous ones. | 42 // ownership of the task. Creating a new task cancels any previous ones. |
43 WebThread::Task* cancelAndCreate(); | 43 WebTaskRunner::Task* cancelAndCreate(); |
44 | 44 |
45 #if defined(ADDRESS_SANITIZER) | 45 #if defined(ADDRESS_SANITIZER) |
46 // The CancellableTaskFactory part object might be within a poisoned heap | 46 // The CancellableTaskFactory part object might be within a poisoned heap |
47 // object, hence CancellableTask::run() will access poisoned memory | 47 // object, hence CancellableTask::run() will access poisoned memory |
48 // when reaching into the factory object to update its state. | 48 // when reaching into the factory object to update its state. |
49 // We will allow such access iff the task factory is marked as requiring | 49 // We will allow such access iff the task factory is marked as requiring |
50 // unpoisoning first. | 50 // unpoisoning first. |
51 void setUnpoisonBeforeUpdate() { m_unpoisonBeforeUpdate = true; } | 51 void setUnpoisonBeforeUpdate() { m_unpoisonBeforeUpdate = true; } |
52 #endif | 52 #endif |
53 | 53 |
54 private: | 54 private: |
55 class CancellableTask : public WebThread::Task { | 55 class CancellableTask : public WebTaskRunner::Task { |
56 WTF_MAKE_NONCOPYABLE(CancellableTask); | 56 WTF_MAKE_NONCOPYABLE(CancellableTask); |
57 | 57 |
58 public: | 58 public: |
59 explicit CancellableTask(WeakPtr<CancellableTaskFactory> weakPtr) | 59 explicit CancellableTask(WeakPtr<CancellableTaskFactory> weakPtr) |
60 : m_weakPtr(weakPtr) {} | 60 : m_weakPtr(weakPtr) {} |
61 | 61 |
62 ~CancellableTask() override {} | 62 ~CancellableTask() override {} |
63 | 63 |
64 void run() override; | 64 void run() override; |
65 | 65 |
66 private: | 66 private: |
67 WeakPtr<CancellableTaskFactory> m_weakPtr; | 67 WeakPtr<CancellableTaskFactory> m_weakPtr; |
68 }; | 68 }; |
69 | 69 |
70 OwnPtr<Closure> m_closure; | 70 OwnPtr<Closure> m_closure; |
71 #if defined(ADDRESS_SANITIZER) | 71 #if defined(ADDRESS_SANITIZER) |
72 bool m_unpoisonBeforeUpdate; | 72 bool m_unpoisonBeforeUpdate; |
73 #endif | 73 #endif |
74 WeakPtrFactory<CancellableTaskFactory> m_weakPtrFactory; | 74 WeakPtrFactory<CancellableTaskFactory> m_weakPtrFactory; |
75 }; | 75 }; |
76 | 76 |
77 } // namespace blink | 77 } // namespace blink |
78 | 78 |
79 #endif // CancellableTaskFactory_h | 79 #endif // CancellableTaskFactory_h |
OLD | NEW |