| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/debugger/qqmlabstractprofileradapter.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||
| 2 | ** | - | ||||||
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||
| 4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||
| 5 | ** | - | ||||||
| 6 | ** This file is part of the QtQml module of the Qt Toolkit. | - | ||||||
| 7 | ** | - | ||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||
| 9 | ** Commercial License Usage | - | ||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||
| 16 | ** | - | ||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||
| 19 | ** General Public License version 3 as published by the Free Software | - | ||||||
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||
| 21 | ** packaging of this file. Please review the following information to | - | ||||||
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||
| 24 | ** | - | ||||||
| 25 | ** GNU General Public License Usage | - | ||||||
| 26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||
| 28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||
| 31 | ** included in the packaging of this file. Please review the following | - | ||||||
| 32 | ** information to ensure the GNU General Public License requirements will | - | ||||||
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||
| 35 | ** | - | ||||||
| 36 | ** $QT_END_LICENSE$ | - | ||||||
| 37 | ** | - | ||||||
| 38 | ****************************************************************************/ | - | ||||||
| 39 | - | |||||||
| 40 | #include "qqmlabstractprofileradapter_p.h" | - | ||||||
| 41 | - | |||||||
| 42 | QT_BEGIN_NAMESPACE | - | ||||||
| 43 | - | |||||||
| 44 | /*! | - | ||||||
| 45 | * \internal | - | ||||||
| 46 | * \class QQmlAbstractProfilerAdapter | - | ||||||
| 47 | * \inmodule QtQml | - | ||||||
| 48 | * Abstract base class for all adapters between profilers and the QQmlProfilerService. Adapters have | - | ||||||
| 49 | * to retrieve profiler-specific data and convert it to the format sent over the wire. Adapters must | - | ||||||
| 50 | * live in the QDebugServer thread but the actual profilers can live in different threads. The | - | ||||||
| 51 | * recommended way to deal with this is passing the profiling data through a signal/slot connection. | - | ||||||
| 52 | */ | - | ||||||
| 53 | - | |||||||
| 54 | /*! | - | ||||||
| 55 | * \internal | - | ||||||
| 56 | * \fn void QQmlAbstractProfilerAdapter::dataRequested() | - | ||||||
| 57 | * Signals that data has been requested by the \c QQmlProfilerService. This signal should be | - | ||||||
| 58 | * connected to a slot in the profiler and the profiler should then transfer its currently available | - | ||||||
| 59 | * profiling data to the adapter as soon as possible. | - | ||||||
| 60 | */ | - | ||||||
| 61 | - | |||||||
| 62 | /*! | - | ||||||
| 63 | * \internal | - | ||||||
| 64 | * \fn qint64 QQmlAbstractProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &messages) | - | ||||||
| 65 | * Append the messages up to the timestamp \a until, chronologically sorted, to \a messages. Keep | - | ||||||
| 66 | * track of the messages already sent and with each subsequent call to this method start with the | - | ||||||
| 67 | * first one not yet sent. Messages that have been sent can be deleted. When new data from the | - | ||||||
| 68 | * profiler arrives the information about the last sent message must be reset. Return the timestamp | - | ||||||
| 69 | * of the next message after \a until or \c -1 if there is no such message. | - | ||||||
| 70 | * The profiler service keeps a list of adapters, sorted by time of next message and keeps querying | - | ||||||
| 71 | * the first one to send messages up to the time of the second one. Like that we get chronologically | - | ||||||
| 72 | * sorted messages and can occasionally post the messages to exploit parallelism and save memory. | - | ||||||
| 73 | */ | - | ||||||
| 74 | - | |||||||
| 75 | /*! | - | ||||||
| 76 | * \internal | - | ||||||
| 77 | * Emits either \c profilingEnabled(quint64) or \c profilingEnabledWhileWaiting(quint64), depending | - | ||||||
| 78 | * on \c waiting. If the profiler's thread is waiting for an initial start signal, we can emit the | - | ||||||
| 79 | * signal over a Qt::DirectConnection to avoid the delay of the event loop. The \a features are | - | ||||||
| 80 | * passed on to the signal. | - | ||||||
| 81 | */ | - | ||||||
| 82 | void QQmlAbstractProfilerAdapter::startProfiling(quint64 features) | - | ||||||
| 83 | { | - | ||||||
| 84 | if (waiting)
| 0-24 | ||||||
| 85 | emit profilingEnabledWhileWaiting(features); executed 24 times by 1 test: profilingEnabledWhileWaiting(features);Executed by:
| 24 | ||||||
| 86 | else | - | ||||||
| 87 | emit profilingEnabled(features); never executed: profilingEnabled(features); | 0 | ||||||
| 88 | featuresEnabled = features; | - | ||||||
| 89 | } executed 24 times by 1 test: end of blockExecuted by:
| 24 | ||||||
| 90 | - | |||||||
| 91 | /*! | - | ||||||
| 92 | * \internal | - | ||||||
| 93 | * Emits either \c profilingDisabled() or \c profilingDisabledWhileWaiting(), depending on | - | ||||||
| 94 | * \c waiting. If the profiler's thread is waiting for an initial start signal, we can emit the | - | ||||||
| 95 | * signal over a Qt::DirectConnection to avoid the delay of the event loop. This should trigger | - | ||||||
| 96 | * the profiler to report its collected data and subsequently delete it. | - | ||||||
| 97 | */ | - | ||||||
| 98 | void QQmlAbstractProfilerAdapter::stopProfiling() { | - | ||||||
| 99 | if (waiting)
| 0-24 | ||||||
| 100 | emit profilingDisabledWhileWaiting(); executed 24 times by 1 test: profilingDisabledWhileWaiting();Executed by:
| 24 | ||||||
| 101 | else | - | ||||||
| 102 | emit profilingDisabled(); never executed: profilingDisabled(); | 0 | ||||||
| 103 | featuresEnabled = 0; | - | ||||||
| 104 | } executed 24 times by 1 test: end of blockExecuted by:
| 24 | ||||||
| 105 | - | |||||||
| 106 | /*! | - | ||||||
| 107 | * \internal | - | ||||||
| 108 | * \fn bool QQmlAbstractProfilerAdapter::isRunning() const | - | ||||||
| 109 | * Returns if the profiler is currently running. The profiler is considered to be running after | - | ||||||
| 110 | * \c startProfiling(quint64) has been called until \c stopProfiling() is called. That is | - | ||||||
| 111 | * independent of \c waiting. The profiler may be running and waiting at the same time. | - | ||||||
| 112 | */ | - | ||||||
| 113 | - | |||||||
| 114 | /*! | - | ||||||
| 115 | * \internal | - | ||||||
| 116 | * \fn void QQmlAbstractProfilerAdapter::profilingDisabled() | - | ||||||
| 117 | * This signal is emitted if \c stopProfiling() is called while the profiler is not considered to | - | ||||||
| 118 | * be waiting. The profiler is expected to handle the signal asynchronously. | - | ||||||
| 119 | */ | - | ||||||
| 120 | - | |||||||
| 121 | /*! | - | ||||||
| 122 | * \internal | - | ||||||
| 123 | * \fn void QQmlAbstractProfilerAdapter::profilingDisabledWhileWaiting() | - | ||||||
| 124 | * This signal is emitted if \c stopProfiling() is called while the profiler is considered to be | - | ||||||
| 125 | * waiting. In many cases this signal can be connected with a Qt::DirectConnection. | - | ||||||
| 126 | */ | - | ||||||
| 127 | - | |||||||
| 128 | /*! | - | ||||||
| 129 | * \internal | - | ||||||
| 130 | * \fn void QQmlAbstractProfilerAdapter::profilingEnabled(quint64 features) | - | ||||||
| 131 | * This signal is emitted if \c startProfiling(quint64) is called while the profiler is not | - | ||||||
| 132 | * considered to be waiting. The profiler is expected to handle the signal asynchronously. The | - | ||||||
| 133 | * \a features are passed on from \c startProfiling(quint64). | - | ||||||
| 134 | */ | - | ||||||
| 135 | - | |||||||
| 136 | /*! | - | ||||||
| 137 | * \internal | - | ||||||
| 138 | * \fn void QQmlAbstractProfilerAdapter::profilingEnabledWhileWaiting(quint64 features) | - | ||||||
| 139 | * This signal is emitted if \c startProfiling(quint64) is called while the profiler is considered | - | ||||||
| 140 | * to be waiting. In many cases this signal can be connected with a Qt::DirectConnection. By | - | ||||||
| 141 | * starting the profiler synchronously when the QML engine starts instead of waiting for the first | - | ||||||
| 142 | * iteration of the event loop the engine startup can be profiled. The \a features are passed on | - | ||||||
| 143 | * from \c startProfiling(quint64). | - | ||||||
| 144 | */ | - | ||||||
| 145 | - | |||||||
| 146 | /*! | - | ||||||
| 147 | * \internal | - | ||||||
| 148 | * \fn void QQmlAbstractProfilerAdapter::referenceTimeKnown(const QElapsedTimer &timer) | - | ||||||
| 149 | * This signal is used to synchronize the profiler's timer to the QQmlProfilerservice's. The | - | ||||||
| 150 | * profiler is expected to save \a timer and use it for timestamps on its data. | - | ||||||
| 151 | */ | - | ||||||
| 152 | - | |||||||
| 153 | /*! | - | ||||||
| 154 | * \internal | - | ||||||
| 155 | * \fn void QQmlAbstractProfilerAdapter::synchronize(const QElapsedTimer &timer) | - | ||||||
| 156 | * Synchronize the profiler to \a timer. This emits \c referenceTimeKnown(). | - | ||||||
| 157 | */ | - | ||||||
| 158 | - | |||||||
| 159 | /*! | - | ||||||
| 160 | * \internal | - | ||||||
| 161 | * \fn void QQmlAbstractProfilerAdapter::reportData() | - | ||||||
| 162 | * Make the profiler report its current data without stopping the collection. The same (and | - | ||||||
| 163 | * additional) data can later be requested again with \c stopProfiling() or \c reportData(). | - | ||||||
| 164 | */ | - | ||||||
| 165 | - | |||||||
| 166 | /*! | - | ||||||
| 167 | * \internal | - | ||||||
| 168 | * \fn void QQmlAbstractProfilerAdapter::startWaiting() | - | ||||||
| 169 | * Consider the profiler to be waiting from now on. While the profiler is waiting it can be directly | - | ||||||
| 170 | * accessed even if it is in a different thread. This method should only be called if it is actually | - | ||||||
| 171 | * safe to do so. | - | ||||||
| 172 | */ | - | ||||||
| 173 | - | |||||||
| 174 | /*! | - | ||||||
| 175 | * \internal | - | ||||||
| 176 | * \fn void QQmlAbstractProfilerAdapter::stopWaiting() | - | ||||||
| 177 | * Consider the profiler not to be waiting anymore. If it lives in a different threads any requests | - | ||||||
| 178 | * for it have to be done via a queued connection then. | - | ||||||
| 179 | */ | - | ||||||
| 180 | - | |||||||
| 181 | QT_END_NAMESPACE | - | ||||||
| 182 | - | |||||||
| 183 | #include "moc_qqmlabstractprofileradapter_p.cpp" | - | ||||||
| Source code | Switch to Preprocessed file |