diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-11-10 17:14:54 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2013-11-10 18:19:02 +0900 |
| commit | 9e52483c04045ced0aa11b408f905a2baa97ea49 (patch) | |
| tree | c4ff5a083b2bff01a3d335d378fba771fabf2d85 /src/UTMetadataPostDownloadHandler.cc | |
| parent | ba3b823a667fbb794d811b3c565aa103391a0e1c (diff) | |
Refactor DownloadHandlerFactory
Diffstat (limited to 'src/UTMetadataPostDownloadHandler.cc')
| -rw-r--r-- | src/UTMetadataPostDownloadHandler.cc | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/UTMetadataPostDownloadHandler.cc b/src/UTMetadataPostDownloadHandler.cc index 58e3002a..ff006d8a 100644 --- a/src/UTMetadataPostDownloadHandler.cc +++ b/src/UTMetadataPostDownloadHandler.cc @@ -53,29 +53,33 @@ namespace aria2 { -bool UTMetadataPostDownloadHandler::Criteria::match -(const RequestGroup* requestGroup) const +namespace { +class Criteria:public RequestGroupCriteria { - const std::shared_ptr<DownloadContext>& dctx = - requestGroup->getDownloadContext(); - if(dctx->hasAttribute(CTX_ATTR_BT)) { - if(bittorrent::getTorrentAttrs(dctx)->metadata.empty()) { - return true; +public: + virtual bool match(const RequestGroup* requestGroup) const CXX11_OVERRIDE + { + auto& dctx = requestGroup->getDownloadContext(); + if(dctx->hasAttribute(CTX_ATTR_BT)) { + if(bittorrent::getTorrentAttrs(dctx)->metadata.empty()) { + return true; + } } + return false; } - return false; -} +}; +} // namespace UTMetadataPostDownloadHandler::UTMetadataPostDownloadHandler() { - std::shared_ptr<Criteria> cri(new Criteria()); - setCriteria(cri); + setCriteria(make_unique<Criteria>()); } void UTMetadataPostDownloadHandler::getNextRequestGroups -(std::vector<std::shared_ptr<RequestGroup> >& groups, RequestGroup* requestGroup) +(std::vector<std::shared_ptr<RequestGroup> >& groups, + RequestGroup* requestGroup) const { - const std::shared_ptr<DownloadContext>& dctx =requestGroup->getDownloadContext(); + auto& dctx =requestGroup->getDownloadContext(); auto attrs = bittorrent::getTorrentAttrs(dctx); std::string metadata = util::toString(requestGroup->getPieceStorage()->getDiskAdaptor()); @@ -92,7 +96,7 @@ void UTMetadataPostDownloadHandler::getNextRequestGroups } } if(!requestGroup->getOption()->getAsBool(PREF_BT_METADATA_ONLY)) { - std::vector<std::shared_ptr<RequestGroup> > newRgs; + std::vector<std::shared_ptr<RequestGroup>> newRgs; // Don't adjust announce URI because it has been done when // RequestGroup is created with magnet URI. createRequestGroupForBitTorrent(newRgs, requestGroup->getOption(), |
