| 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 "public/platform/WebTaskRunner.h" | 5 #include "public/platform/WebTaskRunner.h" |
| 6 | 6 |
| 7 #include "base/single_thread_task_runner.h" |
| 8 |
| 7 namespace blink { | 9 namespace blink { |
| 8 | 10 |
| 9 // This class holds a reference to a TaskHandle to keep it alive while a task is | 11 // This class holds a reference to a TaskHandle to keep it alive while a task is |
| 10 // pending in a task queue, and clears the reference on the task disposal, so | 12 // pending in a task queue, and clears the reference on the task disposal, so |
| 11 // that it doesn't leave a circular reference like below: | 13 // that it doesn't leave a circular reference like below: |
| 12 // struct Foo : GarbageCollected<Foo> { | 14 // struct Foo : GarbageCollected<Foo> { |
| 13 // void bar() {} | 15 // void bar() {} |
| 14 // RefPtr<TaskHandle> m_handle; | 16 // RefPtr<TaskHandle> m_handle; |
| 15 // }; | 17 // }; |
| 16 // | 18 // |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 DCHECK(runsTasksOnCurrentThread()); | 113 DCHECK(runsTasksOnCurrentThread()); |
| 112 RefPtr<TaskHandle> handle = adoptRef(new TaskHandle(std::move(task))); | 114 RefPtr<TaskHandle> handle = adoptRef(new TaskHandle(std::move(task))); |
| 113 postDelayedTask(location, | 115 postDelayedTask(location, |
| 114 WTF::bind(&TaskHandle::run, handle->asWeakPtr(), | 116 WTF::bind(&TaskHandle::run, handle->asWeakPtr(), |
| 115 TaskHandle::CancelOnTaskDestruction(handle)), | 117 TaskHandle::CancelOnTaskDestruction(handle)), |
| 116 delayMs); | 118 delayMs); |
| 117 return handle; | 119 return handle; |
| 118 } | 120 } |
| 119 | 121 |
| 120 } // namespace blink | 122 } // namespace blink |
| OLD | NEW |