Code cleanup

pull/28/head
Tatsuhiro Tsujikawa 2012-09-28 00:26:34 +09:00
parent c6b76f1d32
commit 1fdc6e0a33
4 changed files with 24 additions and 25 deletions

View File

@ -48,7 +48,8 @@ bool DownloadHandler::canHandle(const RequestGroup* requestGroup) const
return criteria_ && criteria_->match(requestGroup); return criteria_ && criteria_->match(requestGroup);
} }
void DownloadHandler::setCriteria(const RequestGroupCriteriaHandle& criteria) void DownloadHandler::setCriteria
(const SharedHandle<RequestGroupCriteria>& criteria)
{ {
criteria_ = criteria; criteria_ = criteria;
} }

View File

@ -44,35 +44,35 @@ namespace aria2 {
#ifdef ENABLE_METALINK #ifdef ENABLE_METALINK
SharedHandle<MemoryBufferPreDownloadHandler> SharedHandle<PreDownloadHandler>
DownloadHandlerFactory::metalinkPreDownloadHandler_; DownloadHandlerFactory::metalinkPreDownloadHandler_;
SharedHandle<MetalinkPostDownloadHandler> SharedHandle<PostDownloadHandler>
DownloadHandlerFactory::metalinkPostDownloadHandler_; DownloadHandlerFactory::metalinkPostDownloadHandler_;
#endif // ENABLE_METALINK #endif // ENABLE_METALINK
#ifdef ENABLE_BITTORRENT #ifdef ENABLE_BITTORRENT
SharedHandle<bittorrent::MemoryBencodePreDownloadHandler> SharedHandle<PreDownloadHandler>
DownloadHandlerFactory::btPreDownloadHandler_; DownloadHandlerFactory::btPreDownloadHandler_;
SharedHandle<BtPostDownloadHandler> SharedHandle<PostDownloadHandler>
DownloadHandlerFactory::btPostDownloadHandler_; DownloadHandlerFactory::btPostDownloadHandler_;
SharedHandle<UTMetadataPostDownloadHandler> SharedHandle<PostDownloadHandler>
DownloadHandlerFactory::btMetadataPostDownloadHandler_; DownloadHandlerFactory::btMetadataPostDownloadHandler_;
#endif // ENABLE_BITTORRENT #endif // ENABLE_BITTORRENT
#ifdef ENABLE_METALINK #ifdef ENABLE_METALINK
SharedHandle<MemoryBufferPreDownloadHandler> SharedHandle<PreDownloadHandler>
DownloadHandlerFactory::getMetalinkPreDownloadHandler() DownloadHandlerFactory::getMetalinkPreDownloadHandler()
{ {
if(!metalinkPreDownloadHandler_) { if(!metalinkPreDownloadHandler_) {
metalinkPreDownloadHandler_.reset(new MemoryBufferPreDownloadHandler()); metalinkPreDownloadHandler_.reset(new MemoryBufferPreDownloadHandler());
RequestGroupCriteriaHandle criteria SharedHandle<RequestGroupCriteria> criteria
(new ContentTypeRequestGroupCriteria (new ContentTypeRequestGroupCriteria
(getMetalinkContentTypes(), getMetalinkExtensions())); (getMetalinkContentTypes(), getMetalinkExtensions()));
metalinkPreDownloadHandler_->setCriteria(criteria); metalinkPreDownloadHandler_->setCriteria(criteria);
@ -80,7 +80,7 @@ DownloadHandlerFactory::getMetalinkPreDownloadHandler()
return metalinkPreDownloadHandler_; return metalinkPreDownloadHandler_;
} }
SharedHandle<MetalinkPostDownloadHandler> SharedHandle<PostDownloadHandler>
DownloadHandlerFactory::getMetalinkPostDownloadHandler() DownloadHandlerFactory::getMetalinkPostDownloadHandler()
{ {
if(!metalinkPostDownloadHandler_) { if(!metalinkPostDownloadHandler_) {
@ -93,14 +93,14 @@ DownloadHandlerFactory::getMetalinkPostDownloadHandler()
#ifdef ENABLE_BITTORRENT #ifdef ENABLE_BITTORRENT
SharedHandle<bittorrent::MemoryBencodePreDownloadHandler> SharedHandle<PreDownloadHandler>
DownloadHandlerFactory::getBtPreDownloadHandler() DownloadHandlerFactory::getBtPreDownloadHandler()
{ {
if(!btPreDownloadHandler_) { if(!btPreDownloadHandler_) {
btPreDownloadHandler_.reset btPreDownloadHandler_.reset
(new bittorrent::MemoryBencodePreDownloadHandler()); (new bittorrent::MemoryBencodePreDownloadHandler());
RequestGroupCriteriaHandle criteria SharedHandle<RequestGroupCriteria> criteria
(new ContentTypeRequestGroupCriteria (new ContentTypeRequestGroupCriteria
(getBtContentTypes(), getBtExtensions())); (getBtContentTypes(), getBtExtensions()));
btPreDownloadHandler_->setCriteria(criteria); btPreDownloadHandler_->setCriteria(criteria);
@ -108,7 +108,7 @@ DownloadHandlerFactory::getBtPreDownloadHandler()
return btPreDownloadHandler_; return btPreDownloadHandler_;
} }
SharedHandle<BtPostDownloadHandler> SharedHandle<PostDownloadHandler>
DownloadHandlerFactory::getBtPostDownloadHandler() DownloadHandlerFactory::getBtPostDownloadHandler()
{ {
if(!btPostDownloadHandler_) { if(!btPostDownloadHandler_) {
@ -117,7 +117,7 @@ DownloadHandlerFactory::getBtPostDownloadHandler()
return btPostDownloadHandler_; return btPostDownloadHandler_;
} }
SharedHandle<UTMetadataPostDownloadHandler> SharedHandle<PostDownloadHandler>
DownloadHandlerFactory::getUTMetadataPostDownloadHandler() DownloadHandlerFactory::getUTMetadataPostDownloadHandler()
{ {
if(!btMetadataPostDownloadHandler_) { if(!btMetadataPostDownloadHandler_) {

View File

@ -56,40 +56,40 @@ class DownloadHandlerFactory
{ {
private: private:
#ifdef ENABLE_METALINK #ifdef ENABLE_METALINK
static SharedHandle<MemoryBufferPreDownloadHandler> static SharedHandle<PreDownloadHandler>
metalinkPreDownloadHandler_; metalinkPreDownloadHandler_;
static SharedHandle<MetalinkPostDownloadHandler> static SharedHandle<PostDownloadHandler>
metalinkPostDownloadHandler_; metalinkPostDownloadHandler_;
#endif // ENABLE_METALINK #endif // ENABLE_METALINK
#ifdef ENABLE_BITTORRENT #ifdef ENABLE_BITTORRENT
static SharedHandle<bittorrent::MemoryBencodePreDownloadHandler> static SharedHandle<PreDownloadHandler>
btPreDownloadHandler_; btPreDownloadHandler_;
static SharedHandle<BtPostDownloadHandler> static SharedHandle<PostDownloadHandler>
btPostDownloadHandler_; btPostDownloadHandler_;
static SharedHandle<UTMetadataPostDownloadHandler> static SharedHandle<PostDownloadHandler>
btMetadataPostDownloadHandler_; btMetadataPostDownloadHandler_;
#endif // ENABLE_BITTORRENT #endif // ENABLE_BITTORRENT
public: public:
#ifdef ENABLE_METALINK #ifdef ENABLE_METALINK
static SharedHandle<MemoryBufferPreDownloadHandler> static SharedHandle<PreDownloadHandler>
getMetalinkPreDownloadHandler(); getMetalinkPreDownloadHandler();
static SharedHandle<MetalinkPostDownloadHandler> static SharedHandle<PostDownloadHandler>
getMetalinkPostDownloadHandler(); getMetalinkPostDownloadHandler();
#endif // ENABLE_METALINK #endif // ENABLE_METALINK
#ifdef ENABLE_BITTORRENT #ifdef ENABLE_BITTORRENT
static SharedHandle<bittorrent::MemoryBencodePreDownloadHandler> static SharedHandle<PreDownloadHandler>
getBtPreDownloadHandler(); getBtPreDownloadHandler();
static SharedHandle<BtPostDownloadHandler> static SharedHandle<PostDownloadHandler>
getBtPostDownloadHandler(); getBtPostDownloadHandler();
static SharedHandle<UTMetadataPostDownloadHandler> static SharedHandle<PostDownloadHandler>
getUTMetadataPostDownloadHandler(); getUTMetadataPostDownloadHandler();
#endif // ENABLE_BITTORRENT #endif // ENABLE_BITTORRENT
}; };

View File

@ -50,8 +50,6 @@ public:
virtual bool match(const RequestGroup* requestGroup) const = 0; virtual bool match(const RequestGroup* requestGroup) const = 0;
}; };
typedef SharedHandle<RequestGroupCriteria> RequestGroupCriteriaHandle;
} // namespace aria2 } // namespace aria2
#endif // D_REQUEST_GROUP_CRITERIA_H #endif // D_REQUEST_GROUP_CRITERIA_H