/* */ #ifndef D_DOWNLOAD_COMMAND_H #define D_DOWNLOAD_COMMAND_H #include "AbstractCommand.h" #include namespace aria2 { class PeerStat; class StreamFilter; class MessageDigest; class DownloadCommand : public AbstractCommand { private: std::shared_ptr peerStat_; std::unique_ptr streamFilter_; std::unique_ptr messageDigest_; std::chrono::seconds startupIdleTime_; int lowestDownloadSpeedLimit_; bool pieceHashValidationEnabled_; bool sinkFilterOnly_; void validatePieceHash(const std::shared_ptr& segment, const std::string& expectedPieceHash, const std::string& actualPieceHash); void checkLowestDownloadSpeed() const; void completeSegment(cuid_t cuid, const std::shared_ptr& segment); protected: virtual bool executeInternal() CXX11_OVERRIDE; virtual bool prepareForNextSegment(); // This is file local offset virtual int64_t getRequestEndOffset() const = 0; // Returns true if socket should be monitored for writing. The // default implementation is return the return value of // getSocket()->wantWrite(). virtual bool shouldEnableWriteCheck(); public: DownloadCommand(cuid_t cuid, const std::shared_ptr& req, const std::shared_ptr& fileEntry, RequestGroup* requestGroup, DownloadEngine* e, const std::shared_ptr& s, const std::shared_ptr& socketRecvBuffer); virtual ~DownloadCommand(); const std::unique_ptr& getStreamFilter() const { return streamFilter_; } void installStreamFilter(std::unique_ptr streamFilter); void setStartupIdleTime(std::chrono::seconds startupIdleTime) { startupIdleTime_ = std::move(startupIdleTime); } void setLowestDownloadSpeedLimit(int lowestDownloadSpeedLimit) { lowestDownloadSpeedLimit_ = lowestDownloadSpeedLimit; } }; } // namespace aria2 #endif // D_DOWNLOAD_COMMAND_H