DownloadEngine: Use std::unique_ptr for btRegistry_

pull/106/head
Tatsuhiro Tsujikawa 2013-07-06 18:42:57 +09:00
parent 3a3ac4ef9b
commit cc3cd8a58b
4 changed files with 10 additions and 10 deletions

View File

@ -101,12 +101,12 @@ void BtSetup::setup(std::vector<std::unique_ptr<Command>>& commands,
auto torrentAttrs =
bittorrent::getTorrentAttrs(requestGroup->getDownloadContext());
bool metadataGetMode = torrentAttrs->metadata.empty();
const std::shared_ptr<BtRegistry>& btReg = e->getBtRegistry();
const std::shared_ptr<BtObject>& btObject = btReg->get(requestGroup->getGID());
const std::shared_ptr<PieceStorage>& pieceStorage = btObject->pieceStorage;
const std::shared_ptr<PeerStorage>& peerStorage = btObject->peerStorage;
const std::shared_ptr<BtRuntime>& btRuntime = btObject->btRuntime;
const std::shared_ptr<BtAnnounce>& btAnnounce = btObject->btAnnounce;
auto& btReg = e->getBtRegistry();
auto& btObject = btReg->get(requestGroup->getGID());
auto& pieceStorage = btObject->pieceStorage;
auto& peerStorage = btObject->peerStorage;
auto& btRuntime = btObject->btRuntime;
auto& btAnnounce = btObject->btAnnounce;
// commands
{
auto c = make_unique<TrackerWatcherCommand>(e->newCUID(), requestGroup, e);

View File

@ -95,7 +95,7 @@ DownloadEngine::DownloadEngine(const std::shared_ptr<EventPoll>& eventPoll)
lastRefresh_(0),
cookieStorage_(new CookieStorage()),
#ifdef ENABLE_BITTORRENT
btRegistry_(new BtRegistry()),
btRegistry_(make_unique<BtRegistry>()),
#endif // ENABLE_BITTORRENT
#ifdef HAVE_ARES_ADDR_NODE
asyncDNSServers_(0),

View File

@ -136,7 +136,7 @@ private:
std::unique_ptr<CookieStorage> cookieStorage_;
#ifdef ENABLE_BITTORRENT
std::shared_ptr<BtRegistry> btRegistry_;
std::unique_ptr<BtRegistry> btRegistry_;
#endif // ENABLE_BITTORRENT
CUIDCounter cuidCounter_;
@ -305,7 +305,7 @@ public:
const std::unique_ptr<CookieStorage>& getCookieStorage() const;
#ifdef ENABLE_BITTORRENT
const std::shared_ptr<BtRegistry>& getBtRegistry() const
const std::unique_ptr<BtRegistry>& getBtRegistry() const
{
return btRegistry_;
}

View File

@ -289,7 +289,7 @@ void RequestGroup::createInitialCommand
throw DOWNLOAD_FAILURE_EXCEPTION
("Cancel BitTorrent download in dry-run context.");
}
std::shared_ptr<BtRegistry> btRegistry = e->getBtRegistry();
auto& btRegistry = e->getBtRegistry();
if(btRegistry->getDownloadContext(torrentAttrs->infoHash)) {
// TODO If metadataGetMode == false and each FileEntry has
// URI, then go without BT.