void MutationObserver::deliver() { DCHECK(!shouldBeSuspended()); // Calling clearTransientRegistrations() can modify m_registrations, so it's // necessary to make a copy of the transient registrations before operating on // them. HeapVector<Member<MutationObserverRegistration>, 1> transientRegistrations; for (auto& registration : m_registrations) { if (registration->hasTransientRegistrations()) transientRegistrations.append(registration); } for (size_t i = 0; i < transientRegistrations.size(); ++i) transientRegistrations[i]->clearTransientRegistrations(); if (m_records.isEmpty()) return; MutationRecordVector records; records.swap(m_records); // Report the first (earliest) stack as the async cause. InspectorInstrumentation::AsyncTask asyncTask( m_callback->getExecutionContext(), records.first()); m_callback->call(records, this); }
void XMLHttpRequestProgressEventThrottle::dispatchReadyStateChangeEvent(Event* event, DeferredEventAction action) { XMLHttpRequest::State state = m_target->readyState(); // Given that ResourceDispatcher doesn't deliver an event when suspended, // we don't have to worry about event dispatching while suspended. if (action == Flush) { if (m_deferred.isSet()) dispatchProgressProgressEvent(m_deferred.take()); stop(); } else if (action == Clear) { m_deferred.clear(); stop(); } m_hasDispatchedProgressProgressEvent = false; if (state == m_target->readyState()) { // We don't dispatch the event when an event handler associated with // the previously dispatched event changes the readyState (e.g. when // the event handler calls xhr.abort()). In such cases a // readystatechange should have been already dispatched if necessary. InspectorInstrumentation::AsyncTask asyncTask(m_target->getExecutionContext(), m_target, m_target->isAsync()); m_target->dispatchEvent(event); } }
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 XMLHttpRequestUpload::handleRequestError(const AtomicString& type) { bool lengthComputable = m_lastTotalBytesToBeSent > 0 && m_lastBytesSent <= m_lastTotalBytesToBeSent; InspectorInstrumentation::AsyncTask asyncTask(getExecutionContext(), m_xmlHttpRequest, m_xmlHttpRequest->isAsync()); dispatchEvent(ProgressEvent::create(EventTypeNames::progress, lengthComputable, m_lastBytesSent, m_lastTotalBytesToBeSent)); dispatchEventAndLoadEnd(type, lengthComputable, m_lastBytesSent, m_lastTotalBytesToBeSent); }
void MediaStream::getJSONStats(std::function<void(std::string)> callback) { asyncTask([callback] (std::shared_ptr<MediaStream> connection) { std::string requested_stats = connection->stats_->getStats(); // ELOG_DEBUG("%s message: Stats, stats: %s", connection->toLog(), requested_stats.c_str()); callback(requested_stats); }); }
void MediaStream::close() { ELOG_DEBUG("%s message: Async close called", toLog()); std::shared_ptr<MediaStream> shared_this = shared_from_this(); asyncTask([shared_this] (std::shared_ptr<MediaStream> stream) { shared_this->syncClose(); }); }
void XMLHttpRequestUpload::dispatchEventAndLoadEnd(const AtomicString& type, bool lengthComputable, unsigned long long bytesSent, unsigned long long total) { ASSERT(type == EventTypeNames::load || type == EventTypeNames::abort || type == EventTypeNames::error || type == EventTypeNames::timeout); InspectorInstrumentation::AsyncTask asyncTask(getExecutionContext(), m_xmlHttpRequest, m_xmlHttpRequest->isAsync()); dispatchEvent(ProgressEvent::create(type, lengthComputable, bytesSent, total)); dispatchEvent(ProgressEvent::create(EventTypeNames::loadend, lengthComputable, bytesSent, total)); }
void XMLHttpRequestUpload::dispatchProgressEvent(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) { m_lastBytesSent = bytesSent; m_lastTotalBytesToBeSent = totalBytesToBeSent; InspectorInstrumentation::AsyncTask asyncTask(getExecutionContext(), m_xmlHttpRequest, m_xmlHttpRequest->isAsync()); dispatchEvent(ProgressEvent::create(EventTypeNames::progress, true, bytesSent, totalBytesToBeSent)); }
PingWindow::PingWindow(QWidget* parent) : QWidget(parent), ui(new Ui::PingWindow) { ui->setupUi(this); //window flags this->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint); this->setAttribute(Qt::WA_DeleteOnClose, true); //drop behavior setAcceptDrops(true); //get a pinger instance pingerInstance = Pinger::Instance(); //create the timer object this->asyncWorker = new QTimer(this); connect(this->asyncWorker, SIGNAL(timeout()), this, SLOT(asyncTask())); //format plot ui->plotLatency->addGraph(); ui->plotLatency->graph(0)->setPen(QPen(Qt::darkGreen)); ui->plotLatency->graph(0)->setBrush(QBrush(QColor(230, 230, 230))); ui->plotLatency->graph(0)->setAntialiasedFill(false); // ui->plotLatency->xAxis->setTickLabelType(QCPAxis::ltDateTime); ui->plotLatency->xAxis->setDateTimeFormat("hh:mm:ss"); ui->plotLatency->xAxis->setAutoTickStep(false); ui->plotLatency->xAxis->setTickStep(25); //reset values this->resetValues(); }
void WebIDBCallbacksImpl::onSuccess(const WebVector<WebString>& webStringList) { Vector<String> stringList; for (size_t i = 0; i < webStringList.size(); ++i) stringList.append(webStringList[i]); InspectorInstrumentation::AsyncTask asyncTask(m_request->getExecutionContext(), this); m_request->onSuccess(stringList); }
void MediaStream::setMaxVideoBW(uint32_t max_video_bw) { asyncTask([max_video_bw] (std::shared_ptr<MediaStream> stream) { if (stream->rtcp_processor_) { stream->rtcp_processor_->setMaxVideoBW(max_video_bw * 1000); stream->pipeline_->notifyUpdate(); } }); }
void WorkerEventQueue::dispatchEvent(Event* event, ExecutionContext* executionContext) { if (!event || !removeEvent(event)) return; InspectorInstrumentation::AsyncTask asyncTask(executionContext, event); event->target()->dispatchEvent(event); }
void ExternalOutput::queueDataAsync(std::shared_ptr<DataPacket> copied_packet) { asyncTask([copied_packet] (std::shared_ptr<ExternalOutput> this_ptr) { if (!this_ptr->pipeline_initialized_) { return; } this_ptr->pipeline_->write(std::move(copied_packet)); }); }
void WebIDBCallbacksImpl::onSuccess(const WebVector<WebIDBValue>& values) { InspectorInstrumentation::AsyncTask asyncTask(m_request->getExecutionContext(), this); Vector<RefPtr<IDBValue>> idbValues(values.size()); for (size_t i = 0; i < values.size(); ++i) idbValues[i] = IDBValue::create(values[i]); m_request->onSuccess(idbValues); }
void XMLHttpRequestProgressEventThrottle::dispatchProgressProgressEvent(Event* progressEvent) { XMLHttpRequest::State state = m_target->readyState(); if (m_target->readyState() == XMLHttpRequest::LOADING && m_hasDispatchedProgressProgressEvent) { TRACE_EVENT1("devtools.timeline", "XHRReadyStateChange", "data", InspectorXhrReadyStateChangeEvent::data(m_target->getExecutionContext(), m_target)); InspectorInstrumentation::AsyncTask asyncTask(m_target->getExecutionContext(), m_target, m_target->isAsync()); m_target->dispatchEvent(Event::create(EventTypeNames::readystatechange)); TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "UpdateCounters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data()); } if (m_target->readyState() != state) return; m_hasDispatchedProgressProgressEvent = true; InspectorInstrumentation::AsyncTask asyncTask(m_target->getExecutionContext(), m_target, m_target->isAsync()); m_target->dispatchEvent(progressEvent); }
void DOMWindowEventQueue::dispatchEvent(Event* event) { EventTarget* eventTarget = event->target(); InspectorInstrumentation::AsyncTask asyncTask( eventTarget->getExecutionContext(), event); if (LocalDOMWindow* window = eventTarget->toLocalDOMWindow()) window->dispatchEvent(event, nullptr); else eventTarget->dispatchEvent(event); }
void MediaStream::muteStream(bool mute_video, bool mute_audio) { asyncTask([mute_audio, mute_video] (std::shared_ptr<MediaStream> media_stream) { ELOG_DEBUG("%s message: muteStream, mute_video: %u, mute_audio: %u", media_stream->toLog(), mute_video, mute_audio); media_stream->audio_muted_ = mute_audio; media_stream->video_muted_ = mute_video; media_stream->stats_->getNode()[media_stream->getAudioSinkSSRC()].insertStat("erizoAudioMute", CumulativeStat{mute_audio}); media_stream->stats_->getNode()[media_stream->getAudioSinkSSRC()].insertStat("erizoVideoMute", CumulativeStat{mute_video}); media_stream->pipeline_->notifyUpdate(); }); }
bool ExternalOutput::init() { MediaInfo m; m.hasVideo = false; m.hasAudio = false; recording_ = true; asyncTask([] (std::shared_ptr<ExternalOutput> output) { output->initializePipeline(); }); thread_ = boost::thread(&ExternalOutput::sendLoop, this); ELOG_DEBUG("Initialized successfully"); return true; }
void MediaStream::setSlideShowMode(bool state) { ELOG_DEBUG("%s slideShowMode: %u", toLog(), state); if (slide_show_mode_ == state) { return; } asyncTask([state] (std::shared_ptr<MediaStream> media_stream) { media_stream->stats_->getNode()[media_stream->getVideoSinkSSRC()].insertStat( "erizoSlideShow", CumulativeStat{state}); }); slide_show_mode_ = state; notifyUpdateToHandlers(); }
void ScriptPromiseResolver::resolveOrRejectImmediately() { DCHECK(!getExecutionContext()->isContextDestroyed()); DCHECK(!getExecutionContext()->activeDOMObjectsAreSuspended()); { InspectorInstrumentation::AsyncTask asyncTask(getExecutionContext(), this); if (m_state == Resolving) { m_resolver.resolve(m_value.newLocal(m_scriptState->isolate())); } else { ASSERT(m_state == Rejecting); m_resolver.reject(m_value.newLocal(m_scriptState->isolate())); } } detach(); }
void run() { if (!m_loader) return; ExecutionContext& context = m_loader->element()->document(); InspectorInstrumentation::AsyncTask asyncTask(&context, this); if (m_scriptState->contextIsValid()) { ScriptState::Scope scope(m_scriptState.get()); m_loader->doUpdateFromElement(m_shouldBypassMainWorldCSP, m_updateBehavior, m_requestURL, m_referrerPolicy); } else { m_loader->doUpdateFromElement(m_shouldBypassMainWorldCSP, m_updateBehavior, m_requestURL, m_referrerPolicy); } }
void GenericEventQueue::timerFired(Timer<GenericEventQueue>*) { ASSERT(!m_timer.isActive()); ASSERT(!m_pendingEvents.isEmpty()); HeapVector<Member<Event>> pendingEvents; m_pendingEvents.swap(pendingEvents); for (const auto& pendingEvent : pendingEvents) { Event* event = pendingEvent.get(); EventTarget* target = event->target() ? event->target() : m_owner.get(); CString type(event->type().ascii()); InspectorInstrumentation::AsyncTask asyncTask(target->getExecutionContext(), event); TRACE_EVENT_ASYNC_STEP_INTO1("event", "GenericEventQueue:enqueueEvent", event, "dispatch", "type", type); target->dispatchEvent(pendingEvent); TRACE_EVENT_ASYNC_END1("event", "GenericEventQueue:enqueueEvent", event, "type", type); } }
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(); }
bool SQLStatement::performCallback(SQLTransaction* transaction) { ASSERT(transaction); ASSERT(m_backend); bool callbackError = false; SQLStatementCallback* callback = m_statementCallback.release(); SQLStatementErrorCallback* errorCallback = m_statementErrorCallback.release(); SQLErrorData* error = m_backend->sqlError(); InspectorInstrumentation::AsyncTask asyncTask(transaction->database()->getExecutionContext(), this); // Call the appropriate statement callback and track if it resulted in an error, // because then we need to jump to the transaction error callback. if (error) { if (errorCallback) callbackError = errorCallback->handleEvent(transaction, SQLError::create(*error)); } else if (callback) { callbackError = !callback->handleEvent(transaction, m_backend->sqlResultSet()); } return callbackError; }
void WebIDBCallbacksImpl::onSuccess(const WebIDBKey& key) { InspectorInstrumentation::AsyncTask asyncTask(m_request->getExecutionContext(), this); m_request->onSuccess(key); }
void WebIDBCallbacksImpl::onSuccess(WebIDBDatabase* backend, const WebIDBMetadata& metadata) { InspectorInstrumentation::AsyncTask asyncTask(m_request->getExecutionContext(), this); m_request->onSuccess(wrapUnique(backend), IDBDatabaseMetadata(metadata)); }
void WebIDBCallbacksImpl::onSuccess(WebIDBCursor* cursor, const WebIDBKey& key, const WebIDBKey& primaryKey, const WebIDBValue& value) { InspectorInstrumentation::AsyncTask asyncTask(m_request->getExecutionContext(), this); m_request->onSuccess(wrapUnique(cursor), key, primaryKey, IDBValue::create(value)); }
void WebIDBCallbacksImpl::onBlocked(long long oldVersion) { InspectorInstrumentation::AsyncTask asyncTask(m_request->getExecutionContext(), this); m_request->onBlocked(oldVersion); }
void WebIDBCallbacksImpl::onError(const WebIDBDatabaseError& error) { InspectorInstrumentation::AsyncTask asyncTask(m_request->getExecutionContext(), this); m_request->onError(DOMException::create(error.code(), error.message())); }
void WebIDBCallbacksImpl::onUpgradeNeeded(long long oldVersion, WebIDBDatabase* database, const WebIDBMetadata& metadata, unsigned short dataLoss, WebString dataLossMessage) { InspectorInstrumentation::AsyncTask asyncTask(m_request->getExecutionContext(), this); m_request->onUpgradeNeeded(oldVersion, wrapUnique(database), IDBDatabaseMetadata(metadata), static_cast<WebIDBDataLoss>(dataLoss), dataLossMessage); }