Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(450)

Unified Diff: Source/platform/Timer.h

Issue 1210103002: Revert of "Lazily constructed bespoke cancellable timer task." (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/platform/Timer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/Timer.h
diff --git a/Source/platform/Timer.h b/Source/platform/Timer.h
index b8032009aaf97e4742402e0f7d2766e929ea7b56..60fec18a6b0356eff0326002f44bd70d8b777ba1 100644
--- a/Source/platform/Timer.h
+++ b/Source/platform/Timer.h
@@ -28,6 +28,7 @@
#include "platform/PlatformExport.h"
#include "platform/heap/Handle.h"
+#include "platform/scheduler/CancellableTaskFactory.h"
#include "public/platform/WebTraceLocation.h"
#include "wtf/AddressSanitizer.h"
#include "wtf/Noncopyable.h"
@@ -71,6 +72,11 @@ public:
void didChangeAlignmentInterval(double now);
+#if defined(ADDRESS_SANITIZER)
+protected:
+ CancellableTaskFactory& cancellableTaskFactory() { return m_cancellableTaskFactory; }
+#endif
+
private:
virtual void fired() = 0;
@@ -81,38 +87,13 @@ private:
void setNextFireTime(double now, double delay);
- void runInternal();
-
- class CancellableTimerTask final : public WebThread::Task {
- WTF_MAKE_NONCOPYABLE(CancellableTimerTask);
- public:
- explicit CancellableTimerTask(TimerBase* timer) : m_timer(timer) { }
-
- ~CancellableTimerTask() override { }
-
- NO_LAZY_SWEEP_SANITIZE_ADDRESS
- void run() override
- {
- if (m_timer) {
- m_timer->m_cancellableTimerTask = nullptr;
- m_timer->runInternal();
- }
- }
-
- void cancel()
- {
- m_timer = nullptr;
- }
-
- private:
- TimerBase* m_timer; // NOT OWNED
- };
+ void run();
double m_nextFireTime; // 0 if inactive
double m_unalignedNextFireTime; // m_nextFireTime not considering alignment interval
double m_repeatInterval; // 0 if not repeating
WebTraceLocation m_location;
- CancellableTimerTask* m_cancellableTimerTask; // NOT OWNED
+ CancellableTaskFactory m_cancellableTaskFactory;
WebScheduler* m_webScheduler; // Not owned.
#if ENABLE(ASSERT)
@@ -147,6 +128,10 @@ public:
Timer(TimerFiredClass* o, TimerFiredFunction f)
: m_object(o), m_function(f)
{
+#if ENABLE(LAZY_SWEEPING) && defined(ADDRESS_SANITIZER)
+ if (IsGarbageCollectedType<TimerFiredClass>::value)
+ cancellableTaskFactory().setUnpoisonBeforeUpdate();
+#endif
}
protected:
@@ -177,7 +162,7 @@ NO_LAZY_SWEEP_SANITIZE_ADDRESS
inline bool TimerBase::isActive() const
{
ASSERT(m_thread == currentThread());
- return m_cancellableTimerTask;
+ return m_cancellableTaskFactory.isPending();
}
} // namespace blink
« no previous file with comments | « no previous file | Source/platform/Timer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698