ScriptValue InjectedScriptBase::callFunctionWithEvalEnabled(ScriptFunctionCall& function, bool& hadException) const { ASSERT(!isEmpty()); ExecutionContext* executionContext = m_injectedScriptObject.scriptState()->executionContext(); ScriptState::Scope scope(m_injectedScriptObject.scriptState()); v8::Local<v8::Function> functionObj = function.function(); DevToolsFunctionInfo info(functionObj); TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "FunctionCall", "data", InspectorFunctionCallEvent::data(executionContext, info.scriptId(), "InjectedScriptSource.js", info.lineNumber())); InspectorInstrumentationCookie cookie = InspectorInstrumentation::willCallFunction(executionContext, info); ScriptState* scriptState = m_injectedScriptObject.scriptState(); bool evalIsDisabled = false; if (scriptState) { evalIsDisabled = !scriptState->evalEnabled(); // Temporarily enable allow evals for inspector. if (evalIsDisabled) scriptState->setEvalEnabled(true); } ScriptValue resultValue = function.call(hadException); if (evalIsDisabled) scriptState->setEvalEnabled(false); InspectorInstrumentation::didCallFunction(cookie); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "UpdateCounters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data()); return resultValue; }
void V8GCController::gcEpilogue(v8::GCType type, v8::GCCallbackFlags flags) { // FIXME: It would be nice if the GC callbacks passed the Isolate directly.... v8::Isolate* isolate = v8::Isolate::GetCurrent(); if (type == v8::kGCTypeScavenge) minorGCEpilogue(isolate); else if (type == v8::kGCTypeMarkSweepCompact) majorGCEpilogue(isolate); // Forces a Blink heap garbage collection when a garbage collection // was forced from V8. This is used for tests that force GCs from // JavaScript to verify that objects die when expected. if (flags & v8::kGCCallbackFlagForced) { // This single GC is not enough for two reasons: // (1) The GC is not precise because the GC scans on-stack pointers conservatively. // (2) One GC is not enough to break a chain of persistent handles. It's possible that // some heap allocated objects own objects that contain persistent handles // pointing to other heap allocated objects. To break the chain, we need multiple GCs. // // Regarding (1), we force a precise GC at the end of the current event loop. So if you want // to collect all garbage, you need to wait until the next event loop. // Regarding (2), it would be OK in practice to trigger only one GC per gcEpilogue, because // GCController.collectAll() forces 7 V8's GC. Heap::collectGarbage(ThreadState::HeapPointersOnStack, ThreadState::ForcedGC); // Forces a precise GC at the end of the current event loop. Heap::setForcePreciseGCForTesting(); } TRACE_EVENT_END1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "GCEvent", "usedHeapSizeAfter", usedHeapSize(isolate)); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "UpdateCounters", "data", InspectorUpdateCountersEvent::data()); }
void ScriptedAnimationController::executeCallbacks(double monotonicTimeNow) { // dispatchEvents() runs script which can cause the document to be destroyed. if (!m_document) return; double highResNowMs = 1000.0 * m_document->loader()->timing()->monotonicTimeToZeroBasedDocumentTime(monotonicTimeNow); double legacyHighResNowMs = 1000.0 * m_document->loader()->timing()->monotonicTimeToPseudoWallTime(monotonicTimeNow); // First, generate a list of callbacks to consider. Callbacks registered from this point // on are considered only for the "next" frame, not this one. ASSERT(m_callbacksToInvoke.isEmpty()); m_callbacksToInvoke.swap(m_callbacks); for (size_t i = 0; i < m_callbacksToInvoke.size(); ++i) { RequestAnimationFrameCallback* callback = m_callbacksToInvoke[i].get(); if (!callback->m_cancelled) { TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "FireAnimationFrame", "data", InspectorAnimationFrameEvent::data(m_document, callback->m_id)); // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeline migrates to tracing. InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireAnimationFrame(m_document, callback->m_id); if (callback->m_useLegacyTimeBase) callback->handleEvent(legacyHighResNowMs); else callback->handleEvent(highResNowMs); InspectorInstrumentation::didFireAnimationFrame(cookie); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "UpdateCounters", "data", InspectorUpdateCountersEvent::data()); } } m_callbacksToInvoke.clear(); }
ScriptValue InjectedScriptBase::callFunctionWithEvalEnabled(ScriptFunctionCall& function, bool& hadException) const { ASSERT(!isEmpty()); ExecutionContext* executionContext = m_injectedScriptObject.scriptState()->executionContext(); TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "FunctionCall", "data", InspectorFunctionCallEvent::data(executionContext, 0, name(), 1)); // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeline migrates to tracing. InspectorInstrumentationCookie cookie = InspectorInstrumentation::willCallFunction(executionContext, 0, name(), 1); ScriptState* scriptState = m_injectedScriptObject.scriptState(); bool evalIsDisabled = false; if (scriptState) { evalIsDisabled = !scriptState->evalEnabled(); // Temporarily enable allow evals for inspector. if (evalIsDisabled) scriptState->setEvalEnabled(true); } ScriptValue resultValue = function.call(hadException); if (evalIsDisabled) scriptState->setEvalEnabled(false); InspectorInstrumentation::didCallFunction(cookie); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "UpdateCounters", "data", InspectorUpdateCountersEvent::data()); return resultValue; }
v8::Local<v8::Value> ScriptController::executeScriptAndReturnValue(v8::Handle<v8::Context> context, const ScriptSourceCode& source, AccessControlStatus corsStatus) { TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "EvaluateScript", "data", InspectorEvaluateScriptEvent::data(m_frame, source.url().string(), source.startLine())); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), "CallStack", "stack", InspectorCallStackEvent::currentCallStack()); // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeline migrates to tracing. InspectorInstrumentationCookie cookie = InspectorInstrumentation::willEvaluateScript(m_frame, source.url().string(), source.startLine()); v8::Local<v8::Value> result; { // 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; tryCatch.SetVerbose(true); v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(source, m_isolate, corsStatus); // Keep LocalFrame (and therefore ScriptController) alive. RefPtr<LocalFrame> protect(m_frame); result = V8ScriptRunner::runCompiledScript(script, m_frame->document(), m_isolate); ASSERT(!tryCatch.HasCaught() || result.IsEmpty()); } InspectorInstrumentation::didEvaluateScript(cookie); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "UpdateCounters", "data", InspectorUpdateCountersEvent::data()); return result; }
v8::Local<v8::Value> ScriptController::executeScriptAndReturnValue(v8::Handle<v8::Context> context, const ScriptSourceCode& source, AccessControlStatus corsStatus, double* compilationFinishTime) { TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "EvaluateScript", "data", InspectorEvaluateScriptEvent::data(frame(), source.url().string(), source.startLine())); // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeline migrates to tracing. InspectorInstrumentationCookie cookie = InspectorInstrumentation::willEvaluateScript(frame(), source.url().string(), source.startLine()); v8::Local<v8::Value> result; { V8CacheOptions v8CacheOptions(V8CacheOptionsDefault); if (frame()->settings()) v8CacheOptions = frame()->settings()->v8CacheOptions(); // 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; tryCatch.SetVerbose(true); v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(source, isolate(), corsStatus, v8CacheOptions); if (compilationFinishTime) { *compilationFinishTime = WTF::monotonicallyIncreasingTime(); } // Keep LocalFrame (and therefore ScriptController) alive. RefPtrWillBeRawPtr<LocalFrame> protect(frame()); result = V8ScriptRunner::runCompiledScript(isolate(), script, frame()->document()); ASSERT(!tryCatch.HasCaught() || result.IsEmpty()); } InspectorInstrumentation::didEvaluateScript(cookie); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "UpdateCounters", "data", InspectorUpdateCountersEvent::data()); return result; }
bool EventDispatcher::dispatch() { TRACE_EVENT0("webkit", "EventDispatcher::dispatch"); #ifndef NDEBUG ASSERT(!m_eventDispatched); m_eventDispatched = true; #endif ChildNodesLazySnapshot::takeChildNodesLazySnapshot(); m_event->setTarget(EventPath::eventTargetRespectingTargetRules(m_node.get())); ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden()); ASSERT(m_event->target()); WindowEventContext windowEventContext(m_event.get(), m_node.get(), topNodeEventContext()); TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "EventDispatch", "type", m_event->type().ascii()); // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeline migrates to tracing. InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDispatchEvent(&m_node->document(), *m_event, windowEventContext.window(), m_node.get(), m_event->eventPath()); void* preDispatchEventHandlerResult; if (dispatchEventPreProcess(preDispatchEventHandlerResult) == ContinueDispatching) if (dispatchEventAtCapturing(windowEventContext) == ContinueDispatching) if (dispatchEventAtTarget() == ContinueDispatching) dispatchEventAtBubbling(windowEventContext); dispatchEventPostProcess(preDispatchEventHandlerResult); // Ensure that after event dispatch, the event's target object is the // outermost shadow DOM boundary. m_event->setTarget(windowEventContext.target()); m_event->setCurrentTarget(0); InspectorInstrumentation::didDispatchEvent(cookie); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "UpdateCounters", "data", InspectorUpdateCountersEvent::data()); return !m_event->defaultPrevented(); }
DispatchEventResult EventDispatcher::dispatch() { TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "EventDispatcher::dispatch"); #if ENABLE(ASSERT) ASSERT(!m_eventDispatched); m_eventDispatched = true; #endif if (event().eventPath().isEmpty()) { // eventPath() can be empty if event path is shrinked by relataedTarget retargeting. return DispatchEventResult::NotCanceled; } m_event->eventPath().ensureWindowEventContext(); m_event->setTarget(EventPath::eventTargetRespectingTargetRules(*m_node)); ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); ASSERT(m_event->target()); TRACE_EVENT1("devtools.timeline", "EventDispatch", "data", InspectorEventDispatchEvent::data(*m_event)); void* preDispatchEventHandlerResult; if (dispatchEventPreProcess(preDispatchEventHandlerResult) == ContinueDispatching) { if (dispatchEventAtCapturing() == ContinueDispatching) { if (dispatchEventAtTarget() == ContinueDispatching) dispatchEventAtBubbling(); } } dispatchEventPostProcess(preDispatchEventHandlerResult); // Ensure that after event dispatch, the event's target object is the // outermost shadow DOM boundary. m_event->setTarget(m_event->eventPath().windowEventContext().target()); m_event->setCurrentTarget(nullptr); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "UpdateCounters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data()); return EventTarget::dispatchEventResult(*m_event); }
void MainThreadWebSocketChannel::didCloseSocketStream(SocketStreamHandle* handle) { WTF_LOG(Network, "MainThreadWebSocketChannel %p didCloseSocketStream()", this); if (m_identifier && m_document) { TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "WebSocketDestroy", "data", InspectorWebSocketEvent::data(m_document, m_identifier)); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), "CallStack", "stack", InspectorCallStackEvent::currentCallStack()); // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeline migrates to tracing. InspectorInstrumentation::didCloseWebSocket(m_document, m_identifier); } ASSERT_UNUSED(handle, handle == m_handle || !m_handle); // Show error message on JS console if this is unexpected connection close // during opening handshake. if (!m_hasCalledDisconnectOnHandle && m_handshake->mode() == WebSocketHandshake::Incomplete && m_document) { const String message = "WebSocket connection to '" + m_handshake->url().elidedString() + "' failed: Connection closed before receiving a handshake response"; m_document->addConsoleMessage(ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message, m_sourceURLAtConstruction, m_lineNumberAtConstruction)); } m_state = ChannelClosed; if (m_closingTimer.isActive()) m_closingTimer.stop(); if (m_outgoingFrameQueueStatus != OutgoingFrameQueueClosed) abortOutgoingFrameQueue(); if (m_handle) { WebSocketChannelClient* client = m_client; m_client = nullptr; clearDocument(); m_handle = nullptr; if (client) client->didClose(m_receivedClosingHandshake ? WebSocketChannelClient::ClosingHandshakeComplete : WebSocketChannelClient::ClosingHandshakeIncomplete, m_closeEventCode, m_closeEventReason); } deref(); }
v8::Local<v8::Value> V8WorkerGlobalScopeEventListener::callListenerFunction(v8::Handle<v8::Value> jsEvent, Event* event) { v8::Local<v8::Function> handlerFunction = getListenerFunction(scriptState()->executionContext()); v8::Local<v8::Object> receiver = getReceiverObject(event); if (handlerFunction.IsEmpty() || receiver.IsEmpty()) return v8::Local<v8::Value>(); TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "FunctionCall", "data", devToolsTraceEventData(scriptState()->executionContext(), handlerFunction, isolate())); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), "CallStack", "stack", InspectorCallStackEvent::currentCallStack()); // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeline migrates to tracing. InspectorInstrumentationCookie cookie; if (InspectorInstrumentation::timelineAgentEnabled(scriptState()->executionContext())) { int scriptId = 0; String resourceName; int lineNumber = 1; GetDevToolsFunctionInfo(handlerFunction, isolate(), scriptId, resourceName, lineNumber); cookie = InspectorInstrumentation::willCallFunction(scriptState()->executionContext(), scriptId, resourceName, lineNumber); } v8::Handle<v8::Value> parameters[1] = { jsEvent }; v8::Local<v8::Value> result = V8ScriptRunner::callFunction(handlerFunction, scriptState()->executionContext(), receiver, WTF_ARRAY_LENGTH(parameters), parameters, isolate()); InspectorInstrumentation::didCallFunction(cookie); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "UpdateCounters", "data", InspectorUpdateCountersEvent::data()); return result; }
void ImageDecodingStore::removeFromCacheInternal( const T* cacheEntry, U* cacheMap, V* identifierMap, Vector<std::unique_ptr<CacheEntry>>* deletionList) { const size_t cacheEntryBytes = cacheEntry->memoryUsageInBytes(); ASSERT(m_heapMemoryUsageInBytes >= cacheEntryBytes); m_heapMemoryUsageInBytes -= cacheEntryBytes; // Remove entry from identifier map. typename V::iterator iter = identifierMap->find(cacheEntry->generator()); ASSERT(iter != identifierMap->end()); iter->value.remove(cacheEntry->cacheKey()); if (!iter->value.size()) identifierMap->remove(iter); // Remove entry from cache map. deletionList->append(cacheMap->take(cacheEntry->cacheKey())); TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("blink.image_decoding"), "ImageDecodingStoreHeapMemoryUsageBytes", m_heapMemoryUsageInBytes); TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("blink.image_decoding"), "ImageDecodingStoreNumOfDecoders", m_decoderCacheMap.size()); }
void DOMTimer::removeByID(ExecutionContext* context, int timeoutID) { context->removeTimeoutByID(timeoutID); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "TimerRemove", "data", InspectorTimerRemoveEvent::data(context, timeoutID)); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), "CallStack", "stack", InspectorCallStackEvent::currentCallStack()); // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeline migrates to tracing. InspectorInstrumentation::didRemoveTimer(context, timeoutID); }
int DOMTimer::install(ExecutionContext* context, PassOwnPtr<ScheduledAction> action, int timeout, bool singleShot) { int timeoutID = context->installNewTimeout(action, timeout, singleShot); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "TimerInstall", "data", InspectorTimerInstallEvent::data(context, timeoutID, timeout, singleShot)); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), "CallStack", "stack", InspectorCallStackEvent::currentCallStack()); // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeline migrates to tracing. InspectorInstrumentation::didInstallTimer(context, timeoutID, timeout, singleShot); return timeoutID; }
void FrameFetchContext::dispatchWillSendRequest(DocumentLoader* loader, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse, const FetchInitiatorInfo& initiatorInfo) { m_frame->loader().applyUserAgent(request); m_frame->loader().client()->dispatchWillSendRequest(loader, identifier, request, redirectResponse); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "ResourceSendRequest", "data", InspectorSendRequestEvent::data(identifier, m_frame, request)); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), "CallStack", "stack", InspectorCallStackEvent::currentCallStack()); // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeline migrates to tracing. InspectorInstrumentation::willSendRequest(m_frame, identifier, ensureLoader(loader), request, redirectResponse, initiatorInfo); }
ScriptedAnimationController::CallbackId ScriptedAnimationController::registerCallback(PassOwnPtr<RequestAnimationFrameCallback> callback) { ScriptedAnimationController::CallbackId id = ++m_nextCallbackId; WTF_LOG(ScriptedAnimationController, "registerCallback: id = %d", id); callback->m_cancelled = false; callback->m_id = id; m_callbacks.append(callback); scheduleAnimationIfNeeded(); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "RequestAnimationFrame", TRACE_EVENT_SCOPE_PROCESS, "data", InspectorAnimationFrameEvent::data(m_document, id)); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), "CallStack", TRACE_EVENT_SCOPE_PROCESS, "stack", InspectorCallStackEvent::currentCallStack()); return id; }
void MainThreadWebSocketChannel::disconnect() { WTF_LOG(Network, "MainThreadWebSocketChannel %p disconnect()", this); if (m_identifier && m_document) { TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "WebSocketDestroy", "data", InspectorWebSocketEvent::data(m_document, m_identifier)); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), "CallStack", "stack", InspectorCallStackEvent::currentCallStack()); // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeline migrates to tracing. InspectorInstrumentation::didCloseWebSocket(m_document, m_identifier); } clearDocument(); m_client = nullptr; disconnectHandle(); }
ScriptedAnimationController::CallbackId ScriptedAnimationController::registerCallback(PassOwnPtr<RequestAnimationFrameCallback> callback) { ScriptedAnimationController::CallbackId id = ++m_nextCallbackId; callback->m_cancelled = false; callback->m_id = id; m_callbacks.append(callback); scheduleAnimationIfNeeded(); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "RequestAnimationFrame", "data", InspectorAnimationFrameEvent::data(m_document, id)); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), "CallStack", "stack", InspectorCallStackEvent::currentCallStack()); // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeline migrates to tracing. InspectorInstrumentation::didRequestAnimationFrame(m_document, id); return id; }
void OpaqueRectTrackingContentLayerDelegate::paintContents(SkCanvas* canvas, const WebRect& clip, bool canPaintLCDText, WebFloatRect& opaque) { static const unsigned char* annotationsEnabled = 0; if (UNLIKELY(!annotationsEnabled)) annotationsEnabled = EventTracer::getTraceCategoryEnabledFlag(TRACE_DISABLED_BY_DEFAULT("blink.graphics_context_annotations")); GraphicsContext context(canvas); context.setTrackOpaqueRegion(!m_opaque); context.setCertainlyOpaque(m_opaque); context.setShouldSmoothFonts(canPaintLCDText); if (*annotationsEnabled) context.setAnnotationMode(AnnotateAll); // Record transform prior to painting, as all opaque tracking will be // relative to this current value. AffineTransform canvasToContentTransform = context.getCTM().inverse(); m_painter->paint(context, clip); // Transform tracked opaque paints back to our layer's content space. ASSERT(canvasToContentTransform.isInvertible()); ASSERT(canvasToContentTransform.preservesAxisAlignment()); opaque = canvasToContentTransform.mapRect(context.opaqueRegion().asRect()); }
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 MainThreadWebSocketChannel::didOpenSocketStream(SocketStreamHandle* handle) { WTF_LOG(Network, "MainThreadWebSocketChannel %p didOpenSocketStream()", this); ASSERT(handle == m_handle); if (!m_document) return; if (m_identifier) { TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "WebSocketSendHandshakeRequest", "data", InspectorWebSocketEvent::data(m_document, m_identifier)); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), "CallStack", "stack", InspectorCallStackEvent::currentCallStack()); // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeline migrates to tracing. InspectorInstrumentation::willSendWebSocketHandshakeRequest(m_document, m_identifier, m_handshake->clientHandshakeRequest().get()); } CString handshakeMessage = m_handshake->clientHandshakeMessage(); if (!handle->send(handshakeMessage.data(), handshakeMessage.length())) failAsError("Failed to send WebSocket handshake."); }
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().string(), source.startPosition())); InspectorInstrumentation::willEvaluateScript(frame()->document()); v8::Local<v8::Value> result; { V8CacheOptions v8CacheOptions(V8CacheOptionsDefault); if (frame()->settings()) v8CacheOptions = frame()->settings()->v8CacheOptions(); // 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; 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(); } // Keep LocalFrame (and therefore ScriptController) alive. RefPtrWillBeRawPtr<LocalFrame> protect(frame()); 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; }
void FrameFetchContext::dispatchDidDownloadData(DocumentLoader*, unsigned long identifier, int dataLength, int encodedDataLength) { m_frame->loader().progress().incrementProgress(identifier, 0, dataLength); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "ResourceReceivedData", "data", InspectorReceiveDataEvent::data(identifier, m_frame, encodedDataLength)); // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeline migrates to tracing. InspectorInstrumentation::didReceiveData(m_frame, identifier, 0, dataLength, encodedDataLength); }
void FrameFetchContext::dispatchDidFail(DocumentLoader* loader, unsigned long identifier, const ResourceError& error) { m_frame->loader().progress().completeProgress(identifier); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "ResourceFinish", "data", InspectorResourceFinishEvent::data(identifier, 0, true)); // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeline migrates to tracing. InspectorInstrumentation::didFailLoading(m_frame, identifier, error); }
DispatchEventResult EventDispatcher::dispatchEvent(Node& node, PassRefPtrWillBeRawPtr<EventDispatchMediator> mediator) { TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("blink.debug"), "EventDispatcher::dispatchEvent"); ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); EventDispatcher dispatcher(node, &mediator->event()); return mediator->dispatchEvent(dispatcher); }
void ImageDecodingStore::prune() { TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("blink.image_decoding"), "ImageDecodingStore::prune"); Vector<std::unique_ptr<CacheEntry>> cacheEntriesToDelete; { MutexLocker lock(m_mutex); // Head of the list is the least recently used entry. const CacheEntry* cacheEntry = m_orderedCacheList.head(); // Walk the list of cache entries starting from the least recently used // and then keep them for deletion later. while (cacheEntry) { const bool isPruneNeeded = m_heapMemoryUsageInBytes > m_heapLimitInBytes || !m_heapLimitInBytes; if (!isPruneNeeded) break; // Cache is not used; Remove it. if (!cacheEntry->useCount()) removeFromCacheInternal(cacheEntry, &cacheEntriesToDelete); cacheEntry = cacheEntry->next(); } // Remove from cache list as well. removeFromCacheListInternal(cacheEntriesToDelete); } }
void InspectorRuntimeAgent::evaluate(ErrorString* errorString, const String& expression, const Maybe<String>& objectGroup, const Maybe<bool>& includeCommandLineAPI, const Maybe<bool>& doNotPauseOnExceptionsAndMuteConsole, const Maybe<int>& optExecutionContextId, const Maybe<bool>& returnByValue, const Maybe<bool>& generatePreview, OwnPtr<protocol::Runtime::RemoteObject>* result, Maybe<bool>* wasThrown, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) { int executionContextId; if (optExecutionContextId.isJust()) { executionContextId = optExecutionContextId.fromJust(); } else { v8::HandleScope handles(defaultScriptState()->isolate()); executionContextId = m_v8RuntimeAgent->ensureDefaultContextAvailable(defaultScriptState()->context()); } MuteConsoleScope<InspectorRuntimeAgent> muteScope; if (doNotPauseOnExceptionsAndMuteConsole.fromMaybe(false)) muteScope.enter(this); m_v8RuntimeAgent->evaluate(errorString, expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, executionContextId, returnByValue, generatePreview, result, wasThrown, exceptionDetails); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "UpdateCounters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data()); }
// Compiles a GL shader and attaches it to a program. Returns the shader ID if // successful, or 0 if not. static GrGLuint attach_shader(const GrGLContext& glCtx, GrGLuint programId, GrGLenum type, const SkString& shaderSrc) { const GrGLInterface* gli = glCtx.interface(); GrGLuint shaderId; GR_GL_CALL_RET(gli, shaderId, CreateShader(type)); if (0 == shaderId) { return 0; } const GrGLchar* sourceStr = shaderSrc.c_str(); GrGLint sourceLength = static_cast<GrGLint>(shaderSrc.size()); GR_GL_CALL(gli, ShaderSource(shaderId, 1, &sourceStr, &sourceLength)); GR_GL_CALL(gli, CompileShader(shaderId)); // Calling GetShaderiv in Chromium is quite expensive. Assume success in release builds. bool checkCompiled = !glCtx.isChromium(); #ifdef SK_DEBUG checkCompiled = true; #endif if (checkCompiled) { GrGLint compiled = GR_GL_INIT_ZERO; GR_GL_CALL(gli, GetShaderiv(shaderId, GR_GL_COMPILE_STATUS, &compiled)); if (!compiled) { GrGLint infoLen = GR_GL_INIT_ZERO; GR_GL_CALL(gli, GetShaderiv(shaderId, GR_GL_INFO_LOG_LENGTH, &infoLen)); SkAutoMalloc log(sizeof(char)*(infoLen+1)); // outside if for debugger if (infoLen > 0) { // retrieve length even though we don't need it to workaround bug in Chromium cmd // buffer param validation. GrGLsizei length = GR_GL_INIT_ZERO; GR_GL_CALL(gli, GetShaderInfoLog(shaderId, infoLen+1, &length, (char*)log.get())); GrPrintf(shaderSrc.c_str()); GrPrintf("\n%s", log.get()); } SkDEBUGFAIL("Shader compilation failed!"); GR_GL_CALL(gli, DeleteShader(shaderId)); return 0; } } TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("skia.gpu"), "skia_gpu::GLShader", TRACE_EVENT_SCOPE_THREAD, "shader", TRACE_STR_COPY(shaderSrc.c_str())); if (c_PrintShaders) { GrPrintf(shaderSrc.c_str()); GrPrintf("\n"); } // Attach the shader, but defer deletion until after we have linked the program. // This works around a bug in the Android emulator's GLES2 wrapper which // will immediately delete the shader object and free its memory even though it's // attached to a program, which then causes glLinkProgram to fail. GR_GL_CALL(gli, AttachShader(programId, shaderId)); return shaderId; }
void PingLoader::didFail(blink::WebURLLoader*, const blink::WebURLError& resourceError) { if (Page* page = this->page()) { TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "ResourceFinish", "data", InspectorResourceFinishEvent::data(m_identifier, 0, true)); didFailLoading(page); } dispose(); }
void PingLoader::timeout(Timer<PingLoader>*) { if (Page* page = this->page()) { TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "ResourceFinish", "data", InspectorResourceFinishEvent::data(m_identifier, 0, true)); didFailLoading(page); } dispose(); }
v8::MaybeLocal<v8::Value> ScriptController::callFunction(ExecutionContext* context, v8::Local<v8::Function> function, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[], v8::Isolate* isolate) { TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "FunctionCall", "data", devToolsTraceEventData(isolate, context, function)); InspectorInstrumentationCookie cookie = InspectorInstrumentation::willCallFunction(context, DevToolsFunctionInfo(function)); v8::MaybeLocal<v8::Value> result = V8ScriptRunner::callFunction(function, context, receiver, argc, info, isolate); InspectorInstrumentation::didCallFunction(cookie); return result; }