DHTInteractionCommand: Use std::unique_ptr for DHTConnection

Remove DHTConnection from DHTMessageReceiver because it is not used.
This commit is contained in:
Tatsuhiro Tsujikawa 2013-07-06 22:55:00 +09:00
parent fc6318d23f
commit cf8cfeefbc
5 changed files with 6 additions and 23 deletions

View file

@ -162,9 +162,9 @@ void DHTInteractionCommand::setTaskQueue(DHTTaskQueue* taskQueue)
}
void DHTInteractionCommand::setConnection
(const std::shared_ptr<DHTConnection>& connection)
(std::unique_ptr<DHTConnection> connection)
{
connection_ = connection;
connection_ = std::move(connection);
}
void DHTInteractionCommand::setUDPTrackerClient

View file

@ -56,7 +56,7 @@ private:
DHTMessageReceiver* receiver_;
DHTTaskQueue* taskQueue_;
std::shared_ptr<SocketCore> readCheckSocket_;
std::shared_ptr<DHTConnection> connection_;
std::unique_ptr<DHTConnection> connection_;
std::shared_ptr<UDPTrackerClient> udpTrackerClient_;
public:
DHTInteractionCommand(cuid_t cuid, DownloadEngine* e);
@ -75,7 +75,7 @@ public:
void setTaskQueue(DHTTaskQueue* taskQueue);
void setConnection(const std::shared_ptr<DHTConnection>& connection);
void setConnection(std::unique_ptr<DHTConnection> connection);
void setUDPTrackerClient
(const std::shared_ptr<UDPTrackerClient>& udpTrackerClient);

View file

@ -38,7 +38,6 @@
#include <utility>
#include "DHTMessageTracker.h"
#include "DHTConnection.h"
#include "DHTMessage.h"
#include "DHTQueryMessage.h"
#include "DHTResponseMessage.h"
@ -143,11 +142,6 @@ DHTMessageReceiver::handleUnknownMessage(const unsigned char* data,
return m;
}
void DHTMessageReceiver::setConnection(const std::shared_ptr<DHTConnection>& connection)
{
connection_ = connection;
}
void DHTMessageReceiver::setMessageFactory(DHTMessageFactory* factory)
{
factory_ = factory;

View file

@ -44,7 +44,6 @@ namespace aria2 {
class DHTMessageTracker;
class DHTMessage;
class DHTConnection;
class DHTMessageFactory;
class DHTRoutingTable;
class DHTUnknownMessage;
@ -53,8 +52,6 @@ class DHTMessageReceiver {
private:
std::shared_ptr<DHTMessageTracker> tracker_;
std::shared_ptr<DHTConnection> connection_;
DHTMessageFactory* factory_;
DHTRoutingTable* routingTable_;
@ -73,18 +70,11 @@ public:
void handleTimeout();
const std::shared_ptr<DHTConnection>& getConnection() const
{
return connection_;
}
const std::shared_ptr<DHTMessageTracker>& getMessageTracker() const
{
return tracker_;
}
void setConnection(const std::shared_ptr<DHTConnection>& connection);
void setMessageFactory(DHTMessageFactory* factory);
void setRoutingTable(DHTRoutingTable* routingTable);

View file

@ -111,7 +111,7 @@ std::vector<std::unique_ptr<Command>> DHTSetup::setup
}
uint16_t port;
auto connection = std::make_shared<DHTConnectionImpl>(family);
auto connection = make_unique<DHTConnectionImpl>(family);
{
port = e->getBtRegistry()->getUdpPort();
const std::string& addr =
@ -156,7 +156,6 @@ std::vector<std::unique_ptr<Command>> DHTSetup::setup
dispatcher->setTimeout(messageTimeout);
receiver->setConnection(connection);
receiver->setMessageFactory(factory.get());
receiver->setRoutingTable(routingTable.get());
@ -210,7 +209,7 @@ std::vector<std::unique_ptr<Command>> DHTSetup::setup
command->setMessageReceiver(receiver.get());
command->setTaskQueue(taskQueue.get());
command->setReadCheckSocket(connection->getSocket());
command->setConnection(connection);
command->setConnection(std::move(connection));
command->setUDPTrackerClient(udpTrackerClient);
tempCommands.push_back(std::move(command));
}