Code cleanup

This commit is contained in:
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);
}
void DownloadHandler::setCriteria(const RequestGroupCriteriaHandle& criteria)
void DownloadHandler::setCriteria
(const SharedHandle<RequestGroupCriteria>& criteria)
{
criteria_ = criteria;
}

View File

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

View File

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

View File

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