summaryrefslogtreecommitdiff
path: root/src/TrackerWatcherCommand.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2013-06-22 01:10:38 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2013-06-22 01:10:38 +0900
commit07d270c87e6f9184aea4ca17eb26e466712e8db2 (patch)
tree2dfbaa2e0d2ad0f38cb73098608f7d67a64320f8 /src/TrackerWatcherCommand.cc
parent126a4bde612eb0e6c48cf2f13ebe3eac45cc71a8 (diff)
Require -std=c++11 and use std::shared_ptr instead of SharedHandle
Diffstat (limited to 'src/TrackerWatcherCommand.cc')
-rw-r--r--src/TrackerWatcherCommand.cc46
1 files changed, 23 insertions, 23 deletions
diff --git a/src/TrackerWatcherCommand.cc b/src/TrackerWatcherCommand.cc
index 06d7fc3e..4c95236e 100644
--- a/src/TrackerWatcherCommand.cc
+++ b/src/TrackerWatcherCommand.cc
@@ -70,7 +70,7 @@
namespace aria2 {
-HTTPAnnRequest::HTTPAnnRequest(const SharedHandle<RequestGroup>& rg)
+HTTPAnnRequest::HTTPAnnRequest(const std::shared_ptr<RequestGroup>& rg)
: rg_(rg)
{}
@@ -110,7 +110,7 @@ bool HTTPAnnRequest::issue(DownloadEngine* e)
}
bool HTTPAnnRequest::processResponse
-(const SharedHandle<BtAnnounce>& btAnnounce)
+(const std::shared_ptr<BtAnnounce>& btAnnounce)
{
try {
std::stringstream strm;
@@ -134,7 +134,7 @@ bool HTTPAnnRequest::processResponse
}
}
-UDPAnnRequest::UDPAnnRequest(const SharedHandle<UDPTrackerRequest>& req)
+UDPAnnRequest::UDPAnnRequest(const std::shared_ptr<UDPTrackerRequest>& req)
: req_(req)
{}
@@ -173,7 +173,7 @@ bool UDPAnnRequest::issue(DownloadEngine* e)
}
bool UDPAnnRequest::processResponse
-(const SharedHandle<BtAnnounce>& btAnnounce)
+(const std::shared_ptr<BtAnnounce>& btAnnounce)
{
if(req_) {
btAnnounce->processUDPTrackerResponse(req_);
@@ -264,7 +264,7 @@ void TrackerWatcherCommand::addConnection()
break;
}
cuid_t ncuid = e_->newCUID();
- SharedHandle<Peer> peer = peerStorage_->checkoutPeer(ncuid);
+ std::shared_ptr<Peer> peer = peerStorage_->checkoutPeer(ncuid);
// sanity check
if(!peer) {
break;
@@ -280,10 +280,10 @@ void TrackerWatcherCommand::addConnection()
}
}
-SharedHandle<AnnRequest>
+std::shared_ptr<AnnRequest>
TrackerWatcherCommand::createAnnounce(DownloadEngine* e)
{
- SharedHandle<AnnRequest> treq;
+ std::shared_ptr<AnnRequest> treq;
while(!btAnnounce_->isAllAnnounceFailed() &&
btAnnounce_->isAnnounceReady()) {
std::string uri = btAnnounce_->getAnnounceUrl();
@@ -314,21 +314,21 @@ TrackerWatcherCommand::createAnnounce(DownloadEngine* e)
return treq;
}
-SharedHandle<AnnRequest>
+std::shared_ptr<AnnRequest>
TrackerWatcherCommand::createUDPAnnRequest(const std::string& host,
uint16_t port,
uint16_t localPort)
{
- SharedHandle<UDPTrackerRequest> req =
+ std::shared_ptr<UDPTrackerRequest> req =
btAnnounce_->createUDPTrackerRequest(host, port, localPort);
- return SharedHandle<AnnRequest>(new UDPAnnRequest(req));
+ return std::shared_ptr<AnnRequest>(new UDPAnnRequest(req));
}
namespace {
bool backupTrackerIsAvailable
-(const SharedHandle<DownloadContext>& context)
+(const std::shared_ptr<DownloadContext>& context)
{
- SharedHandle<TorrentAttribute> torrentAttrs =
+ std::shared_ptr<TorrentAttribute> torrentAttrs =
bittorrent::getTorrentAttrs(context);
if(torrentAttrs->announceList.size() >= 2) {
return true;
@@ -344,13 +344,13 @@ bool backupTrackerIsAvailable
}
} // namespace
-SharedHandle<AnnRequest>
+std::shared_ptr<AnnRequest>
TrackerWatcherCommand::createHTTPAnnRequest(const std::string& uri)
{
std::vector<std::string> uris;
uris.push_back(uri);
- SharedHandle<Option> option = util::copy(getOption());
- SharedHandle<RequestGroup> rg(new RequestGroup(GroupId::create(), option));
+ std::shared_ptr<Option> option = util::copy(getOption());
+ std::shared_ptr<RequestGroup> rg(new RequestGroup(GroupId::create(), option));
if(backupTrackerIsAvailable(requestGroup_->getDownloadContext())) {
A2_LOG_DEBUG("This is multi-tracker announce.");
} else {
@@ -369,13 +369,13 @@ TrackerWatcherCommand::createHTTPAnnRequest(const std::string& uri)
option->get(PREF_BT_TRACKER_CONNECT_TIMEOUT));
option->put(PREF_REUSE_URI, A2_V_FALSE);
option->put(PREF_SELECT_LEAST_USED_HOST, A2_V_FALSE);
- SharedHandle<DownloadContext> dctx
+ std::shared_ptr<DownloadContext> dctx
(new DownloadContext(option->getAsInt(PREF_PIECE_LENGTH),
0,
"[tracker.announce]"));
dctx->getFileEntries().front()->setUris(uris);
rg->setDownloadContext(dctx);
- SharedHandle<DiskWriterFactory> dwf(new ByteArrayDiskWriterFactory());
+ std::shared_ptr<DiskWriterFactory> dwf(new ByteArrayDiskWriterFactory());
rg->setDiskWriterFactory(dwf);
rg->setFileAllocationEnabled(false);
rg->setPreLocalFileCheckEnabled(false);
@@ -386,34 +386,34 @@ TrackerWatcherCommand::createHTTPAnnRequest(const std::string& uri)
dctx->setAcceptMetalink(false);
A2_LOG_INFO(fmt("Creating tracker request group GID#%s",
GroupId::toHex(rg->getGID()).c_str()));
- return SharedHandle<AnnRequest>(new HTTPAnnRequest(rg));
+ return std::shared_ptr<AnnRequest>(new HTTPAnnRequest(rg));
}
void TrackerWatcherCommand::setBtRuntime
-(const SharedHandle<BtRuntime>& btRuntime)
+(const std::shared_ptr<BtRuntime>& btRuntime)
{
btRuntime_ = btRuntime;
}
void TrackerWatcherCommand::setPeerStorage
-(const SharedHandle<PeerStorage>& peerStorage)
+(const std::shared_ptr<PeerStorage>& peerStorage)
{
peerStorage_ = peerStorage;
}
void TrackerWatcherCommand::setPieceStorage
-(const SharedHandle<PieceStorage>& pieceStorage)
+(const std::shared_ptr<PieceStorage>& pieceStorage)
{
pieceStorage_ = pieceStorage;
}
void TrackerWatcherCommand::setBtAnnounce
-(const SharedHandle<BtAnnounce>& btAnnounce)
+(const std::shared_ptr<BtAnnounce>& btAnnounce)
{
btAnnounce_ = btAnnounce;
}
-const SharedHandle<Option>& TrackerWatcherCommand::getOption() const
+const std::shared_ptr<Option>& TrackerWatcherCommand::getOption() const
{
return requestGroup_->getOption();
}