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; }
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)); 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::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; }
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; } } }
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 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(); }
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); }
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); }
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; }
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; }
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 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(); }
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."); }
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(); }
void FrameFetchContext::dispatchDidReceiveResponse(unsigned long identifier, const ResourceResponse& response, WebURLRequest::FrameType frameType, WebURLRequest::RequestContext requestContext, Resource* resource) { LinkLoader::CanLoadResources resourceLoadingPolicy = LinkLoader::LoadResourcesAndPreconnect; MixedContentChecker::checkMixedPrivatePublic(frame(), response.remoteIPAddress()); if (m_documentLoader == frame()->loader().provisionalDocumentLoader()) { ResourceFetcher* fetcher = nullptr; if (frame()->document()) fetcher = frame()->document()->fetcher(); m_documentLoader->clientHintsPreferences().updateFromAcceptClientHintsHeader(response.httpHeaderField(HTTPNames::Accept_CH), fetcher); // When response is received with a provisional docloader, the resource haven't committed yet, and we cannot load resources, only preconnect. resourceLoadingPolicy = LinkLoader::DoNotLoadResources; } LinkLoader::loadLinksFromHeader(response.httpHeaderField(HTTPNames::Link), response.url(), frame()->document(), NetworkHintsInterfaceImpl(), resourceLoadingPolicy, nullptr); if (response.hasMajorCertificateErrors()) MixedContentChecker::handleCertificateError(frame(), response, frameType, requestContext); frame()->loader().progress().incrementProgress(identifier, response); frame()->loader().client()->dispatchDidReceiveResponse(m_documentLoader, identifier, response); TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceReceiveResponse", TRACE_EVENT_SCOPE_THREAD, "data", InspectorReceiveResponseEvent::data(identifier, frame(), response)); DocumentLoader* documentLoader = masterDocumentLoader(); InspectorInstrumentation::didReceiveResourceResponse(frame(), identifier, documentLoader, response, resource); // It is essential that inspector gets resource response BEFORE console. frame()->console().reportResourceResponseReceived(documentLoader, identifier, response); }
int DOMTimer::install(ExecutionContext* context, RawPtr<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::didInstallTimer(context, timeoutID, timeout, singleShot); return timeoutID; }
bool WebCompositorInputHandlerImpl::cancelCurrentFling() { bool hadFlingAnimation = m_wheelFlingAnimation; TRACE_EVENT_INSTANT1("cc", "WebCompositorInputHandlerImpl::cancelCurrentFling", "hadFlingAnimation", hadFlingAnimation); m_wheelFlingAnimation.clear(); return hadFlingAnimation; }
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 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(); }
ScriptedIdleTaskController::CallbackId ScriptedIdleTaskController::registerCallback( IdleRequestCallback* callback, const IdleRequestOptions& options) { CallbackId id = nextCallbackId(); m_callbacks.set(id, callback); long long timeoutMillis = options.timeout(); RefPtr<internal::IdleRequestCallbackWrapper> callbackWrapper = internal::IdleRequestCallbackWrapper::create(id, this); m_scheduler->postIdleTask( BLINK_FROM_HERE, WTF::bind(&internal::IdleRequestCallbackWrapper::idleTaskFired, callbackWrapper)); if (timeoutMillis > 0) m_scheduler->timerTaskRunner()->postDelayedTask( BLINK_FROM_HERE, WTF::bind(&internal::IdleRequestCallbackWrapper::timeoutFired, callbackWrapper), timeoutMillis); TRACE_EVENT_INSTANT1("devtools.timeline", "RequestIdleCallback", TRACE_EVENT_SCOPE_THREAD, "data", InspectorIdleCallbackRequestEvent::data( getExecutionContext(), id, timeoutMillis)); return id; }
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; }
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 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); }
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); }
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(); }
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; }
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 FrameFetchContext::dispatchWillSendRequest(unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse, const FetchInitiatorInfo& initiatorInfo) { frame()->loader().applyUserAgent(request); frame()->loader().client()->dispatchWillSendRequest(m_documentLoader, identifier, request, redirectResponse); TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceSendRequest", TRACE_EVENT_SCOPE_THREAD, "data", InspectorSendRequestEvent::data(identifier, frame(), request)); InspectorInstrumentation::willSendRequest(frame(), identifier, ensureLoaderForNotifications(), request, redirectResponse, initiatorInfo); }
// 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 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()); }
void PingLoader::timeout(Timer<PingLoader>*) { if (LocalFrame* frame = this->frame()) { TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceFinish", TRACE_EVENT_SCOPE_THREAD, "data", InspectorResourceFinishEvent::data(m_identifier, 0, true)); didFailLoading(frame); } dispose(); }