summaryrefslogtreecommitdiff
path: root/src/DefaultBtProgressInfoFile.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-11-03 06:49:02 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-11-03 06:49:02 +0000
commit7cf589e78483e6ca7daff2ddd1a30af8091a4448 (patch)
treed595de6899aa7ddad9ad6242c9f50dd6c2a85e22 /src/DefaultBtProgressInfoFile.cc
parent93edc7bd202df92174cc4ce3b8c0c0c7684170fd (diff)
2008-11-03 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Made BtRegistry non-static object. Now DownloadEngine has a reference to its object. * src/AbstractBtMessage.cc * src/ActivePeerConnectionCommand.cc * src/ActivePeerConnectionCommand.h * src/BtContextAwareCommand.cc * src/BtContextAwareCommand.h * src/BtExtendedMessage.cc * src/BtExtendedMessage.h * src/BtInterestedMessage.cc * src/BtInterestedMessage.h * src/BtNotInterestedMessage.cc * src/BtNotInterestedMessage.h * src/BtRegistry.cc * src/BtRegistry.h * src/BtSeederStateChoke.cc * src/BtSetup.cc * src/DHTGetPeersCommand.cc * src/DHTGetPeersCommand.h * src/DHTPeerAnnounceEntry.cc * src/DHTPeerAnnounceEntry.h * src/DHTPeerAnnounceStorage.cc * src/DHTPeerAnnounceStorage.h * src/DHTPeerLookupTask.cc * src/DHTPeerLookupTask.h * src/DHTSetup.cc * src/DHTSetup.h * src/DHTTaskFactory.h * src/DHTTaskFactoryImpl.cc * src/DHTTaskFactoryImpl.h * src/DefaultBtAnnounce.cc * src/DefaultBtInteractive.cc * src/DefaultBtInteractive.h * src/DefaultBtMessageDispatcher.cc * src/DefaultBtMessageDispatcher.h * src/DefaultBtMessageFactory.cc * src/DefaultBtMessageFactory.h * src/DefaultBtMessageReceiver.cc * src/DefaultBtProgressInfoFile.cc * src/DefaultBtProgressInfoFile.h * src/DefaultBtRequestFactory.cc * src/DefaultBtRequestFactory.h * src/DefaultExtensionMessageFactory.cc * src/DefaultExtensionMessageFactory.h * src/DefaultPeerStorage.cc * src/DefaultPeerStorage.h * src/DownloadEngine.cc * src/DownloadEngine.h * src/InitiatorMSEHandshakeCommand.cc * src/InitiatorMSEHandshakeCommand.h * src/MSEHandshake.cc * src/MSEHandshake.h * src/Makefile.am * src/Makefile.in * src/PeerChokeCommand.cc * src/PeerChokeCommand.h * src/PeerInitiateConnectionCommand.cc * src/PeerInitiateConnectionCommand.h * src/PeerInteractionCommand.cc * src/PeerInteractionCommand.h * src/PeerObject.h * src/PeerReceiveHandshakeCommand.cc * src/PeerReceiveHandshakeCommand.h * src/ReceiverMSEHandshakeCommand.cc * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/RequestGroupMan.h * src/SeedCheckCommand.cc * src/SeedCheckCommand.h * src/ShareRatioSeedCriteria.h * src/SimpleBtMessage.cc * src/TrackerWatcherCommand.cc * src/TrackerWatcherCommand.h * src/UTPexExtensionMessage.cc * src/UTPexExtensionMessage.h * test/BtCancelMessageTest.cc * test/BtChokeMessageTest.cc * test/BtExtendedMessageTest.cc * test/BtInterestedMessageTest.cc * test/BtNotInterestedMessageTest.cc * test/BtPieceMessageTest.cc * test/BtPortMessageTest.cc * test/BtRegistryTest.cc * test/BtRejectMessageTest.cc * test/BtRequestMessageTest.cc * test/DHTPeerAnnounceEntryTest.cc * test/DHTPeerAnnounceStorageTest.cc * test/DefaultBtMessageDispatcherTest.cc * test/DefaultBtMessageFactoryTest.cc * test/DefaultBtProgressInfoFileTest.cc * test/DefaultBtRequestFactoryTest.cc * test/DefaultExtensionMessageFactoryTest.cc * test/MSEHandshakeTest.cc * test/MockDHTTaskFactory.h * test/ShareRatioSeedCriteriaTest.cc * test/UTPexExtensionMessageTest.cc
Diffstat (limited to 'src/DefaultBtProgressInfoFile.cc')
-rw-r--r--src/DefaultBtProgressInfoFile.cc29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/DefaultBtProgressInfoFile.cc b/src/DefaultBtProgressInfoFile.cc
index eb93a3ed..31286de9 100644
--- a/src/DefaultBtProgressInfoFile.cc
+++ b/src/DefaultBtProgressInfoFile.cc
@@ -33,6 +33,11 @@
*/
/* copyright --> */
#include "DefaultBtProgressInfoFile.h"
+
+#include <cerrno>
+#include <cstring>
+#include <fstream>
+
#include "BtContext.h"
#include "PieceStorage.h"
#include "Piece.h"
@@ -41,7 +46,6 @@
#include "BitfieldMan.h"
#include "Option.h"
#include "TransferStat.h"
-#include "BtRegistry.h"
#include "LogFactory.h"
#include "Logger.h"
#include "prefs.h"
@@ -52,9 +56,6 @@
#include "a2io.h"
#include "DownloadFailureException.h"
#include "StringFormat.h"
-#include <fstream>
-#include <cerrno>
-#include <cstring>
namespace aria2 {
@@ -86,7 +87,7 @@ void DefaultBtProgressInfoFile::updateFilename()
bool DefaultBtProgressInfoFile::isTorrentDownload()
{
- return !dynamic_pointer_cast<BtContext>(_dctx).isNull();
+ return !_btRuntime.isNull();
}
// Since version 0001, Integers are saved in binary form, network byte order.
@@ -138,8 +139,7 @@ void DefaultBtProgressInfoFile::save() {
// uploadLength: 64 bits
uint64_t uploadLengthNL = 0;
if(torrentDownload) {
- BtContextHandle btContext(dynamic_pointer_cast<BtContext>(_dctx));
- TransferStat stat = PEER_STORAGE(btContext)->calculateStat();
+ TransferStat stat = _peerStorage->calculateStat();
uploadLengthNL = hton64(stat.getAllTimeUploadLength());
}
o.write(reinterpret_cast<const char*>(&uploadLengthNL),
@@ -267,8 +267,7 @@ void DefaultBtProgressInfoFile::load()
uploadLength = ntoh64(uploadLength);
}
if(isTorrentDownload()) {
- BT_RUNTIME(dynamic_pointer_cast<BtContext>(_dctx))->
- setUploadLengthAtStartup(uploadLength);
+ _btRuntime->setUploadLengthAtStartup(uploadLength);
}
// TODO implement the conversion mechanism between different piece length.
@@ -401,4 +400,16 @@ bool DefaultBtProgressInfoFile::exists()
}
}
+void DefaultBtProgressInfoFile::setPeerStorage
+(const SharedHandle<PeerStorage>& peerStorage)
+{
+ _peerStorage = peerStorage;
+}
+
+void DefaultBtProgressInfoFile::setBtRuntime
+(const SharedHandle<BtRuntime>& btRuntime)
+{
+ _btRuntime = btRuntime;
+}
+
} // namespace aria2