Commit 9cf65cfd authored by hjk's avatar hjk

QmlProfiler: clean up QmlProfiler{State,Client}Manager

Change-Id: I538fbae5be9750b9b00f82d467136a8500e8f8e6
Reviewed-by: default avatarChristiaan Janssen <christiaan.janssen@digia.com>
parent 3de45d8c
......@@ -46,11 +46,10 @@ using namespace Core;
namespace QmlProfiler {
namespace Internal {
class QmlProfilerClientManager::QmlProfilerClientManagerPrivate {
class QmlProfilerClientManager::QmlProfilerClientManagerPrivate
{
public:
QmlProfilerClientManagerPrivate(QmlProfilerClientManager *qq) { Q_UNUSED(qq); }
QmlProfilerStateManager* profilerState;
QmlProfilerStateManager *profilerState;
QmlDebugConnection *connection;
QPointer<QmlProfilerTraceClient> qmlclientplugin;
......@@ -59,9 +58,7 @@ public:
QTimer connectionTimer;
int connectionAttempts;
enum ConnectMode {
TcpConnection, OstConnection
};
enum ConnectMode { TcpConnection, OstConnection };
ConnectMode connectMode;
QString tcpHost;
quint64 tcpPort;
......@@ -73,7 +70,7 @@ public:
};
QmlProfilerClientManager::QmlProfilerClientManager(QObject *parent) :
QObject(parent), d(new QmlProfilerClientManagerPrivate(this))
QObject(parent), d(new QmlProfilerClientManagerPrivate)
{
setObjectName(QLatin1String("QML Profiler Connections"));
......@@ -97,6 +94,7 @@ QmlProfilerClientManager::~QmlProfilerClientManager()
delete d;
}
////////////////////////////////////////////////////////////////
// Interface
void QmlProfilerClientManager::setTcpConnection(QString host, quint64 port)
......
......@@ -30,18 +30,19 @@
#ifndef QMLPROFILERCLIENTMANAGER_H
#define QMLPROFILERCLIENTMANAGER_H
#include <QObject>
#include <QStringList>
#include "qmlprofilerstatemanager.h"
#include <qmldebug/qmlprofilereventlocation.h>
#include <QObject>
#include <QStringList>
namespace QmlProfiler {
namespace Internal {
class QmlProfilerClientManager : public QObject
{
Q_OBJECT
public:
explicit QmlProfilerClientManager(QObject *parent = 0);
~QmlProfilerClientManager();
......@@ -84,9 +85,6 @@ private slots:
void serverRecordingChanged();
private:
class QmlProfilerClientManagerPrivate;
QmlProfilerClientManagerPrivate *d;
void connectToClient();
void enableServices();
......@@ -94,9 +92,12 @@ private:
void disconnectClientSignals();
void stopClientsRecording();
class QmlProfilerClientManagerPrivate;
QmlProfilerClientManagerPrivate *d;
};
}
}
} // namespace Internal
} // namespace QmlProfiler
#endif // QMLPROFILERCLIENTMANAGER_H
......@@ -38,7 +38,8 @@
namespace QmlProfiler {
namespace Internal {
inline QString stringForState(int state) {
static QString stringForState(int state)
{
switch (state) {
case QmlProfilerStateManager::Idle: return QLatin1String("Idle");
case QmlProfilerStateManager::AppStarting: return QLatin1String("AppStarting");
......@@ -53,92 +54,79 @@ inline QString stringForState(int state) {
return QString();
}
class QmlProfilerStateManager::QmlProfilerStateManagerPrivate
{
public:
QmlProfilerStateManagerPrivate(QmlProfilerStateManager *qq) : q(qq) {}
~QmlProfilerStateManagerPrivate() {}
QmlProfilerStateManager *q;
QmlProfilerStateManager::QmlProfilerState m_currentState;
bool m_clientRecording;
bool m_serverRecording;
};
QmlProfilerStateManager::QmlProfilerStateManager(QObject *parent) :
QObject(parent),d(new QmlProfilerStateManagerPrivate(this))
QObject(parent)
{
d->m_currentState = Idle;
d->m_clientRecording = true;
d->m_serverRecording = false;
m_currentState = Idle;
m_clientRecording = true;
m_serverRecording = false;
}
QmlProfilerStateManager::~QmlProfilerStateManager()
{
delete d;
}
QmlProfilerStateManager::QmlProfilerState QmlProfilerStateManager::currentState()
QmlProfilerStateManager::QmlProfilerState QmlProfilerStateManager::currentState() const
{
return d->m_currentState;
return m_currentState;
}
bool QmlProfilerStateManager::clientRecording()
bool QmlProfilerStateManager::clientRecording() const
{
return d->m_clientRecording;
return m_clientRecording;
}
bool QmlProfilerStateManager::serverRecording()
bool QmlProfilerStateManager::serverRecording() const
{
return d->m_serverRecording;
return m_serverRecording;
}
QString QmlProfilerStateManager::currentStateAsString()
QString QmlProfilerStateManager::currentStateAsString() const
{
return stringForState(d->m_currentState);
return stringForState(m_currentState);
}
void QmlProfilerStateManager::setCurrentState(QmlProfilerState newState)
{
#ifdef _DEBUG_PROFILERSTATE_
qDebug() << "Profiler state change request from" << stringForState(d->m_currentState) << "to" << stringForState(newState);
qDebug() << "Profiler state change request from" << currentStateAsString() << "to" << stringForState(newState);
#endif
QTC_ASSERT(d->m_currentState != newState, /**/);
QTC_ASSERT(m_currentState != newState, /**/);
switch (newState) {
case Idle:
QTC_ASSERT(d->m_currentState == AppStarting ||
d->m_currentState == AppStopped ||
d->m_currentState == AppKilled,
qDebug() << "from" << stringForState(d->m_currentState));
QTC_ASSERT(m_currentState == AppStarting ||
m_currentState == AppStopped ||
m_currentState == AppKilled,
qDebug() << "from" << currentStateAsString());
break;
case AppStarting:
QTC_ASSERT(d->m_currentState == Idle,
qDebug() << "from" << stringForState(d->m_currentState));
QTC_ASSERT(m_currentState == Idle,
qDebug() << "from" << currentStateAsString());
break;
case AppRunning:
QTC_ASSERT(d->m_currentState == AppStarting,
qDebug() << "from" << stringForState(d->m_currentState));
QTC_ASSERT(m_currentState == AppStarting,
qDebug() << "from" << currentStateAsString());
break;
case AppStopRequested:
QTC_ASSERT(d->m_currentState == AppRunning,
qDebug() << "from" << stringForState(d->m_currentState));
QTC_ASSERT(m_currentState == AppRunning,
qDebug() << "from" << currentStateAsString());
break;
case AppReadyToStop:
QTC_ASSERT(d->m_currentState == AppStopRequested,
qDebug() << "from" << stringForState(d->m_currentState));
QTC_ASSERT(m_currentState == AppStopRequested,
qDebug() << "from" << currentStateAsString());
break;
case AppStopped:
QTC_ASSERT(d->m_currentState == AppReadyToStop ||
d->m_currentState == AppDying,
qDebug() << "from" << stringForState(d->m_currentState));
QTC_ASSERT(m_currentState == AppReadyToStop ||
m_currentState == AppDying,
qDebug() << "from" << currentStateAsString());
break;
case AppDying:
QTC_ASSERT(d->m_currentState == AppRunning,
qDebug() << "from" << stringForState(d->m_currentState));
QTC_ASSERT(m_currentState == AppRunning,
qDebug() << "from" << currentStateAsString());
break;
case AppKilled:
QTC_ASSERT(d->m_currentState == AppDying,
qDebug() << "from" << stringForState(d->m_currentState));
QTC_ASSERT(m_currentState == AppDying,
qDebug() << "from" << currentStateAsString());
break;
default: {
const QString message = QString::fromLatin1("Switching to unknown state in %1:%2").arg(QString::fromLatin1(__FILE__), QString::number(__LINE__));
......@@ -147,17 +135,17 @@ void QmlProfilerStateManager::setCurrentState(QmlProfilerState newState)
break;
}
d->m_currentState = newState;
m_currentState = newState;
emit stateChanged();
}
void QmlProfilerStateManager::setClientRecording(bool recording)
{
#ifdef _DEBUG_PROFILERSTATE_
qDebug() << "Setting client recording flag from" << d->m_serverRecording << "to" << recording;
qDebug() << "Setting client recording flag from" << m_serverRecording << "to" << recording;
#endif
if (d->m_clientRecording != recording) {
d->m_clientRecording = recording;
if (m_clientRecording != recording) {
m_clientRecording = recording;
emit clientRecordingChanged();
}
}
......@@ -165,13 +153,13 @@ void QmlProfilerStateManager::setClientRecording(bool recording)
void QmlProfilerStateManager::setServerRecording(bool recording)
{
#ifdef _DEBUG_PROFILERSTATE_
qDebug() << "Setting server recording flag from" << d->m_serverRecording << "to" << recording;
qDebug() << "Setting server recording flag from" << m_serverRecording << "to" << recording;
#endif
if (d->m_serverRecording != recording) {
d->m_serverRecording = recording;
if (m_serverRecording != recording) {
m_serverRecording = recording;
emit serverRecordingChanged();
}
}
}
}
} // namespace Internal
} // namespace QmlProfiler
......@@ -38,6 +38,7 @@ namespace Internal {
class QmlProfilerStateManager : public QObject
{
Q_OBJECT
public:
enum QmlProfilerState {
Idle,
......@@ -53,11 +54,11 @@ public:
explicit QmlProfilerStateManager(QObject *parent = 0);
~QmlProfilerStateManager();
QmlProfilerState currentState();
bool clientRecording();
bool serverRecording();
QmlProfilerState currentState() const;
bool clientRecording() const;
bool serverRecording() const;
QString currentStateAsString();
QString currentStateAsString() const;
signals:
void stateChanged();
......@@ -70,11 +71,12 @@ public slots:
void setServerRecording(bool recording);
private:
class QmlProfilerStateManagerPrivate;
QmlProfilerStateManagerPrivate *d;
QmlProfilerStateManager::QmlProfilerState m_currentState;
bool m_clientRecording;
bool m_serverRecording;
};
}
}
} // namespace Internal
} // namespace QmlProfiler
#endif // QMLPROFILERSTATEMANAGER_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment