mirror of https://github.com/aria2/aria2
2010-08-31 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Enclosed classes and structs declared in *.cc files unnamed namespace. Added static keyword for function template in *.cc files(TODO we should use unnamed namespace instead of static). * src/AbstractCommand.cc * src/AnnounceList.cc * src/BtLeecherStateChoke.cc * src/BtLeecherStateChoke.h * src/BtSeederStateChoke.cc * src/BtSeederStateChoke.h * src/ConsoleStatCalc.cc * src/ContentTypeRequestGroupCriteria.cc * src/CookieStorage.cc * src/DHTBucket.cc * src/DHTPeerAnnounceEntry.cc * src/DHTPeerAnnounceStorage.cc * src/DefaultBtMessageDispatcher.cc * src/DefaultBtRequestFactory.cc * src/DefaultPeerStorage.cc * src/DefaultPieceStorage.cc * src/ExpatMetalinkProcessor.cc * src/ExpatXmlRpcRequestProcessor.cc * src/FeedbackURISelector.cc * src/FileEntry.cc * src/Metalink2RequestGroup.cc * src/MetalinkEntry.cc * src/Metalinker.cc * src/MultiDiskAdaptor.cc * src/Netrc.cc * src/OptionParser.cc * src/PieceStatMan.cc * src/RarestPieceSelector.cc * src/RequestGroupMan.cc * src/SegmentMan.cc * src/ServerStatMan.cc * src/XML2SAXMetalinkProcessor.cc * src/Xml2XmlRpcRequestProcessor.cc * src/XmlRpcResponse.cc * src/a2algo.h * src/download_helper.ccpull/1/head
parent
492d6e9694
commit
94482144f2
42
ChangeLog
42
ChangeLog
|
@ -1,3 +1,45 @@
|
||||||
|
2010-08-31 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Enclosed classes and structs declared in *.cc files unnamed
|
||||||
|
namespace. Added static keyword for function template in *.cc
|
||||||
|
files(TODO we should use unnamed namespace instead of static).
|
||||||
|
* src/AbstractCommand.cc
|
||||||
|
* src/AnnounceList.cc
|
||||||
|
* src/BtLeecherStateChoke.cc
|
||||||
|
* src/BtLeecherStateChoke.h
|
||||||
|
* src/BtSeederStateChoke.cc
|
||||||
|
* src/BtSeederStateChoke.h
|
||||||
|
* src/ConsoleStatCalc.cc
|
||||||
|
* src/ContentTypeRequestGroupCriteria.cc
|
||||||
|
* src/CookieStorage.cc
|
||||||
|
* src/DHTBucket.cc
|
||||||
|
* src/DHTPeerAnnounceEntry.cc
|
||||||
|
* src/DHTPeerAnnounceStorage.cc
|
||||||
|
* src/DefaultBtMessageDispatcher.cc
|
||||||
|
* src/DefaultBtRequestFactory.cc
|
||||||
|
* src/DefaultPeerStorage.cc
|
||||||
|
* src/DefaultPieceStorage.cc
|
||||||
|
* src/ExpatMetalinkProcessor.cc
|
||||||
|
* src/ExpatXmlRpcRequestProcessor.cc
|
||||||
|
* src/FeedbackURISelector.cc
|
||||||
|
* src/FileEntry.cc
|
||||||
|
* src/Metalink2RequestGroup.cc
|
||||||
|
* src/MetalinkEntry.cc
|
||||||
|
* src/Metalinker.cc
|
||||||
|
* src/MultiDiskAdaptor.cc
|
||||||
|
* src/Netrc.cc
|
||||||
|
* src/OptionParser.cc
|
||||||
|
* src/PieceStatMan.cc
|
||||||
|
* src/RarestPieceSelector.cc
|
||||||
|
* src/RequestGroupMan.cc
|
||||||
|
* src/SegmentMan.cc
|
||||||
|
* src/ServerStatMan.cc
|
||||||
|
* src/XML2SAXMetalinkProcessor.cc
|
||||||
|
* src/Xml2XmlRpcRequestProcessor.cc
|
||||||
|
* src/XmlRpcResponse.cc
|
||||||
|
* src/a2algo.h
|
||||||
|
* src/download_helper.cc
|
||||||
|
|
||||||
2010-08-31 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2010-08-31 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Updated doc
|
Updated doc
|
||||||
|
|
|
@ -542,6 +542,7 @@ static bool isProxyRequest
|
||||||
return !proxyUri.empty() && Request().setUri(proxyUri);
|
return !proxyUri.empty() && Request().setUri(proxyUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class DomainMatch {
|
class DomainMatch {
|
||||||
private:
|
private:
|
||||||
std::string hostname_;
|
std::string hostname_;
|
||||||
|
@ -557,6 +558,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static bool inNoProxy(const SharedHandle<Request>& req,
|
static bool inNoProxy(const SharedHandle<Request>& req,
|
||||||
const std::string& noProxy)
|
const std::string& noProxy)
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "A2STR.h"
|
#include "A2STR.h"
|
||||||
#include "SimpleRandomizer.h"
|
#include "SimpleRandomizer.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "a2algo.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -159,6 +160,7 @@ std::string AnnounceList::getEventString() const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class FindStoppedAllowedTier {
|
class FindStoppedAllowedTier {
|
||||||
public:
|
public:
|
||||||
bool operator()(const SharedHandle<AnnounceTier>& tier) const {
|
bool operator()(const SharedHandle<AnnounceTier>& tier) const {
|
||||||
|
@ -173,7 +175,9 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class FindCompletedAllowedTier {
|
class FindCompletedAllowedTier {
|
||||||
public:
|
public:
|
||||||
bool operator()(const SharedHandle<AnnounceTier>& tier) const {
|
bool operator()(const SharedHandle<AnnounceTier>& tier) const {
|
||||||
|
@ -186,6 +190,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
size_t AnnounceList::countStoppedAllowedTier() const {
|
size_t AnnounceList::countStoppedAllowedTier() const {
|
||||||
return count_if(tiers_.begin(), tiers_.end(), FindStoppedAllowedTier());
|
return count_if(tiers_.begin(), tiers_.end(), FindStoppedAllowedTier());
|
||||||
|
@ -203,17 +208,6 @@ void AnnounceList::setCurrentTier
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class InputIterator, class Predicate>
|
|
||||||
InputIterator
|
|
||||||
find_wrap_if(InputIterator first, InputIterator last,
|
|
||||||
InputIterator current, Predicate pred) {
|
|
||||||
InputIterator itr = std::find_if(current, last, pred);
|
|
||||||
if(itr == last) {
|
|
||||||
itr = std::find_if(first, current, pred);
|
|
||||||
}
|
|
||||||
return itr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AnnounceList::moveToStoppedAllowedTier() {
|
void AnnounceList::moveToStoppedAllowedTier() {
|
||||||
std::deque<SharedHandle<AnnounceTier> >::iterator itr =
|
std::deque<SharedHandle<AnnounceTier> >::iterator itr =
|
||||||
find_wrap_if(tiers_.begin(), tiers_.end(),
|
find_wrap_if(tiers_.begin(), tiers_.end(),
|
||||||
|
|
|
@ -103,21 +103,12 @@ bool BtLeecherStateChoke::PeerEntry::operator<(const PeerEntry& peerEntry) const
|
||||||
return downloadSpeed_ > peerEntry.downloadSpeed_;
|
return downloadSpeed_ > peerEntry.downloadSpeed_;
|
||||||
}
|
}
|
||||||
|
|
||||||
class PeerFilter {
|
bool BtLeecherStateChoke::PeerFilter::operator()
|
||||||
private:
|
(const PeerEntry& peerEntry) const
|
||||||
bool amChoking_;
|
{
|
||||||
bool peerInterested_;
|
return peerEntry.getPeer()->amChoking() == amChoking_ &&
|
||||||
public:
|
peerEntry.getPeer()->peerInterested() == peerInterested_;
|
||||||
PeerFilter(bool amChoking, bool peerInterested):
|
}
|
||||||
amChoking_(amChoking),
|
|
||||||
peerInterested_(peerInterested) {}
|
|
||||||
|
|
||||||
bool operator()(const BtLeecherStateChoke::PeerEntry& peerEntry) const
|
|
||||||
{
|
|
||||||
return peerEntry.getPeer()->amChoking() == amChoking_ &&
|
|
||||||
peerEntry.getPeer()->peerInterested() == peerInterested_;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void BtLeecherStateChoke::plannedOptimisticUnchoke
|
void BtLeecherStateChoke::plannedOptimisticUnchoke
|
||||||
(std::vector<PeerEntry>& peerEntries)
|
(std::vector<PeerEntry>& peerEntries)
|
||||||
|
@ -177,15 +168,6 @@ void BtLeecherStateChoke::regularUnchoke(std::vector<PeerEntry>& peerEntries)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class BtLeecherStateChokeGenPeerEntry {
|
|
||||||
public:
|
|
||||||
BtLeecherStateChoke::PeerEntry operator()
|
|
||||||
(const SharedHandle<Peer>& peer) const
|
|
||||||
{
|
|
||||||
return BtLeecherStateChoke::PeerEntry(peer);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BtLeecherStateChoke::executeChoke
|
BtLeecherStateChoke::executeChoke
|
||||||
(const std::vector<SharedHandle<Peer> >& peerSet)
|
(const std::vector<SharedHandle<Peer> >& peerSet)
|
||||||
|
|
|
@ -86,8 +86,25 @@ private:
|
||||||
|
|
||||||
void regularUnchoke(std::vector<PeerEntry>& peerEntries);
|
void regularUnchoke(std::vector<PeerEntry>& peerEntries);
|
||||||
|
|
||||||
friend class PeerFilter;
|
class PeerFilter {
|
||||||
friend class BtLeecherStateChokeGenPeerEntry;
|
private:
|
||||||
|
bool amChoking_;
|
||||||
|
bool peerInterested_;
|
||||||
|
public:
|
||||||
|
PeerFilter(bool amChoking, bool peerInterested):
|
||||||
|
amChoking_(amChoking),
|
||||||
|
peerInterested_(peerInterested) {}
|
||||||
|
|
||||||
|
bool operator()(const PeerEntry& peerEntry) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
class BtLeecherStateChokeGenPeerEntry {
|
||||||
|
public:
|
||||||
|
PeerEntry operator()(const SharedHandle<Peer>& peer) const
|
||||||
|
{
|
||||||
|
return PeerEntry(peer);
|
||||||
|
}
|
||||||
|
};
|
||||||
public:
|
public:
|
||||||
BtLeecherStateChoke();
|
BtLeecherStateChoke();
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,12 @@ void BtSeederStateChoke::PeerEntry::disableOptUnchoking()
|
||||||
peer_->optUnchoking(false);
|
peer_->optUnchoking(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BtSeederStateChoke::NotInterestedPeer::operator()
|
||||||
|
(const PeerEntry& peerEntry) const
|
||||||
|
{
|
||||||
|
return !peerEntry.getPeer()->peerInterested();
|
||||||
|
}
|
||||||
|
|
||||||
void BtSeederStateChoke::unchoke
|
void BtSeederStateChoke::unchoke
|
||||||
(std::vector<BtSeederStateChoke::PeerEntry>& peers)
|
(std::vector<BtSeederStateChoke::PeerEntry>& peers)
|
||||||
{
|
{
|
||||||
|
@ -110,6 +116,7 @@ void BtSeederStateChoke::unchoke
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class ChokingRequired {
|
class ChokingRequired {
|
||||||
public:
|
public:
|
||||||
void operator()(const SharedHandle<Peer>& peer) const
|
void operator()(const SharedHandle<Peer>& peer) const
|
||||||
|
@ -117,22 +124,7 @@ public:
|
||||||
peer->chokingRequired(true);
|
peer->chokingRequired(true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
class GenPeerEntry {
|
|
||||||
public:
|
|
||||||
BtSeederStateChoke::PeerEntry operator()(const SharedHandle<Peer>& peer) const
|
|
||||||
{
|
|
||||||
return BtSeederStateChoke::PeerEntry(peer);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class NotInterestedPeer {
|
|
||||||
public:
|
|
||||||
bool operator()(const BtSeederStateChoke::PeerEntry& peerEntry) const
|
|
||||||
{
|
|
||||||
return !peerEntry.getPeer()->peerInterested();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BtSeederStateChoke::executeChoke
|
BtSeederStateChoke::executeChoke
|
||||||
|
|
|
@ -78,8 +78,18 @@ private:
|
||||||
|
|
||||||
void unchoke(std::vector<PeerEntry>& peers);
|
void unchoke(std::vector<PeerEntry>& peers);
|
||||||
|
|
||||||
friend class GenPeerEntry;
|
class GenPeerEntry {
|
||||||
friend class NotInterestedPeer;
|
public:
|
||||||
|
PeerEntry operator()(const SharedHandle<Peer>& peer) const
|
||||||
|
{
|
||||||
|
return PeerEntry(peer);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class NotInterestedPeer {
|
||||||
|
public:
|
||||||
|
bool operator()(const PeerEntry& peerEntry) const;
|
||||||
|
};
|
||||||
public:
|
public:
|
||||||
BtSeederStateChoke();
|
BtSeederStateChoke();
|
||||||
|
|
||||||
|
|
|
@ -147,6 +147,7 @@ static void printProgress
|
||||||
o << "]";
|
o << "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class PrintSummary
|
class PrintSummary
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -173,6 +174,7 @@ public:
|
||||||
<< std::setfill(SEP_CHAR) << std::setw(cols_) << SEP_CHAR << "\n";
|
<< std::setfill(SEP_CHAR) << std::setw(cols_) << SEP_CHAR << "\n";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static void printProgressSummary
|
static void printProgressSummary
|
||||||
(const std::deque<SharedHandle<RequestGroup> >& groups, size_t cols,
|
(const std::deque<SharedHandle<RequestGroup> >& groups, size_t cols,
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
template<typename InputIterator>
|
template<typename InputIterator>
|
||||||
bool tailMatch
|
static bool tailMatch
|
||||||
(InputIterator first, InputIterator last, const std::string& target)
|
(InputIterator first, InputIterator last, const std::string& target)
|
||||||
{
|
{
|
||||||
for(; first != last; ++first) {
|
for(; first != last; ++first) {
|
||||||
|
|
|
@ -164,6 +164,7 @@ struct CookiePathDivider {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace {
|
||||||
class CookiePathDividerConverter {
|
class CookiePathDividerConverter {
|
||||||
public:
|
public:
|
||||||
CookiePathDivider operator()(const Cookie& cookie) const
|
CookiePathDivider operator()(const Cookie& cookie) const
|
||||||
|
@ -176,7 +177,9 @@ public:
|
||||||
return cookiePathDivider.cookie_;
|
return cookiePathDivider.cookie_;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class OrderByPathDepthDesc:public std::binary_function<Cookie, Cookie, bool> {
|
class OrderByPathDepthDesc:public std::binary_function<Cookie, Cookie, bool> {
|
||||||
public:
|
public:
|
||||||
bool operator()
|
bool operator()
|
||||||
|
@ -203,6 +206,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
template<typename DomainInputIterator, typename CookieOutputIterator>
|
template<typename DomainInputIterator, typename CookieOutputIterator>
|
||||||
static void searchCookieByDomainSuffix
|
static void searchCookieByDomainSuffix
|
||||||
|
|
|
@ -258,6 +258,7 @@ void DHTBucket::notifyUpdate()
|
||||||
lastUpdated_ = global::wallclock;
|
lastUpdated_ = global::wallclock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class FindQuestionableNode {
|
class FindQuestionableNode {
|
||||||
public:
|
public:
|
||||||
bool operator()(const SharedHandle<DHTNode>& node) const
|
bool operator()(const SharedHandle<DHTNode>& node) const
|
||||||
|
@ -265,6 +266,7 @@ public:
|
||||||
return node->isQuestionable();
|
return node->isQuestionable();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
bool DHTBucket::containsQuestionableNode() const
|
bool DHTBucket::containsQuestionableNode() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -66,6 +66,7 @@ size_t DHTPeerAnnounceEntry::countPeerAddrEntry() const
|
||||||
return peerAddrEntries_.size();
|
return peerAddrEntries_.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class FindStaleEntry {
|
class FindStaleEntry {
|
||||||
private:
|
private:
|
||||||
time_t timeout_;
|
time_t timeout_;
|
||||||
|
@ -81,6 +82,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void DHTPeerAnnounceEntry::removeStalePeerAddrEntry(time_t timeout)
|
void DHTPeerAnnounceEntry::removeStalePeerAddrEntry(time_t timeout)
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,6 +56,7 @@ DHTPeerAnnounceStorage::DHTPeerAnnounceStorage():
|
||||||
|
|
||||||
DHTPeerAnnounceStorage::~DHTPeerAnnounceStorage() {}
|
DHTPeerAnnounceStorage::~DHTPeerAnnounceStorage() {}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class InfoHashLess
|
class InfoHashLess
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -65,6 +66,7 @@ public:
|
||||||
return memcmp(lhs->getInfoHash(), rhs->getInfoHash(), DHT_ID_LENGTH) < 0;
|
return memcmp(lhs->getInfoHash(), rhs->getInfoHash(), DHT_ID_LENGTH) < 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
SharedHandle<DHTPeerAnnounceEntry>
|
SharedHandle<DHTPeerAnnounceEntry>
|
||||||
DHTPeerAnnounceStorage::getPeerAnnounceEntry(const unsigned char* infoHash)
|
DHTPeerAnnounceStorage::getPeerAnnounceEntry(const unsigned char* infoHash)
|
||||||
|
@ -116,6 +118,7 @@ void DHTPeerAnnounceStorage::getPeers(std::vector<SharedHandle<Peer> >& peers,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class RemoveStalePeerAddrEntry
|
class RemoveStalePeerAddrEntry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -124,6 +127,7 @@ public:
|
||||||
e->removeStalePeerAddrEntry(DHT_PEER_ANNOUNCE_PURGE_INTERVAL);
|
e->removeStalePeerAddrEntry(DHT_PEER_ANNOUNCE_PURGE_INTERVAL);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void DHTPeerAnnounceStorage::handleTimeout()
|
void DHTPeerAnnounceStorage::handleTimeout()
|
||||||
{
|
{
|
||||||
|
|
|
@ -140,6 +140,7 @@ void DefaultBtMessageDispatcher::doCancelSendingPieceAction
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class AbortOutstandingRequest {
|
class AbortOutstandingRequest {
|
||||||
private:
|
private:
|
||||||
SharedHandle<Piece> piece_;
|
SharedHandle<Piece> piece_;
|
||||||
|
@ -163,6 +164,7 @@ public:
|
||||||
piece_->cancelBlock(slot.getBlockIndex());
|
piece_->cancelBlock(slot.getBlockIndex());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// localhost cancels outstanding download requests to the peer.
|
// localhost cancels outstanding download requests to the peer.
|
||||||
void DefaultBtMessageDispatcher::doAbortOutstandingRequestAction
|
void DefaultBtMessageDispatcher::doAbortOutstandingRequestAction
|
||||||
|
@ -186,6 +188,7 @@ void DefaultBtMessageDispatcher::doAbortOutstandingRequestAction
|
||||||
&BtMessage::onAbortOutstandingRequestEvent, event);
|
&BtMessage::onAbortOutstandingRequestEvent, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class ProcessChokedRequestSlot {
|
class ProcessChokedRequestSlot {
|
||||||
private:
|
private:
|
||||||
cuid_t cuid_;
|
cuid_t cuid_;
|
||||||
|
@ -217,7 +220,9 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class FindChokedRequestSlot {
|
class FindChokedRequestSlot {
|
||||||
private:
|
private:
|
||||||
SharedHandle<Peer> peer_;
|
SharedHandle<Peer> peer_;
|
||||||
|
@ -230,6 +235,7 @@ public:
|
||||||
return !peer_->isInPeerAllowedIndexSet(slot.getIndex());
|
return !peer_->isInPeerAllowedIndexSet(slot.getIndex());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// localhost received choke message from the peer.
|
// localhost received choke message from the peer.
|
||||||
void DefaultBtMessageDispatcher::doChokedAction()
|
void DefaultBtMessageDispatcher::doChokedAction()
|
||||||
|
@ -253,6 +259,7 @@ void DefaultBtMessageDispatcher::doChokingAction()
|
||||||
&BtMessage::onChokingEvent, event);
|
&BtMessage::onChokingEvent, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class ProcessStaleRequestSlot {
|
class ProcessStaleRequestSlot {
|
||||||
private:
|
private:
|
||||||
cuid_t cuid_;
|
cuid_t cuid_;
|
||||||
|
@ -301,7 +308,9 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class FindStaleRequestSlot {
|
class FindStaleRequestSlot {
|
||||||
private:
|
private:
|
||||||
SharedHandle<PieceStorage> pieceStorage_;
|
SharedHandle<PieceStorage> pieceStorage_;
|
||||||
|
@ -325,6 +334,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void DefaultBtMessageDispatcher::checkRequestSlotAndDoNecessaryThing()
|
void DefaultBtMessageDispatcher::checkRequestSlotAndDoNecessaryThing()
|
||||||
{
|
{
|
||||||
|
@ -350,6 +360,7 @@ bool DefaultBtMessageDispatcher::isSendingInProgress()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class BlockIndexLess {
|
class BlockIndexLess {
|
||||||
public:
|
public:
|
||||||
bool operator()(const RequestSlot& lhs, const RequestSlot& rhs) const
|
bool operator()(const RequestSlot& lhs, const RequestSlot& rhs) const
|
||||||
|
@ -361,6 +372,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
bool DefaultBtMessageDispatcher::isOutstandingRequest
|
bool DefaultBtMessageDispatcher::isOutstandingRequest
|
||||||
(size_t index, size_t blockIndex) {
|
(size_t index, size_t blockIndex) {
|
||||||
|
|
|
@ -70,6 +70,7 @@ void DefaultBtRequestFactory::addTargetPiece(const SharedHandle<Piece>& piece)
|
||||||
pieces_.push_back(piece);
|
pieces_.push_back(piece);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class AbortCompletedPieceRequest
|
class AbortCompletedPieceRequest
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -85,6 +86,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void DefaultBtRequestFactory::removeCompletedPiece() {
|
void DefaultBtRequestFactory::removeCompletedPiece() {
|
||||||
std::for_each(pieces_.begin(), pieces_.end(),
|
std::for_each(pieces_.begin(), pieces_.end(),
|
||||||
|
@ -103,6 +105,7 @@ void DefaultBtRequestFactory::removeTargetPiece
|
||||||
pieceStorage_->cancelPiece(piece);
|
pieceStorage_->cancelPiece(piece);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class ProcessChokedPiece {
|
class ProcessChokedPiece {
|
||||||
private:
|
private:
|
||||||
SharedHandle<Peer> peer_;
|
SharedHandle<Peer> peer_;
|
||||||
|
@ -120,7 +123,9 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class FindChokedPiece {
|
class FindChokedPiece {
|
||||||
private:
|
private:
|
||||||
SharedHandle<Peer> peer_;
|
SharedHandle<Peer> peer_;
|
||||||
|
@ -132,6 +137,7 @@ public:
|
||||||
return !peer_->isInPeerAllowedIndexSet(piece->getIndex());
|
return !peer_->isInPeerAllowedIndexSet(piece->getIndex());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void DefaultBtRequestFactory::doChokedAction()
|
void DefaultBtRequestFactory::doChokedAction()
|
||||||
{
|
{
|
||||||
|
@ -226,6 +232,7 @@ void DefaultBtRequestFactory::createRequestMessagesOnEndGame
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class CountMissingBlock
|
class CountMissingBlock
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -243,6 +250,7 @@ public:
|
||||||
numMissingBlock_ += piece->countMissingBlock();
|
numMissingBlock_ += piece->countMissingBlock();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
size_t DefaultBtRequestFactory::countMissingBlock()
|
size_t DefaultBtRequestFactory::countMissingBlock()
|
||||||
{
|
{
|
||||||
|
|
|
@ -65,6 +65,7 @@ DefaultPeerStorage::~DefaultPeerStorage()
|
||||||
delete leecherStateChoke_;
|
delete leecherStateChoke_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class FindIdenticalPeer {
|
class FindIdenticalPeer {
|
||||||
private:
|
private:
|
||||||
SharedHandle<Peer> peer_;
|
SharedHandle<Peer> peer_;
|
||||||
|
@ -77,6 +78,7 @@ public:
|
||||||
(peer_->getPort() == peer->getPort()));
|
(peer_->getPort() == peer->getPort()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
bool DefaultPeerStorage::isPeerAlreadyAdded(const SharedHandle<Peer>& peer)
|
bool DefaultPeerStorage::isPeerAlreadyAdded(const SharedHandle<Peer>& peer)
|
||||||
{
|
{
|
||||||
|
@ -142,12 +144,14 @@ const std::deque<SharedHandle<Peer> >& DefaultPeerStorage::getDroppedPeers()
|
||||||
return droppedPeers_;
|
return droppedPeers_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class FindFinePeer {
|
class FindFinePeer {
|
||||||
public:
|
public:
|
||||||
bool operator()(const SharedHandle<Peer>& peer) const {
|
bool operator()(const SharedHandle<Peer>& peer) const {
|
||||||
return peer->unused() && peer->isGood();
|
return peer->unused() && peer->isGood();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
SharedHandle<Peer> DefaultPeerStorage::getUnusedPeer() {
|
SharedHandle<Peer> DefaultPeerStorage::getUnusedPeer() {
|
||||||
std::deque<SharedHandle<Peer> >::const_iterator itr =
|
std::deque<SharedHandle<Peer> >::const_iterator itr =
|
||||||
|
@ -159,6 +163,7 @@ SharedHandle<Peer> DefaultPeerStorage::getUnusedPeer() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class FindPeer {
|
class FindPeer {
|
||||||
private:
|
private:
|
||||||
std::string ipaddr;
|
std::string ipaddr;
|
||||||
|
@ -171,6 +176,7 @@ public:
|
||||||
return ipaddr == peer->getIPAddress() && port == peer->getPort();
|
return ipaddr == peer->getIPAddress() && port == peer->getPort();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
SharedHandle<Peer> DefaultPeerStorage::getPeer(const std::string& ipaddr,
|
SharedHandle<Peer> DefaultPeerStorage::getPeer(const std::string& ipaddr,
|
||||||
uint16_t port) const {
|
uint16_t port) const {
|
||||||
|
@ -191,6 +197,7 @@ bool DefaultPeerStorage::isPeerAvailable() {
|
||||||
return !getUnusedPeer().isNull();
|
return !getUnusedPeer().isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class CollectActivePeer {
|
class CollectActivePeer {
|
||||||
private:
|
private:
|
||||||
std::vector<SharedHandle<Peer> >& activePeers_;
|
std::vector<SharedHandle<Peer> >& activePeers_;
|
||||||
|
@ -205,6 +212,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void DefaultPeerStorage::getActivePeers
|
void DefaultPeerStorage::getActivePeers
|
||||||
(std::vector<SharedHandle<Peer> >& activePeers)
|
(std::vector<SharedHandle<Peer> >& activePeers)
|
||||||
|
|
|
@ -643,6 +643,7 @@ DefaultPieceStorage::getAdvertisedPieceIndexes(std::vector<size_t>& indexes,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class FindElapsedHave
|
class FindElapsedHave
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -658,7 +659,8 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void DefaultPieceStorage::removeAdvertisedPiece(time_t elapsed)
|
void DefaultPieceStorage::removeAdvertisedPiece(time_t elapsed)
|
||||||
{
|
{
|
||||||
std::deque<HaveEntry>::iterator itr =
|
std::deque<HaveEntry>::iterator itr =
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
namespace {
|
||||||
class SessionData {
|
class SessionData {
|
||||||
public:
|
public:
|
||||||
SharedHandle<MetalinkParserStateMachine> stm_;
|
SharedHandle<MetalinkParserStateMachine> stm_;
|
||||||
|
@ -57,6 +58,7 @@ public:
|
||||||
|
|
||||||
SessionData(const SharedHandle<MetalinkParserStateMachine>& stm):stm_(stm) {}
|
SessionData(const SharedHandle<MetalinkParserStateMachine>& stm):stm_(stm) {}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static void splitNsName
|
static void splitNsName
|
||||||
(std::string& localname, std::string& prefix, std::string& nsUri,
|
(std::string& localname, std::string& prefix, std::string& nsUri,
|
||||||
|
|
|
@ -47,6 +47,7 @@ namespace aria2 {
|
||||||
|
|
||||||
namespace xmlrpc {
|
namespace xmlrpc {
|
||||||
|
|
||||||
|
namespace {
|
||||||
struct SessionData {
|
struct SessionData {
|
||||||
XmlRpcRequestParserStateMachine* stm_;
|
XmlRpcRequestParserStateMachine* stm_;
|
||||||
|
|
||||||
|
@ -54,6 +55,7 @@ struct SessionData {
|
||||||
|
|
||||||
SessionData(XmlRpcRequestParserStateMachine* stm):stm_(stm) {}
|
SessionData(XmlRpcRequestParserStateMachine* stm):stm_(stm) {}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static void mlStartElement(void* userData, const char* name, const char** attrs)
|
static void mlStartElement(void* userData, const char* name, const char** attrs)
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,6 +55,7 @@ FeedbackURISelector::FeedbackURISelector
|
||||||
|
|
||||||
FeedbackURISelector::~FeedbackURISelector() {}
|
FeedbackURISelector::~FeedbackURISelector() {}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class ServerStatFaster {
|
class ServerStatFaster {
|
||||||
public:
|
public:
|
||||||
bool operator()(const std::pair<SharedHandle<ServerStat>, std::string> lhs,
|
bool operator()(const std::pair<SharedHandle<ServerStat>, std::string> lhs,
|
||||||
|
@ -64,6 +65,7 @@ public:
|
||||||
return lhs.first->getDownloadSpeed() > rhs.first->getDownloadSpeed();
|
return lhs.first->getDownloadSpeed() > rhs.first->getDownloadSpeed();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
std::string FeedbackURISelector::select
|
std::string FeedbackURISelector::select
|
||||||
(FileEntry* fileEntry,
|
(FileEntry* fileEntry,
|
||||||
|
|
|
@ -203,6 +203,7 @@ FileEntry::findFasterRequest(const SharedHandle<Request>& base)
|
||||||
return SharedHandle<Request>();
|
return SharedHandle<Request>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class RequestFaster {
|
class RequestFaster {
|
||||||
public:
|
public:
|
||||||
bool operator()(const SharedHandle<Request>& lhs,
|
bool operator()(const SharedHandle<Request>& lhs,
|
||||||
|
@ -218,6 +219,7 @@ public:
|
||||||
lhs->getPeerStat()->getAvgDownloadSpeed() > rhs->getPeerStat()->getAvgDownloadSpeed();
|
lhs->getPeerStat()->getAvgDownloadSpeed() > rhs->getPeerStat()->getAvgDownloadSpeed();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void FileEntry::storePool(const SharedHandle<Request>& request)
|
void FileEntry::storePool(const SharedHandle<Request>& request)
|
||||||
{
|
{
|
||||||
|
@ -282,6 +284,7 @@ void FileEntry::addURIResult(std::string uri, downloadresultcode::RESULT result)
|
||||||
uriResults_.push_back(URIResult(uri, result));
|
uriResults_.push_back(URIResult(uri, result));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class FindURIResultByResult {
|
class FindURIResultByResult {
|
||||||
private:
|
private:
|
||||||
downloadresultcode::RESULT r_;
|
downloadresultcode::RESULT r_;
|
||||||
|
@ -293,6 +296,7 @@ public:
|
||||||
return uriResult.getResult() == r_;
|
return uriResult.getResult() == r_;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void FileEntry::extractURIResult
|
void FileEntry::extractURIResult
|
||||||
(std::deque<URIResult>& res, downloadresultcode::RESULT r)
|
(std::deque<URIResult>& res, downloadresultcode::RESULT r)
|
||||||
|
|
|
@ -69,6 +69,7 @@ namespace aria2 {
|
||||||
Metalink2RequestGroup::Metalink2RequestGroup():
|
Metalink2RequestGroup::Metalink2RequestGroup():
|
||||||
logger_(LogFactory::getInstance()) {}
|
logger_(LogFactory::getInstance()) {}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class AccumulateNonP2PUri {
|
class AccumulateNonP2PUri {
|
||||||
private:
|
private:
|
||||||
std::vector<std::string>& urisPtr;
|
std::vector<std::string>& urisPtr;
|
||||||
|
@ -88,7 +89,9 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class FindBitTorrentUri {
|
class FindBitTorrentUri {
|
||||||
public:
|
public:
|
||||||
FindBitTorrentUri() {}
|
FindBitTorrentUri() {}
|
||||||
|
@ -101,6 +104,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Metalink2RequestGroup::generate
|
Metalink2RequestGroup::generate
|
||||||
|
|
|
@ -57,6 +57,7 @@ MetalinkEntry::MetalinkEntry():
|
||||||
|
|
||||||
MetalinkEntry::~MetalinkEntry() {}
|
MetalinkEntry::~MetalinkEntry() {}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class AddLocationPriority {
|
class AddLocationPriority {
|
||||||
private:
|
private:
|
||||||
std::vector<std::string> locations_;
|
std::vector<std::string> locations_;
|
||||||
|
@ -76,6 +77,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
MetalinkEntry& MetalinkEntry::operator=(const MetalinkEntry& metalinkEntry)
|
MetalinkEntry& MetalinkEntry::operator=(const MetalinkEntry& metalinkEntry)
|
||||||
{
|
{
|
||||||
|
@ -111,6 +113,7 @@ void MetalinkEntry::setLocationPriority
|
||||||
AddLocationPriority(locations, priorityToAdd));
|
AddLocationPriority(locations, priorityToAdd));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class AddProtocolPriority {
|
class AddProtocolPriority {
|
||||||
private:
|
private:
|
||||||
std::string protocol_;
|
std::string protocol_;
|
||||||
|
@ -126,6 +129,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void MetalinkEntry::setProtocolPriority(const std::string& protocol,
|
void MetalinkEntry::setProtocolPriority(const std::string& protocol,
|
||||||
int priorityToAdd)
|
int priorityToAdd)
|
||||||
|
@ -134,6 +138,7 @@ void MetalinkEntry::setProtocolPriority(const std::string& protocol,
|
||||||
AddProtocolPriority(protocol, priorityToAdd));
|
AddProtocolPriority(protocol, priorityToAdd));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class PriorityHigher {
|
class PriorityHigher {
|
||||||
public:
|
public:
|
||||||
|
@ -143,6 +148,7 @@ public:
|
||||||
return res1->priority < res2->priority;
|
return res1->priority < res2->priority;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void MetalinkEntry::reorderResourcesByPriority() {
|
void MetalinkEntry::reorderResourcesByPriority() {
|
||||||
std::random_shuffle(resources.begin(), resources.end(),
|
std::random_shuffle(resources.begin(), resources.end(),
|
||||||
|
@ -156,6 +162,7 @@ void MetalinkEntry::reorderMetaurlsByPriority()
|
||||||
std::sort(metaurls.begin(), metaurls.end(),PriorityHigher<MetalinkMetaurl>());
|
std::sort(metaurls.begin(), metaurls.end(),PriorityHigher<MetalinkMetaurl>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class Supported:public std::unary_function<SharedHandle<MetalinkResource>, bool> {
|
class Supported:public std::unary_function<SharedHandle<MetalinkResource>, bool> {
|
||||||
public:
|
public:
|
||||||
bool operator()(const SharedHandle<MetalinkResource>& res) const
|
bool operator()(const SharedHandle<MetalinkResource>& res) const
|
||||||
|
@ -175,6 +182,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void MetalinkEntry::dropUnsupportedResource() {
|
void MetalinkEntry::dropUnsupportedResource() {
|
||||||
resources.erase(std::remove_if(resources.begin(), resources.end(),
|
resources.erase(std::remove_if(resources.begin(), resources.end(),
|
||||||
|
|
|
@ -42,6 +42,7 @@ Metalinker::Metalinker() {}
|
||||||
|
|
||||||
Metalinker::~Metalinker() {}
|
Metalinker::~Metalinker() {}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class EntryQuery:
|
class EntryQuery:
|
||||||
public std::unary_function<SharedHandle<MetalinkEntry>, bool> {
|
public std::unary_function<SharedHandle<MetalinkEntry>, bool> {
|
||||||
private:
|
private:
|
||||||
|
@ -75,6 +76,7 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void Metalinker::queryEntry
|
void Metalinker::queryEntry
|
||||||
(std::vector<SharedHandle<MetalinkEntry> >& queryResult,
|
(std::vector<SharedHandle<MetalinkEntry> >& queryResult,
|
||||||
|
|
|
@ -351,6 +351,7 @@ static size_t calculateLength(const DiskWriterEntryHandle entry,
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class OffsetCompare {
|
class OffsetCompare {
|
||||||
public:
|
public:
|
||||||
bool operator()(off_t offset, const SharedHandle<DiskWriterEntry>& dwe)
|
bool operator()(off_t offset, const SharedHandle<DiskWriterEntry>& dwe)
|
||||||
|
@ -358,6 +359,7 @@ public:
|
||||||
return offset < dwe->getFileEntry()->getOffset();
|
return offset < dwe->getFileEntry()->getOffset();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static DiskWriterEntries::const_iterator
|
static DiskWriterEntries::const_iterator
|
||||||
findFirstDiskWriterEntry
|
findFirstDiskWriterEntry
|
||||||
|
|
|
@ -150,6 +150,7 @@ void Netrc::storeAuthenticator(const SharedHandle<Authenticator>& authenticator)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class AuthHostMatch {
|
class AuthHostMatch {
|
||||||
private:
|
private:
|
||||||
std::string hostname;
|
std::string hostname;
|
||||||
|
@ -161,6 +162,7 @@ public:
|
||||||
return authenticator->match(hostname);
|
return authenticator->match(hostname);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
SharedHandle<Authenticator>
|
SharedHandle<Authenticator>
|
||||||
Netrc::findAuthenticator(const std::string& hostname) const
|
Netrc::findAuthenticator(const std::string& hostname) const
|
||||||
|
|
|
@ -178,6 +178,7 @@ void OptionParser::parse(Option& option, std::istream& is)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class DummyOptionHandler:public NameMatchOptionHandler {
|
class DummyOptionHandler:public NameMatchOptionHandler {
|
||||||
protected:
|
protected:
|
||||||
virtual void parseArg(Option& option, const std::string& arg) {}
|
virtual void parseArg(Option& option, const std::string& arg) {}
|
||||||
|
@ -189,6 +190,7 @@ public:
|
||||||
return A2STR::NIL;
|
return A2STR::NIL;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
OptionHandlerHandle OptionParser::getOptionHandlerByName
|
OptionHandlerHandle OptionParser::getOptionHandlerByName
|
||||||
(const std::string& optName)
|
(const std::string& optName)
|
||||||
|
@ -239,6 +241,7 @@ void OptionParser::parseDefaultValues(Option& option) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class FindOptionHandlerByTag :
|
class FindOptionHandlerByTag :
|
||||||
public std::unary_function<SharedHandle<OptionHandler>, bool> {
|
public std::unary_function<SharedHandle<OptionHandler>, bool> {
|
||||||
private:
|
private:
|
||||||
|
@ -251,6 +254,7 @@ public:
|
||||||
return !optionHandler->isHidden() && optionHandler->hasTag(tag_);
|
return !optionHandler->isHidden() && optionHandler->hasTag(tag_);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<SharedHandle<OptionHandler> >
|
std::vector<SharedHandle<OptionHandler> >
|
||||||
OptionParser::findByTag(const std::string& tag) const
|
OptionParser::findByTag(const std::string& tag) const
|
||||||
|
@ -263,6 +267,7 @@ OptionParser::findByTag(const std::string& tag) const
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class FindOptionHandlerByNameSubstring :
|
class FindOptionHandlerByNameSubstring :
|
||||||
public std::unary_function<SharedHandle<OptionHandler> , bool> {
|
public std::unary_function<SharedHandle<OptionHandler> , bool> {
|
||||||
private:
|
private:
|
||||||
|
@ -277,6 +282,7 @@ public:
|
||||||
optionHandler->getName().find(substring_) != std::string::npos;
|
optionHandler->getName().find(substring_) != std::string::npos;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<SharedHandle<OptionHandler> >
|
std::vector<SharedHandle<OptionHandler> >
|
||||||
OptionParser::findByNameSubstring(const std::string& substring) const
|
OptionParser::findByNameSubstring(const std::string& substring) const
|
||||||
|
@ -327,6 +333,7 @@ OptionParser::findByName(const std::string& name) const
|
||||||
return handler;
|
return handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class FindOptionHandlerByID:public std::unary_function
|
class FindOptionHandlerByID:public std::unary_function
|
||||||
<SharedHandle<OptionHandler>, bool> {
|
<SharedHandle<OptionHandler>, bool> {
|
||||||
private:
|
private:
|
||||||
|
@ -339,6 +346,7 @@ public:
|
||||||
return !optionHandler->isHidden() && optionHandler->getOptionID() == id_;
|
return !optionHandler->isHidden() && optionHandler->getOptionID() == id_;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
SharedHandle<OptionHandler> OptionParser::findByID(int id) const
|
SharedHandle<OptionHandler> OptionParser::findByID(int id) const
|
||||||
{
|
{
|
||||||
|
@ -346,6 +354,7 @@ SharedHandle<OptionHandler> OptionParser::findByID(int id) const
|
||||||
FindOptionHandlerByID(id));
|
FindOptionHandlerByID(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class FindOptionHandlerByShortName:
|
class FindOptionHandlerByShortName:
|
||||||
public std::unary_function<SharedHandle<OptionHandler>, bool> {
|
public std::unary_function<SharedHandle<OptionHandler>, bool> {
|
||||||
private:
|
private:
|
||||||
|
@ -359,6 +368,7 @@ public:
|
||||||
optionHandler->getShortName() == shortName_;
|
optionHandler->getShortName() == shortName_;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
SharedHandle<OptionHandler> OptionParser::findByShortName(char shortName) const
|
SharedHandle<OptionHandler> OptionParser::findByShortName(char shortName) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -57,6 +57,7 @@ void PieceStat::subCount()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class GenPieceStat {
|
class GenPieceStat {
|
||||||
private:
|
private:
|
||||||
size_t index_;
|
size_t index_;
|
||||||
|
@ -68,6 +69,7 @@ public:
|
||||||
return SharedHandle<PieceStat>(new PieceStat(index_++));
|
return SharedHandle<PieceStat>(new PieceStat(index_++));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
PieceStatMan::PieceStatMan(size_t pieceNum, bool randomShuffle):
|
PieceStatMan::PieceStatMan(size_t pieceNum, bool randomShuffle):
|
||||||
pieceStats_(pieceNum),
|
pieceStats_(pieceNum),
|
||||||
|
@ -91,6 +93,7 @@ PieceStatMan::PieceStatMan(size_t pieceNum, bool randomShuffle):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class PieceStatRarer {
|
class PieceStatRarer {
|
||||||
private:
|
private:
|
||||||
const std::vector<SharedHandle<PieceStat> >& pieceStats_;
|
const std::vector<SharedHandle<PieceStat> >& pieceStats_;
|
||||||
|
@ -103,6 +106,7 @@ public:
|
||||||
return pieceStats_[lhs] < pieceStats_[rhs];
|
return pieceStats_[lhs] < pieceStats_[rhs];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void PieceStatMan::addPieceStats(const unsigned char* bitfield,
|
void PieceStatMan::addPieceStats(const unsigned char* bitfield,
|
||||||
size_t bitfieldLength)
|
size_t bitfieldLength)
|
||||||
|
|
|
@ -44,6 +44,7 @@ namespace aria2 {
|
||||||
RarestPieceSelector::RarestPieceSelector
|
RarestPieceSelector::RarestPieceSelector
|
||||||
(const SharedHandle<PieceStatMan>& pieceStatMan):pieceStatMan_(pieceStatMan) {}
|
(const SharedHandle<PieceStatMan>& pieceStatMan):pieceStatMan_(pieceStatMan) {}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class FindRarestPiece
|
class FindRarestPiece
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -60,6 +61,7 @@ public:
|
||||||
return misbitfield_[index/8]&mask;
|
return misbitfield_[index/8]&mask;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
bool RarestPieceSelector::select
|
bool RarestPieceSelector::select
|
||||||
(size_t& index, const unsigned char* bitfield, size_t nbits) const
|
(size_t& index, const unsigned char* bitfield, size_t nbits) const
|
||||||
|
|
|
@ -267,6 +267,7 @@ static void executeStopHook
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class ProcessStoppedRequestGroup {
|
class ProcessStoppedRequestGroup {
|
||||||
private:
|
private:
|
||||||
DownloadEngine* e_;
|
DownloadEngine* e_;
|
||||||
|
@ -359,7 +360,9 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class CollectServerStat {
|
class CollectServerStat {
|
||||||
private:
|
private:
|
||||||
RequestGroupMan* requestGroupMan_;
|
RequestGroupMan* requestGroupMan_;
|
||||||
|
@ -401,13 +404,16 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class FindStoppedRequestGroup {
|
class FindStoppedRequestGroup {
|
||||||
public:
|
public:
|
||||||
bool operator()(const SharedHandle<RequestGroup>& group) {
|
bool operator()(const SharedHandle<RequestGroup>& group) {
|
||||||
return group->getNumCommand() == 0;
|
return group->getNumCommand() == 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void RequestGroupMan::updateServerStat()
|
void RequestGroupMan::updateServerStat()
|
||||||
{
|
{
|
||||||
|
|
|
@ -301,6 +301,7 @@ void SegmentMan::eraseSegmentWrittenLengthMemo()
|
||||||
segmentWrittenLengthMemo_.clear();
|
segmentWrittenLengthMemo_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class FindSegmentEntry {
|
class FindSegmentEntry {
|
||||||
private:
|
private:
|
||||||
SharedHandle<Segment> segment_;
|
SharedHandle<Segment> segment_;
|
||||||
|
@ -312,6 +313,7 @@ public:
|
||||||
return segmentEntry->segment->getIndex() == segment_->getIndex();
|
return segmentEntry->segment->getIndex() == segment_->getIndex();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
bool SegmentMan::completeSegment
|
bool SegmentMan::completeSegment
|
||||||
(cuid_t cuid, const SharedHandle<Segment>& segment) {
|
(cuid_t cuid, const SharedHandle<Segment>& segment) {
|
||||||
|
@ -363,7 +365,7 @@ SharedHandle<PeerStat> SegmentMan::getPeerStat(cuid_t cuid) const
|
||||||
return SharedHandle<PeerStat>();
|
return SharedHandle<PeerStat>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class PeerStatHostProtoEqual {
|
class PeerStatHostProtoEqual {
|
||||||
private:
|
private:
|
||||||
const SharedHandle<PeerStat>& peerStat_;
|
const SharedHandle<PeerStat>& peerStat_;
|
||||||
|
@ -377,6 +379,7 @@ public:
|
||||||
peerStat_->getProtocol() == p->getProtocol();
|
peerStat_->getProtocol() == p->getProtocol();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void SegmentMan::updateFastestPeerStat(const SharedHandle<PeerStat>& peerStat)
|
void SegmentMan::updateFastestPeerStat(const SharedHandle<PeerStat>& peerStat)
|
||||||
{
|
{
|
||||||
|
@ -429,6 +432,7 @@ void SegmentMan::updateDownloadSpeedFor(const SharedHandle<PeerStat>& pstat)
|
||||||
peerStatDlspdMap_[pstat->getCuid()] = newspd;
|
peerStatDlspdMap_[pstat->getCuid()] = newspd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class PeerStatDownloadLengthOperator {
|
class PeerStatDownloadLengthOperator {
|
||||||
public:
|
public:
|
||||||
uint64_t operator()(uint64_t total, const SharedHandle<PeerStat>& ps)
|
uint64_t operator()(uint64_t total, const SharedHandle<PeerStat>& ps)
|
||||||
|
@ -436,6 +440,7 @@ public:
|
||||||
return ps->getSessionDownloadLength()+total;
|
return ps->getSessionDownloadLength()+total;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t SegmentMan::calculateSessionDownloadLength() const
|
uint64_t SegmentMan::calculateSessionDownloadLength() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -140,6 +140,7 @@ bool ServerStatMan::load(std::istream& in)
|
||||||
return !in.bad();
|
return !in.bad();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class FindStaleServerStat {
|
class FindStaleServerStat {
|
||||||
private:
|
private:
|
||||||
time_t timeout_;
|
time_t timeout_;
|
||||||
|
@ -152,6 +153,7 @@ public:
|
||||||
return ss->getLastUpdated().difference(time_) >= timeout_;
|
return ss->getLastUpdated().difference(time_) >= timeout_;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void ServerStatMan::removeStaleServerStat(time_t timeout)
|
void ServerStatMan::removeStaleServerStat(time_t timeout)
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
namespace {
|
||||||
class SessionData {
|
class SessionData {
|
||||||
public:
|
public:
|
||||||
SharedHandle<MetalinkParserStateMachine> stm_;
|
SharedHandle<MetalinkParserStateMachine> stm_;
|
||||||
|
@ -55,6 +56,7 @@ public:
|
||||||
|
|
||||||
SessionData(const SharedHandle<MetalinkParserStateMachine>& stm):stm_(stm) {}
|
SessionData(const SharedHandle<MetalinkParserStateMachine>& stm):stm_(stm) {}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static void mlStartElement
|
static void mlStartElement
|
||||||
(void* userData,
|
(void* userData,
|
||||||
|
|
|
@ -47,6 +47,7 @@ namespace aria2 {
|
||||||
|
|
||||||
namespace xmlrpc {
|
namespace xmlrpc {
|
||||||
|
|
||||||
|
namespace {
|
||||||
struct SessionData {
|
struct SessionData {
|
||||||
XmlRpcRequestParserStateMachine* stm_;
|
XmlRpcRequestParserStateMachine* stm_;
|
||||||
|
|
||||||
|
@ -54,6 +55,7 @@ struct SessionData {
|
||||||
|
|
||||||
SessionData(XmlRpcRequestParserStateMachine* stm):stm_(stm) {}
|
SessionData(XmlRpcRequestParserStateMachine* stm):stm_(stm) {}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
static void mlStartElement(void* userData, const xmlChar* name,
|
static void mlStartElement(void* userData, const xmlChar* name,
|
||||||
const xmlChar** attrs)
|
const xmlChar** attrs)
|
||||||
|
|
|
@ -95,7 +95,7 @@ static void encodeValue(const SharedHandle<ValueBase>& value, OutputStream& o)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename OutputStream>
|
template<typename OutputStream>
|
||||||
std::string encodeAll
|
static std::string encodeAll
|
||||||
(OutputStream& o, int code, const SharedHandle<ValueBase>& param)
|
(OutputStream& o, int code, const SharedHandle<ValueBase>& param)
|
||||||
{
|
{
|
||||||
o << "<?xml version=\"1.0\"?>" << "<methodResponse>";
|
o << "<?xml version=\"1.0\"?>" << "<methodResponse>";
|
||||||
|
|
11
src/a2algo.h
11
src/a2algo.h
|
@ -106,6 +106,17 @@ InputIterator findSecond
|
||||||
return last;
|
return last;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class InputIterator, class Predicate>
|
||||||
|
InputIterator find_wrap_if
|
||||||
|
(InputIterator first, InputIterator last,
|
||||||
|
InputIterator current, Predicate pred)
|
||||||
|
{
|
||||||
|
InputIterator itr = std::find_if(current, last, pred);
|
||||||
|
if(itr == last) {
|
||||||
|
itr = std::find_if(first, current, pred);
|
||||||
|
}
|
||||||
|
return itr;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
||||||
|
|
|
@ -349,6 +349,7 @@ void createRequestGroupForMetalink
|
||||||
}
|
}
|
||||||
#endif // ENABLE_METALINK
|
#endif // ENABLE_METALINK
|
||||||
|
|
||||||
|
namespace {
|
||||||
class AccRequestGroup {
|
class AccRequestGroup {
|
||||||
private:
|
private:
|
||||||
std::vector<SharedHandle<RequestGroup> >& requestGroups_;
|
std::vector<SharedHandle<RequestGroup> >& requestGroups_;
|
||||||
|
@ -415,7 +416,9 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
class StreamProtocolFilter {
|
class StreamProtocolFilter {
|
||||||
private:
|
private:
|
||||||
ProtocolDetector detector_;
|
ProtocolDetector detector_;
|
||||||
|
@ -424,6 +427,7 @@ public:
|
||||||
return detector_.isStreamProtocol(uri);
|
return detector_.isStreamProtocol(uri);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void createRequestGroupForUri
|
void createRequestGroupForUri
|
||||||
(std::vector<SharedHandle<RequestGroup> >& result,
|
(std::vector<SharedHandle<RequestGroup> >& result,
|
||||||
|
|
Loading…
Reference in New Issue