Skip to content

Commit

Permalink
Generalize IDevice::qmlProfilerHost
Browse files Browse the repository at this point in the history
The idea is to have a way for tools to specify what kind of
control channel they would like to use to communicate with
a device without making the choice explicit dependent on
the exact kind of tool to further decouple device and tool
implementations.

The 'hint' values are there to help the device implementation
to decide on which channel to use exactly in case there are
multiple choices. In any case, the tool is responsible to
check that the returned channel is suitable for its operation.

Currently the only choice is "QmlControlChannel" yielding
a simple wrapper around the former IDevice::qmlProfilerHost()
return value.

Other enum values may potentially be {Tcp,LocalSocket}ControlChannel
(to specify a type of transport) AdbChannel (to specify some
generic helper mechanism). It might also turn out that something
more complex than an enum will be needed, e.g. to express
a set of values with priorities or such, but I'd rather
avoid overengineering for now.

Change-Id: Id386425eb3dd2bb395065f0bdb6f67217cd40a71
Reviewed-by: Ulf Hermann <[email protected]>
  • Loading branch information
hjk committed Jun 8, 2016
1 parent 1e90926 commit db9437c
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 12 deletions.
6 changes: 4 additions & 2 deletions src/plugins/android/androiddevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "androidconstants.h"
#include "androidsignaloperation.h"

#include <projectexplorer/runconfiguration.h>

#include <QCoreApplication>

using namespace ProjectExplorer;
Expand Down Expand Up @@ -96,9 +98,9 @@ IDevice::Ptr AndroidDevice::clone() const
return IDevice::Ptr(new AndroidDevice(*this));
}

QString AndroidDevice::qmlProfilerHost() const
Connection AndroidDevice::toolControlChannel(const ControlChannelHint &) const
{
return QLatin1String("localhost");
return HostName("localhost");
}

} // namespace Internal
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/android/androiddevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class AndroidDevice : public ProjectExplorer::IDevice
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const override;

ProjectExplorer::IDevice::Ptr clone() const override;
QString qmlProfilerHost() const override;
ProjectExplorer::Connection toolControlChannel(const ControlChannelHint &) const override;

protected:
friend class AndroidDeviceFactory;
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/debugger/debuggerplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2156,7 +2156,9 @@ void DebuggerPluginPrivate::attachToQmlPort()
IDevice::ConstPtr device = DeviceKitInformation::device(kit);
if (device) {
rp.connParams = device->sshParameters();
rp.qmlServerAddress = device->qmlProfilerHost();
Connection toolControl = device->toolControlChannel(IDevice::QmlControlChannel);
QTC_ASSERT(toolControl.is<HostName>(), return);
rp.qmlServerAddress = toolControl.as<HostName>().host();
}
rp.qmlServerPort = Utils::Port(dlg.port());
rp.startMode = AttachToRemoteProcess;
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/projectexplorer/devicesupport/desktopdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
#include "localprocesslist.h"
#include "desktopdeviceconfigurationwidget.h"
#include "desktopprocesssignaloperation.h"

#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/runconfiguration.h>

#include <ssh/sshconnection.h>

Expand Down Expand Up @@ -134,9 +136,9 @@ DeviceEnvironmentFetcher::Ptr DesktopDevice::environmentFetcher() const
return DeviceEnvironmentFetcher::Ptr(new DesktopDeviceEnvironmentFetcher());
}

QString DesktopDevice::qmlProfilerHost() const
Connection DesktopDevice::toolControlChannel(const ControlChannelHint &) const
{
return QLatin1String("localhost");
return HostName("localhost");
}

IDevice::Ptr DesktopDevice::clone() const
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/projectexplorer/devicesupport/desktopdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class PROJECTEXPLORER_EXPORT DesktopDevice : public IDevice
DeviceProcess *createProcess(QObject *parent) const override;
DeviceProcessSignalOperation::Ptr signalOperation() const override;
DeviceEnvironmentFetcher::Ptr environmentFetcher() const override;
QString qmlProfilerHost() const override;
Connection toolControlChannel(const ControlChannelHint &) const override;

IDevice::Ptr clone() const override;

Expand Down
5 changes: 3 additions & 2 deletions src/plugins/projectexplorer/devicesupport/idevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include "../kit.h"
#include "../kitinformation.h"
#include "../runconfiguration.h"

#include <ssh/sshconnection.h>
#include <utils/portlist.h>
Expand Down Expand Up @@ -407,9 +408,9 @@ void IDevice::setSshParameters(const QSsh::SshConnectionParameters &sshParameter
d->sshParameters.hostKeyDatabase = DeviceManager::instance()->hostKeyDatabase();
}

QString IDevice::qmlProfilerHost() const
Connection IDevice::toolControlChannel(const ControlChannelHint &) const
{
return d->sshParameters.host;
return HostName(d->sshParameters.host);
}

void IDevice::setFreePorts(const Utils::PortList &freePorts)
Expand Down
16 changes: 14 additions & 2 deletions src/plugins/projectexplorer/devicesupport/idevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ class Port;
} // Utils

namespace ProjectExplorer {

class Connection;
class DeviceProcess;
class DeviceProcessList;

class Kit;

namespace Internal { class IDevicePrivate; }
Expand Down Expand Up @@ -107,6 +108,16 @@ class PROJECTEXPLORER_EXPORT PortsGatheringMethod
virtual QList<Utils::Port> usedPorts(const QByteArray &commandOutput) const = 0;
};

class PROJECTEXPLORER_EXPORT HostName
{
public:
explicit HostName(const QString &host) : m_host(host) {}
QString host() const { return m_host; }

private:
QString m_host;
};

// See cpp file for documentation.
class PROJECTEXPLORER_EXPORT IDevice
{
Expand Down Expand Up @@ -178,7 +189,8 @@ class PROJECTEXPLORER_EXPORT IDevice
QSsh::SshConnectionParameters sshParameters() const;
void setSshParameters(const QSsh::SshConnectionParameters &sshParameters);

virtual QString qmlProfilerHost() const;
enum ControlChannelHint { QmlControlChannel };
virtual Connection toolControlChannel(const ControlChannelHint &) const;

Utils::PortList freePorts() const;
void setFreePorts(const Utils::PortList &freePorts);
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/qmlprofiler/qmlprofilertool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,10 @@ void QmlProfilerTool::startRemoteTool(ProjectExplorer::RunConfiguration *rc)

IDevice::ConstPtr device = DeviceKitInformation::device(kit);
if (device) {
Connection toolControl = device->toolControlChannel(IDevice::QmlControlChannel);
QTC_ASSERT(toolControl.is<HostName>(), return);
connection.analyzerHost = toolControl.as<HostName>().host();
connection.connParams = device->sshParameters();
connection.analyzerHost = device->qmlProfilerHost();
}
connection.analyzerPort = Utils::Port(port);

Expand Down

0 comments on commit db9437c

Please sign in to comment.