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 = auto torrentAttrs =
bittorrent::getTorrentAttrs(requestGroup->getDownloadContext()); bittorrent::getTorrentAttrs(requestGroup->getDownloadContext());
bool metadataGetMode = torrentAttrs->metadata.empty(); bool metadataGetMode = torrentAttrs->metadata.empty();
const std::shared_ptr<BtRegistry>& btReg = e->getBtRegistry(); auto& btReg = e->getBtRegistry();
const std::shared_ptr<BtObject>& btObject = btReg->get(requestGroup->getGID()); auto& btObject = btReg->get(requestGroup->getGID());
const std::shared_ptr<PieceStorage>& pieceStorage = btObject->pieceStorage; auto& pieceStorage = btObject->pieceStorage;
const std::shared_ptr<PeerStorage>& peerStorage = btObject->peerStorage; auto& peerStorage = btObject->peerStorage;
const std::shared_ptr<BtRuntime>& btRuntime = btObject->btRuntime; auto& btRuntime = btObject->btRuntime;
const std::shared_ptr<BtAnnounce>& btAnnounce = btObject->btAnnounce; auto& btAnnounce = btObject->btAnnounce;
// commands // commands
{ {
auto c = make_unique<TrackerWatcherCommand>(e->newCUID(), requestGroup, e); 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), lastRefresh_(0),
cookieStorage_(new CookieStorage()), cookieStorage_(new CookieStorage()),
#ifdef ENABLE_BITTORRENT #ifdef ENABLE_BITTORRENT
btRegistry_(new BtRegistry()), btRegistry_(make_unique<BtRegistry>()),
#endif // ENABLE_BITTORRENT #endif // ENABLE_BITTORRENT
#ifdef HAVE_ARES_ADDR_NODE #ifdef HAVE_ARES_ADDR_NODE
asyncDNSServers_(0), asyncDNSServers_(0),

View File

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

View File

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