/* */ #include "StreamFileAllocationEntry.h" #include "CUIDCounter.h" #include "DownloadEngine.h" #include "Option.h" #include "Request.h" #include "prefs.h" #include "RequestGroup.h" #include "InitiateConnectionCommandFactory.h" namespace aria2 { StreamFileAllocationEntry::StreamFileAllocationEntry(const RequestHandle& currentRequest, RequestGroup* requestGroup, Command* nextCommand): FileAllocationEntry(requestGroup, nextCommand), _currentRequest(currentRequest) {} StreamFileAllocationEntry::~StreamFileAllocationEntry() {} Commands StreamFileAllocationEntry::prepareForNextAction(DownloadEngine* e) { Commands commands; if(_nextCommand) { commands.push_back(popNextCommand()); // try remaining uris Commands streamCommands = _requestGroup->createNextCommandWithAdj(e, -1); copy(streamCommands.begin(), streamCommands.end(), back_inserter(commands)); } else { if(_currentRequest.isNull()) { commands = _requestGroup->createNextCommandWithAdj(e, 0); } else { Commands streamCommands = _requestGroup->createNextCommandWithAdj(e, -1); Command* command = InitiateConnectionCommandFactory::createInitiateConnectionCommand(CUIDCounterSingletonHolder::instance()->newID(), _currentRequest, _requestGroup, e); commands.push_back(command); copy(streamCommands.begin(), streamCommands.end(), back_inserter(commands)); } } return commands; } } // namespace aria2