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