void FrameRequestCallbackCollection::cancelCallback(CallbackId id) { for (size_t i = 0; i < m_callbacks.size(); ++i) { if (m_callbacks[i]->m_id == id) { InspectorInstrumentation::asyncTaskCanceled(m_context, m_callbacks[i]); InspectorInstrumentation::NativeBreakpoint nativeBreakpoint( m_context, "cancelAnimationFrame", true); m_callbacks.remove(i); TRACE_EVENT_INSTANT1("devtools.timeline", "CancelAnimationFrame", TRACE_EVENT_SCOPE_THREAD, "data", InspectorAnimationFrameEvent::data(m_context, id)); return; } } for (const auto& callback : m_callbacksToInvoke) { if (callback->m_id == id) { InspectorInstrumentation::asyncTaskCanceled(m_context, callback); InspectorInstrumentation::NativeBreakpoint nativeBreakpoint( m_context, "cancelAnimationFrame", true); TRACE_EVENT_INSTANT1("devtools.timeline", "CancelAnimationFrame", TRACE_EVENT_SCOPE_THREAD, "data", InspectorAnimationFrameEvent::data(m_context, id)); callback->m_cancelled = true; // will be removed at the end of executeCallbacks() return; } } }
int DOMTimer::install(ExecutionContext* context, ScheduledAction* action, int timeout, bool singleShot) { int timeoutID = context->timers()->installNewTimeout(context, action, timeout, singleShot); TRACE_EVENT_INSTANT1("devtools.timeline", "TimerInstall", TRACE_EVENT_SCOPE_THREAD, "data", InspectorTimerInstallEvent::data(context, timeoutID, timeout, singleShot)); InspectorInstrumentation::NativeBreakpoint nativeBreakpoint(context, "setTimer", true); return timeoutID; }
void FrameRequestCallbackCollection::executeCallbacks( double highResNowMs, double highResNowMsLegacy) { // First, generate a list of callbacks to consider. Callbacks registered from // this point on are considered only for the "next" frame, not this one. DCHECK(m_callbacksToInvoke.isEmpty()); m_callbacksToInvoke.swap(m_callbacks); for (const auto& callback : m_callbacksToInvoke) { if (!callback->m_cancelled) { TRACE_EVENT1( "devtools.timeline", "FireAnimationFrame", "data", InspectorAnimationFrameEvent::data(m_context, callback->m_id)); InspectorInstrumentation::NativeBreakpoint nativeBreakpoint( m_context, "animationFrameFired", false); InspectorInstrumentation::AsyncTask asyncTask(m_context, callback); PerformanceMonitor::HandlerCall handlerCall( m_context, "requestAnimationFrame", true); if (callback->m_useLegacyTimeBase) callback->handleEvent(highResNowMsLegacy); else callback->handleEvent(highResNowMs); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "UpdateCounters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data()); } } m_callbacksToInvoke.clear(); }
void DOMTimer::removeByID(ExecutionContext* context, int timeoutID) { DOMTimer* timer = context->timers()->removeTimeoutByID(timeoutID); TRACE_EVENT_INSTANT1("devtools.timeline", "TimerRemove", TRACE_EVENT_SCOPE_THREAD, "data", InspectorTimerRemoveEvent::data(context, timeoutID)); InspectorInstrumentation::NativeBreakpoint nativeBreakpoint(context, "clearTimer", true); // Eagerly unregister as ExecutionContext observer. if (timer) timer->clearContext(); }
v8::Local<v8::Value> ScriptController::executeScriptAndReturnValue(v8::Local<v8::Context> context, const ScriptSourceCode& source, AccessControlStatus accessControlStatus, double* compilationFinishTime) { TRACE_EVENT1("devtools.timeline", "EvaluateScript", "data", InspectorEvaluateScriptEvent::data(frame(), source.url().getString(), source.startPosition())); InspectorInstrumentation::NativeBreakpoint nativeBreakpoint(frame()->document(), "scriptFirstStatement", false); v8::Local<v8::Value> result; { V8CacheOptions v8CacheOptions(V8CacheOptionsDefault); if (frame()->settings()) v8CacheOptions = frame()->settings()->v8CacheOptions(); if (source.resource() && !source.resource()->response().cacheStorageCacheName().isNull()) { switch (frame()->settings()->v8CacheStrategiesForCacheStorage()) { case V8CacheStrategiesForCacheStorage::None: v8CacheOptions = V8CacheOptionsNone; break; case V8CacheStrategiesForCacheStorage::Normal: v8CacheOptions = V8CacheOptionsCode; break; case V8CacheStrategiesForCacheStorage::Default: case V8CacheStrategiesForCacheStorage::Aggressive: v8CacheOptions = V8CacheOptionsAlways; break; } } // Isolate exceptions that occur when compiling and executing // the code. These exceptions should not interfere with // javascript code we might evaluate from C++ when returning // from here. v8::TryCatch tryCatch(isolate()); tryCatch.SetVerbose(true); v8::Local<v8::Script> script; if (!v8Call(V8ScriptRunner::compileScript(source, isolate(), accessControlStatus, v8CacheOptions), script, tryCatch)) return result; if (compilationFinishTime) { *compilationFinishTime = WTF::monotonicallyIncreasingTime(); } if (!v8Call(V8ScriptRunner::runCompiledScript(isolate(), script, frame()->document()), result, tryCatch)) return result; } TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "UpdateCounters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data()); return result; }
FrameRequestCallbackCollection::CallbackId FrameRequestCallbackCollection::registerCallback( FrameRequestCallback* callback) { FrameRequestCallbackCollection::CallbackId id = ++m_nextCallbackId; callback->m_cancelled = false; callback->m_id = id; m_callbacks.append(callback); TRACE_EVENT_INSTANT1("devtools.timeline", "RequestAnimationFrame", TRACE_EVENT_SCOPE_THREAD, "data", InspectorAnimationFrameEvent::data(m_context, id)); InspectorInstrumentation::asyncTaskScheduled( m_context, "requestAnimationFrame", callback); InspectorInstrumentation::NativeBreakpoint nativeBreakpoint( m_context, "requestAnimationFrame", true); return id; }
void DOMTimer::fired() { ExecutionContext* context = getExecutionContext(); ASSERT(context); context->timers()->setTimerNestingLevel(m_nestingLevel); ASSERT(!context->activeDOMObjectsAreSuspended()); // Only the first execution of a multi-shot timer should get an affirmative user gesture indicator. UserGestureIndicator gestureIndicator(m_userGestureToken.release()); TRACE_EVENT1("devtools.timeline", "TimerFire", "data", InspectorTimerFireEvent::data(context, m_timeoutID)); InspectorInstrumentation::NativeBreakpoint nativeBreakpoint(context, "timerFired", false); InspectorInstrumentation::AsyncTask asyncTask(context, this); // Simple case for non-one-shot timers. if (isActive()) { if (repeatInterval() && repeatInterval() < minimumInterval) { m_nestingLevel++; if (m_nestingLevel >= maxTimerNestingLevel) augmentRepeatInterval(minimumInterval - repeatInterval()); } // No access to member variables after this point, it can delete the timer. m_action->execute(context); return; } // Unregister the timer from ExecutionContext before executing the action // for one-shot timers. ScheduledAction* action = m_action.release(); context->timers()->removeTimeoutByID(m_timeoutID); action->execute(context); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "UpdateCounters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data()); // ExecutionContext might be already gone when we executed action->execute(). ExecutionContext* executionContext = getExecutionContext(); if (!executionContext) return; executionContext->timers()->setTimerNestingLevel(0); // Eagerly unregister as ExecutionContext observer. clearContext(); }