int DOMTimer::install(ScriptExecutionContext* context, PassOwnPtr<ScheduledAction> action, int timeout, bool singleShot) { // DOMTimer constructor links the new timer into a list of ActiveDOMObjects held by the 'context'. // The timer is deleted when context is deleted (DOMTimer::contextDestroyed) or explicitly via DOMTimer::removeById(), // or if it is a one-time timer and it has fired (DOMTimer::fired). DOMTimer* timer = new DOMTimer(context, action, timeout, singleShot); timer->suspendIfNeeded(); InspectorInstrumentation::didInstallTimer(context, timer->m_timeoutId, timeout, singleShot); return timer->m_timeoutId; }
int DOMTimerCoordinator::installNewTimeout(ExecutionContext* context, ScheduledAction* action, int timeout, bool singleShot) { // FIXME: DOMTimers depends heavily on ExecutionContext. Decouple them. ASSERT(context->timers() == this); int timeoutID = nextID(); TimeoutMap::AddResult result = m_timers.add(timeoutID, DOMTimer::create(context, action, timeout, singleShot, timeoutID)); ASSERT(result.isNewEntry); DOMTimer* timer = result.storedValue->value.get(); timer->suspendIfNeeded(); return timeoutID; }
int ExecutionContext::installNewTimeout(PassOwnPtr<ScheduledAction> action, int timeout, bool singleShot) { int timeoutID; while (true) { timeoutID = circularSequentialID(); if (!m_timeouts.contains(timeoutID)) break; } TimeoutMap::AddResult result = m_timeouts.add(timeoutID, DOMTimer::create(this, action, timeout, singleShot, timeoutID)); ASSERT(result.isNewEntry); DOMTimer* timer = result.storedValue->value.get(); timer->suspendIfNeeded(); return timer->timeoutID(); }
int DOMTimer::install(ScriptExecutionContext* context, PassOwnPtr<ScheduledAction> action, int timeout, bool singleShot) { // DOMTimer constructor links the new timer into a list of ActiveDOMObjects held by the 'context'. // The timer is deleted when context is deleted (DOMTimer::contextDestroyed) or explicitly via DOMTimer::removeById(), // or if it is a one-time timer and it has fired (DOMTimer::fired). DOMTimer* timer = new DOMTimer(context, action, timeout, singleShot); #if PLATFORM(IOS) if (context->isDocument()) { Document& document = toDocument(*context); bool didDeferTimeout = document.frame() && document.frame()->timersPaused(); if (!didDeferTimeout && timeout <= 100 && singleShot) { WKSetObservedContentChange(WKContentIndeterminateChange); WebThreadAddObservedContentModifier(timer); // Will only take affect if not already visibility change. } } #endif timer->suspendIfNeeded(); InspectorInstrumentation::didInstallTimer(context, timer->m_timeoutId, timeout, singleShot); return timer->m_timeoutId; }
int DOMTimer::install(ScriptExecutionContext* context, std::unique_ptr<ScheduledAction> action, int timeout, bool singleShot) { // DOMTimer constructor passes ownership of the initial ref on the object to the constructor. // This reference will be released automatically when a one-shot timer fires, when the context // is destroyed, or if explicitly cancelled by removeById. DOMTimer* timer = new DOMTimer(context, WTF::move(action), timeout, singleShot); #if PLATFORM(IOS) if (context->isDocument()) { Document& document = toDocument(*context); bool didDeferTimeout = document.frame() && document.frame()->timersPaused(); if (!didDeferTimeout && timeout <= 100 && singleShot) { WKSetObservedContentChange(WKContentIndeterminateChange); WebThreadAddObservedContentModifier(timer); // Will only take affect if not already visibility change. } } #endif timer->suspendIfNeeded(); InspectorInstrumentation::didInstallTimer(context, timer->m_timeoutId, timeout, singleShot); return timer->m_timeoutId; }