DFF0F3C517528350002DA3A4 /* Crc32.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 18B7C8E712942603009E7A26 /* Crc32.cpp */; };
DFF0F3C617528350002DA3A4 /* CryptThreading.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5BD02F4148D3A7E001B5583 /* CryptThreading.cpp */; };
DFF0F3C717528350002DA3A4 /* DatabaseUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 36A9443B15821E2800727135 /* DatabaseUtils.cpp */; };
- DFF0F3C817528350002DA3A4 /* DownloadQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E310D25F9FD00618676 /* DownloadQueue.cpp */; };
- DFF0F3C917528350002DA3A4 /* DownloadQueueManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E330D25F9FD00618676 /* DownloadQueueManager.cpp */; };
DFF0F3CA17528350002DA3A4 /* EdenVideoArtUpdater.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CC30E8816296078003E7579 /* EdenVideoArtUpdater.cpp */; };
DFF0F3CB17528350002DA3A4 /* Environment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF529BAC1741697B00523FB4 /* Environment.cpp */; };
DFF0F3CC17528350002DA3A4 /* Fanart.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E36C29E90DA72486001F0C9D /* Fanart.cpp */; };
E38E22C60D25F9FE00618676 /* BitstreamStats.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E270D25F9FD00618676 /* BitstreamStats.cpp */; };
E38E22C70D25F9FE00618676 /* CharsetConverter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E290D25F9FD00618676 /* CharsetConverter.cpp */; };
E38E22C80D25F9FE00618676 /* CPUInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E2B0D25F9FD00618676 /* CPUInfo.cpp */; };
- E38E22CB0D25F9FE00618676 /* DownloadQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E310D25F9FD00618676 /* DownloadQueue.cpp */; };
- E38E22CC0D25F9FE00618676 /* DownloadQueueManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E330D25F9FD00618676 /* DownloadQueueManager.cpp */; };
E38E22CD0D25F9FE00618676 /* Event.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E350D25F9FD00618676 /* Event.cpp */; };
E38E22D10D25F9FE00618676 /* GUIInfoManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E3E0D25F9FD00618676 /* GUIInfoManager.cpp */; };
E38E22D20D25F9FE00618676 /* HTMLTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E400D25F9FD00618676 /* HTMLTable.cpp */; };
E4991449174E605900741B6D /* Crc32.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 18B7C8E712942603009E7A26 /* Crc32.cpp */; };
E499144A174E605900741B6D /* CryptThreading.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5BD02F4148D3A7E001B5583 /* CryptThreading.cpp */; };
E499144B174E605900741B6D /* DatabaseUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 36A9443B15821E2800727135 /* DatabaseUtils.cpp */; };
- E499144C174E605900741B6D /* DownloadQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E310D25F9FD00618676 /* DownloadQueue.cpp */; };
- E499144D174E605900741B6D /* DownloadQueueManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38E1E330D25F9FD00618676 /* DownloadQueueManager.cpp */; };
E499144E174E605900741B6D /* EdenVideoArtUpdater.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CC30E8816296078003E7579 /* EdenVideoArtUpdater.cpp */; };
E499144F174E605900741B6D /* Environment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DF529BAC1741697B00523FB4 /* Environment.cpp */; };
E4991450174E605900741B6D /* Fanart.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E36C29E90DA72486001F0C9D /* Fanart.cpp */; };
E38E1E2B0D25F9FD00618676 /* CPUInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CPUInfo.cpp; sourceTree = "<group>"; };
E38E1E2C0D25F9FD00618676 /* CPUInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CPUInfo.h; sourceTree = "<group>"; };
E38E1E2E0D25F9FD00618676 /* CriticalSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CriticalSection.h; sourceTree = "<group>"; };
- E38E1E310D25F9FD00618676 /* DownloadQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DownloadQueue.cpp; sourceTree = "<group>"; };
- E38E1E320D25F9FD00618676 /* DownloadQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DownloadQueue.h; sourceTree = "<group>"; };
- E38E1E330D25F9FD00618676 /* DownloadQueueManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DownloadQueueManager.cpp; sourceTree = "<group>"; };
- E38E1E340D25F9FD00618676 /* DownloadQueueManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DownloadQueueManager.h; sourceTree = "<group>"; };
E38E1E350D25F9FD00618676 /* Event.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Event.cpp; sourceTree = "<group>"; };
E38E1E360D25F9FD00618676 /* Event.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Event.h; sourceTree = "<group>"; };
E38E1E3D0D25F9FD00618676 /* fstrcmp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fstrcmp.h; sourceTree = "<group>"; };
F5BD02F5148D3A7E001B5583 /* CryptThreading.h */,
36A9443B15821E2800727135 /* DatabaseUtils.cpp */,
36A9443C15821E2800727135 /* DatabaseUtils.h */,
- E38E1E310D25F9FD00618676 /* DownloadQueue.cpp */,
- E38E1E320D25F9FD00618676 /* DownloadQueue.h */,
- E38E1E330D25F9FD00618676 /* DownloadQueueManager.cpp */,
- E38E1E340D25F9FD00618676 /* DownloadQueueManager.h */,
7CC30E8816296078003E7579 /* EdenVideoArtUpdater.cpp */,
7CC30E8916296078003E7579 /* EdenVideoArtUpdater.h */,
436B38F3106628850049AB3B /* EndianSwap.h */,
E38E22C60D25F9FE00618676 /* BitstreamStats.cpp in Sources */,
E38E22C70D25F9FE00618676 /* CharsetConverter.cpp in Sources */,
E38E22C80D25F9FE00618676 /* CPUInfo.cpp in Sources */,
- E38E22CB0D25F9FE00618676 /* DownloadQueue.cpp in Sources */,
- E38E22CC0D25F9FE00618676 /* DownloadQueueManager.cpp in Sources */,
E38E22CD0D25F9FE00618676 /* Event.cpp in Sources */,
E38E22D10D25F9FE00618676 /* GUIInfoManager.cpp in Sources */,
E38E22D20D25F9FE00618676 /* HTMLTable.cpp in Sources */,
DFF0F3C517528350002DA3A4 /* Crc32.cpp in Sources */,
DFF0F3C617528350002DA3A4 /* CryptThreading.cpp in Sources */,
DFF0F3C717528350002DA3A4 /* DatabaseUtils.cpp in Sources */,
- DFF0F3C817528350002DA3A4 /* DownloadQueue.cpp in Sources */,
- DFF0F3C917528350002DA3A4 /* DownloadQueueManager.cpp in Sources */,
DFF0F3CA17528350002DA3A4 /* EdenVideoArtUpdater.cpp in Sources */,
DFF0F3CB17528350002DA3A4 /* Environment.cpp in Sources */,
DFF0F3CC17528350002DA3A4 /* Fanart.cpp in Sources */,
E4991449174E605900741B6D /* Crc32.cpp in Sources */,
E499144A174E605900741B6D /* CryptThreading.cpp in Sources */,
E499144B174E605900741B6D /* DatabaseUtils.cpp in Sources */,
- E499144C174E605900741B6D /* DownloadQueue.cpp in Sources */,
- E499144D174E605900741B6D /* DownloadQueueManager.cpp in Sources */,
E499144E174E605900741B6D /* EdenVideoArtUpdater.cpp in Sources */,
E499144F174E605900741B6D /* Environment.cpp in Sources */,
E4991450174E605900741B6D /* Fanart.cpp in Sources */,
<ClCompile Include="..\..\xbmc\utils\CPUInfo.cpp" />
<ClCompile Include="..\..\xbmc\utils\Crc32.cpp" />
<ClCompile Include="..\..\xbmc\utils\DatabaseUtils.cpp" />
- <ClCompile Include="..\..\xbmc\utils\DownloadQueue.cpp" />
- <ClCompile Include="..\..\xbmc\utils\DownloadQueueManager.cpp" />
<ClCompile Include="..\..\xbmc\utils\EdenVideoArtUpdater.cpp" />
<ClCompile Include="..\..\xbmc\utils\EndianSwap.cpp" />
<ClCompile Include="..\..\xbmc\utils\Fanart.cpp" />
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release (DirectX)|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release (OpenGL)|Win32'">true</ExcludedFromBuild>
</ClCompile>
- <ClCompile Include="..\..\xbmc\utils\test\TestDownloadQueue.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (DirectX)|Win32'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (OpenGL)|Win32'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release (DirectX)|Win32'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release (OpenGL)|Win32'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Testsuite|Win32'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\xbmc\utils\test\TestDownloadQueueManager.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (DirectX)|Win32'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (OpenGL)|Win32'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release (DirectX)|Win32'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release (OpenGL)|Win32'">true</ExcludedFromBuild>
- </ClCompile>
<ClCompile Include="..\..\xbmc\utils\test\TestEndianSwap.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (DirectX)|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug (OpenGL)|Win32'">true</ExcludedFromBuild>
<ClInclude Include="..\..\xbmc\utils\CPUInfo.h" />
<ClInclude Include="..\..\xbmc\utils\Crc32.h" />
<ClInclude Include="..\..\xbmc\utils\DatabaseUtils.h" />
- <ClInclude Include="..\..\xbmc\utils\DownloadQueue.h" />
- <ClInclude Include="..\..\xbmc\utils\DownloadQueueManager.h" />
<ClInclude Include="..\..\xbmc\utils\EdenVideoArtUpdater.h" />
<ClInclude Include="..\..\xbmc\utils\EndianSwap.h" />
<ClInclude Include="..\..\xbmc\utils\Fanart.h" />
<ClCompile Include="..\..\xbmc\utils\Crc32.cpp">
<Filter>utils</Filter>
</ClCompile>
- <ClCompile Include="..\..\xbmc\utils\DownloadQueue.cpp">
- <Filter>utils</Filter>
- </ClCompile>
- <ClCompile Include="..\..\xbmc\utils\DownloadQueueManager.cpp">
- <Filter>utils</Filter>
- </ClCompile>
<ClCompile Include="..\..\xbmc\utils\Fanart.cpp">
<Filter>utils</Filter>
</ClCompile>
<ClCompile Include="..\..\xbmc\utils\test\TestDatabaseUtils.cpp">
<Filter>utils\test</Filter>
</ClCompile>
- <ClCompile Include="..\..\xbmc\utils\test\TestDownloadQueue.cpp">
- <Filter>utils\test</Filter>
- </ClCompile>
- <ClCompile Include="..\..\xbmc\utils\test\TestDownloadQueueManager.cpp">
- <Filter>utils\test</Filter>
- </ClCompile>
<ClCompile Include="..\..\xbmc\utils\test\TestEndianSwap.cpp">
<Filter>utils\test</Filter>
</ClCompile>
<ClInclude Include="..\..\xbmc\utils\Crc32.h">
<Filter>utils</Filter>
</ClInclude>
- <ClInclude Include="..\..\xbmc\utils\DownloadQueue.h">
- <Filter>utils</Filter>
- </ClInclude>
- <ClInclude Include="..\..\xbmc\utils\DownloadQueueManager.h">
- <Filter>utils</Filter>
- </ClInclude>
<ClInclude Include="..\..\xbmc\utils\EdenVideoArtUpdater.h">
<Filter>utils</Filter>
</ClInclude>
#include "GUILargeTextureManager.h"
#include "guilib/TextureManager.h"
#include "utils/AlarmClock.h"
-#include "utils/DownloadQueueManager.h"
#include "GUIInfoManager.h"
#include "filesystem/DllLibCurl.h"
#include "filesystem/DirectoryCache.h"
CGUIInfoManager g_infoManager;
XCURL::DllLibCurlGlobal g_curlInterface;
- CDownloadQueueManager g_DownloadManager;
CPartyModeManager g_partyModeManager;
#ifdef HAS_PYTHON
}
-std::vector<CStdString> &CXBMCTestUtils::getTestDownloadQueueUrls()
-{
- return TestDownloadQueueUrls;
-}
-
std::vector<CStdString> &CXBMCTestUtils::getTestFileFactoryReadUrls()
{
return TestFileFactoryReadUrls;
"\n"
"The following options are recognized by the xbmc-test program.\n"
"\n"
-" --add-testdownloadqueue-url [URL]\n"
-" Add a url to be used in the TestDownloadQueue tests.\n"
-"\n"
-" --add-testdownloadqueue-urls [URLS]\n"
-" Add multiple urls from a ',' delimited string of urls. to be used\n"
-" in the TestDownloadQueue tests.\n"
-"\n"
" --add-testfilefactory-readurl [URL]\n"
" Add a url to be used int the TestFileFactory read tests.\n"
"\n"
for (i = 1; i < argc; i++)
{
arg = argv[i];
- if (arg == "--add-testdownloadqueue-url")
- {
- TestDownloadQueueUrls.push_back(argv[++i]);
- }
- else if (arg == "--add-testdownloadqueue-urls")
- {
- arg = argv[++i];
- std::vector<std::string> urls = StringUtils::Split(arg, ",");
- std::vector<std::string>::iterator it;
- for (it = urls.begin(); it < urls.end(); it++)
- TestDownloadQueueUrls.push_back(*it);
- }
- else if (arg == "--add-testfilefactory-readurl")
+ if (arg == "--add-testfilefactory-readurl")
{
TestFileFactoryReadUrls.push_back(argv[++i]);
}
/* Function to get path of a tempfile */
CStdString TempFilePath(XFILE::CFile const* const tempfile);
- /* Functions to get variables used in the TestDownloadQueue tests. */
- std::vector<CStdString> &getTestDownloadQueueUrls();
-
/* Functions to get variables used in the TestFileFactory tests. */
std::vector<CStdString> &getTestFileFactoryReadUrls();
CXBMCTestUtils(CXBMCTestUtils const&);
void operator=(CXBMCTestUtils const&);
- std::vector<CStdString> TestDownloadQueueUrls;
std::vector<CStdString> TestFileFactoryReadUrls;
std::vector<CStdString> TestFileFactoryWriteUrls;
CStdString TestFileFactoryWriteInputFile;
+++ /dev/null
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "DownloadQueue.h"
-#include "URIUtils.h"
-#include "log.h"
-
-#include "filesystem/File.h"
-#include "filesystem/CurlFile.h"
-#include "threads/SingleLock.h"
-
-using namespace std;
-using namespace XFILE;
-
-WORD CDownloadQueue::m_wNextQueueId = 0;
-
-CDownloadQueue::CDownloadQueue(void) : CThread("DownloadQueue")
-{
- m_bStop = false;
- m_wQueueId = m_wNextQueueId++;
- m_dwNextItemId = 0;
- CThread::Create(false);
-}
-
-void CDownloadQueue::OnStartup()
-{
- SetPriority( GetMinPriority() );
-}
-
-CDownloadQueue::~CDownloadQueue(void)
-{
-}
-
-
-TICKET CDownloadQueue::RequestContent(const CStdString& aUrl, IDownloadQueueObserver* aObserver)
-{
- CSingleLock lock(m_critical);
- TICKET ticket(m_wQueueId, m_dwNextItemId++);
-
- Command request = {ticket, aUrl, "", aObserver};
- m_queue.push(request);
-
- return request.ticket;
-}
-
-TICKET CDownloadQueue::RequestFile(const CStdString& aUrl, const CStdString& aFilePath, IDownloadQueueObserver* aObserver)
-{
- CSingleLock lock(m_critical);
-
- TICKET ticket(m_wQueueId, m_dwNextItemId++);
-
- Command request = {ticket, aUrl, aFilePath, aObserver};
- m_queue.push(request);
-
- return request.ticket;
-}
-
-void CDownloadQueue::CancelRequests(IDownloadQueueObserver *aObserver)
-{
- CSingleLock lock(m_critical);
-
- CLog::Log(LOGDEBUG, "CancelRequests from observer at %p", aObserver);
- // run through our queue, and create a new queue with the requests
- // from aObserver NULL'd out.
- queue<Command> newQueue;
- while (m_queue.size())
- {
- Command request = m_queue.front();
- m_queue.pop();
- if (request.observer == aObserver)
- request.observer = NULL;
- newQueue.push(request);
- }
- m_queue = newQueue;
-}
-
-TICKET CDownloadQueue::RequestFile(const CStdString& aUrl, IDownloadQueueObserver* aObserver)
-{
- CSingleLock lock(m_critical);
-
- CLog::Log(LOGDEBUG, "RequestFile from observer at %p", aObserver);
- // create a temporary destination
- CStdString strExtension = URIUtils::GetExtension(aUrl);
-
- TICKET ticket(m_wQueueId, m_dwNextItemId++);
-
- CStdString strFilePath;
- strFilePath.Format("special://temp/q%d-item%u%s", ticket.wQueueId, ticket.dwItemId, strExtension.c_str());
-
- Command request = {ticket, aUrl, strFilePath, aObserver};
- m_queue.push(request);
-
- return request.ticket;
-}
-
-VOID CDownloadQueue::Flush()
-{
- CSingleLock lock(m_critical);
-
- m_queue.empty();
-
-}
-
-void CDownloadQueue::Process()
-{
- CLog::Log(LOGNOTICE, "DownloadQueue ready.");
-
- CCurlFile http;
- bool bSuccess;
-
- while ( !m_bStop )
- {
- while ( CDownloadQueue::Size() > 0 )
- {
- CSingleLock lock(m_critical);
-
- // get the first item, but don't pop it from our queue
- // so that the download can be interrupted
- Command request = m_queue.front();
- lock.Leave();
-
- bool bFileRequest = request.content.length() > 0;
- DWORD dwSize = 0;
-
- if (bFileRequest)
- {
- CFile::Delete(request.content);
- bSuccess = http.Download(request.location, request.content, &dwSize);
- }
- else
- {
- bSuccess = http.Get(request.location, request.content);
- }
-
- // now re-grab the item as we may have cancelled our download
- // while we were working
- { CSingleLock lock2(m_critical); // open lock2 scope
-
- request = m_queue.front();
- m_queue.pop();
-
- // if the request has been cancelled our observer will be NULL
- if (NULL != request.observer)
- {
- try
- {
- if (bFileRequest)
- {
- request.observer->OnFileComplete(request.ticket, request.content, dwSize,
- bSuccess ? IDownloadQueueObserver::Succeeded : IDownloadQueueObserver::Failed );
- }
- else
- {
- request.observer->OnContentComplete(request.ticket, request.content,
- bSuccess ? IDownloadQueueObserver::Succeeded : IDownloadQueueObserver::Failed );
- }
- }
- catch (...)
- {
- CLog::Log(LOGERROR, "exception while updating download observer.");
-
- if (bFileRequest)
- {
- CFile::Delete(request.content);
- }
- }
- }
- } // close lock2 scope
- }
-
- Sleep(500);
- }
-
- CLog::Log(LOGNOTICE, "DownloadQueue terminated.");
-}
-
-INT CDownloadQueue::Size()
-{
- CSingleLock lock(m_critical);
-
- int sizeOfQueue = m_queue.size();
-
- return sizeOfQueue;
-}
-
+++ /dev/null
-#pragma once
-
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <queue>
-#include "threads/Thread.h"
-#include "threads/CriticalSection.h"
-#include "StdString.h"
-
-#include "system.h"
-
-struct TICKET
-{
- TICKET(WORD aQueueId, DWORD aItemId)
- {
- wQueueId = aQueueId;
- dwItemId = aItemId;
- };
-
- WORD wQueueId;
- DWORD dwItemId;
-};
-
-class IDownloadQueueObserver
-{
-public:
- enum Result {Succeeded, Failed};
- virtual ~IDownloadQueueObserver() {};
- virtual void OnContentComplete(TICKET aTicket, CStdString& aContentString, Result aResult){};
- virtual void OnFileComplete(TICKET aTicket, CStdString& aFilePath, INT aByteRxCount, Result aResult){};
-};
-
-
-class CDownloadQueue: CThread
-{
-public:
- CDownloadQueue();
- virtual ~CDownloadQueue(void);
-
- TICKET RequestContent(const CStdString& aUrl, IDownloadQueueObserver* aObserver);
- TICKET RequestFile(const CStdString& aUrl, IDownloadQueueObserver* aObserver);
- TICKET RequestFile(const CStdString& aUrl, const CStdString& aFilePath, IDownloadQueueObserver* aObserver);
- void CancelRequests(IDownloadQueueObserver* aObserver);
-
- VOID Flush();
- INT Size();
-
-protected:
-
- void OnStartup();
- void Process();
-
- struct Command
- {
- TICKET ticket;
- CStdString location;
- CStdString content;
- IDownloadQueueObserver* observer;
- };
-
- typedef std::queue<Command> COMMANDQUEUE;
- COMMANDQUEUE m_queue;
- CCriticalSection m_critical;
-
- WORD m_wQueueId;
- DWORD m_dwNextItemId;
-
- static WORD m_wNextQueueId;
-};
+++ /dev/null
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "DownloadQueueManager.h"
-#include "threads/SingleLock.h"
-#include <assert.h>
-
-CDownloadQueueManager::CDownloadQueueManager()
-{
-}
-
-CDownloadQueueManager::~CDownloadQueueManager(void)
-{
-}
-
-VOID CDownloadQueueManager::Initialize()
-{
-}
-
-
-TICKET CDownloadQueueManager::RequestContent(const CStdString& aUrl, IDownloadQueueObserver* aObserver)
-{
- CSingleLock lock(m_critical);
- return GetNextDownloadQueue()->RequestContent(aUrl, aObserver);
-}
-
-TICKET CDownloadQueueManager::RequestFile(const CStdString& aUrl, const CStdString& aFilePath, IDownloadQueueObserver* aObserver)
-{
- CSingleLock lock(m_critical);
- return GetNextDownloadQueue()->RequestFile(aUrl, aFilePath, aObserver);
-}
-
-TICKET CDownloadQueueManager::RequestFile(const CStdString& aUrl, IDownloadQueueObserver* aObserver)
-{
- CSingleLock lock(m_critical);
- return GetNextDownloadQueue()->RequestFile(aUrl, aObserver);
-}
-
-void CDownloadQueueManager::CancelRequests(IDownloadQueueObserver *aObserver)
-{
- CSingleLock lock(m_critical);
- // run through all our queues and remove all requests from this observer
- for (QUEUEPOOL::iterator it = m_queues.begin(); it != m_queues.end(); ++it)
- {
- CDownloadQueue* downloadQueue = *it;
- downloadQueue->CancelRequests(aObserver);
- }
-}
-
-CDownloadQueue* CDownloadQueueManager::GetNextDownloadQueue()
-{
- CDownloadQueue* pQueueAvailable = NULL;
-
- // if we haven't added any queues to the pool, add one.
- if (m_queues.size() < 1)
- {
- m_queues.push_back( new CDownloadQueue() );
- }
-
- // return the queue with the least number of items pending
- for (QUEUEPOOL::iterator it = m_queues.begin(); it != m_queues.end(); ++it)
- {
- // always choose the first queue if we haven't selected one yet
- if (!pQueueAvailable)
- {
- pQueueAvailable = *it;
- }
- else
- {
- // pick this queue if it has less items pending than our previous selection
- if ( pQueueAvailable->Size() > (*it)->Size() )
- {
- pQueueAvailable = *it;
- }
- }
- }
-
- // if we picked a queue with pending items and we haven't reached out max pool limit
- if (pQueueAvailable && pQueueAvailable->Size() > 0 && m_queues.size() < MAX_DOWNLOAD_QUEUES)
- {
- // spawn a new queue
- pQueueAvailable = new CDownloadQueue();
- m_queues.push_back(pQueueAvailable);
- }
-
- assert(pQueueAvailable != NULL);
-
- return pQueueAvailable;
-}
-
+++ /dev/null
-#pragma once
-
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "DownloadQueue.h"
-#include "system.h"
-
-#define MAX_DOWNLOAD_QUEUES 3
-
-class CDownloadQueueManager
-{
-public:
- CDownloadQueueManager();
- virtual ~CDownloadQueueManager(void);
-
- VOID Initialize();
- TICKET RequestContent(const CStdString& aUrl, IDownloadQueueObserver* aObserver);
- TICKET RequestFile(const CStdString& aUrl, IDownloadQueueObserver* aObserver);
- TICKET RequestFile(const CStdString& aUrl, const CStdString& aFilePath, IDownloadQueueObserver* aObserver);
- void CancelRequests(IDownloadQueueObserver *aObserver);
-
-protected:
-
- CDownloadQueue* GetNextDownloadQueue();
-
- typedef std::vector<CDownloadQueue*> QUEUEPOOL;
- QUEUEPOOL m_queues;
-
- CCriticalSection m_critical;
-};
-
-// Single global instance of class is in cpp file
-extern CDownloadQueueManager g_DownloadManager;
SRCS += Crc32.cpp
SRCS += CryptThreading.cpp
SRCS += DatabaseUtils.cpp
-SRCS += DownloadQueue.cpp
-SRCS += DownloadQueueManager.cpp
SRCS += EndianSwap.cpp
SRCS += EdenVideoArtUpdater.cpp
SRCS += Environment.cpp
TestCrc32.cpp \
TestCryptThreading.cpp \
TestDatabaseUtils.cpp \
- TestDownloadQueue.cpp \
- TestDownloadQueueManager.cpp \
TestEndianSwap.cpp \
Testfastmemcpy.cpp \
Testfft.cpp \
+++ /dev/null
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "utils/DownloadQueue.h"
-#include "threads/Thread.h"
-#include "settings/Settings.h"
-#include "test/TestUtils.h"
-
-#include "gtest/gtest.h"
-
-class CTestDownloadQueueThread : public CThread
-{
-public:
- CTestDownloadQueueThread() :
- CThread("TestDownloadQueue"){}
-};
-
-/* Need to set some settings for network connectivity when an
- * http/https url is tested.
- */
-class TestDownloadQueue : public testing::Test
-{
-protected:
- TestDownloadQueue()
- {
- CSettingsCategory* net = CSettings::Get().AddCategory(4, "network", 798);
- CSettings::Get().AddBool(net, "network.usehttpproxy", 708, false);
- CSettings::Get().AddString(net, "network.httpproxyserver", 706, "",
- EDIT_CONTROL_INPUT);
- CSettings::Get().AddString(net, "network.httpproxyport", 730, "8080",
- EDIT_CONTROL_NUMBER_INPUT, false, 707);
- CSettings::Get().AddString(net, "network.httpproxyusername", 1048, "",
- EDIT_CONTROL_INPUT);
- CSettings::Get().AddString(net, "network.httpproxypassword", 733, "",
- EDIT_CONTROL_HIDDEN_INPUT,true,733);
- CSettings::Get().AddInt(net, "network.bandwidth", 14041, 0, 0, 512, 100*1024,
- SPIN_CONTROL_INT_PLUS, 14048, 351);
- }
-
- ~TestDownloadQueue()
- {
- CSettings::Get().Clear();
- }
-};
-
-TEST_F(TestDownloadQueue, RequestContent)
-{
- IDownloadQueueObserver observer;
- CDownloadQueue queue;
- CTestDownloadQueueThread thread;
- unsigned int count;
-
- std::vector<CStdString> urls =
- CXBMCTestUtils::Instance().getTestDownloadQueueUrls();
-
- std::vector<CStdString>::iterator it;
- count = 0;
- for (it = urls.begin(); it < urls.end(); it++)
- {
- std::cout << "Testing URL: " << *it << std::endl;
- TICKET t = queue.RequestContent(*it, &observer);
- EXPECT_EQ(count, t.dwItemId);
- count++;
- }
-
- thread.Sleep(1000);
- queue.Flush();
- EXPECT_EQ(0, queue.Size());
-}
-
-TEST_F(TestDownloadQueue, RequestFile)
-{
- IDownloadQueueObserver observer;
- CDownloadQueue queue;
- CTestDownloadQueueThread thread;
- unsigned int count;
-
- std::vector<CStdString> urls =
- CXBMCTestUtils::Instance().getTestDownloadQueueUrls();
-
- std::vector<CStdString>::iterator it;
- count = 0;
- for (it = urls.begin(); it < urls.end(); it++)
- {
- std::cout << "Testing URL: " << *it << std::endl;
- TICKET t = queue.RequestFile(*it, &observer);
- EXPECT_EQ(count, t.dwItemId);
- count++;
- }
-
- thread.Sleep(1000);
- queue.Flush();
- EXPECT_EQ(0, queue.Size());
-}
+++ /dev/null
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "utils/DownloadQueueManager.h"
-#include "threads/Thread.h"
-#include "settings/Settings.h"
-#include "test/TestUtils.h"
-
-#include "gtest/gtest.h"
-
-class CTestDownloadQueueManagerThread : public CThread
-{
-public:
- CTestDownloadQueueManagerThread() :
- CThread("TestDownloadQueueManager"){}
-};
-
-/* Need to set some settings for network connectivity when an
- * http/https url is tested.
- */
-class TestDownloadQueueManager : public testing::Test
-{
-protected:
- TestDownloadQueueManager()
- {
- /* TODO
- CSettingsCategory* net = CSettings::Get().AddCategory(4, "network", 798);
- CSettings::Get().AddBool(net, "network.usehttpproxy", 708, false);
- CSettings::Get().AddString(net, "network.httpproxyserver", 706, "",
- EDIT_CONTROL_INPUT);
- CSettings::Get().AddString(net, "network.httpproxyport", 730, "8080",
- EDIT_CONTROL_NUMBER_INPUT, false, 707);
- CSettings::Get().AddString(net, "network.httpproxyusername", 1048, "",
- EDIT_CONTROL_INPUT);
- CSettings::Get().AddString(net, "network.httpproxypassword", 733, "",
- EDIT_CONTROL_HIDDEN_INPUT,true,733);
- CSettings::Get().AddInt(net, "network.bandwidth", 14041, 0, 0, 512, 100*1024,
- SPIN_CONTROL_INT_PLUS, 14048, 351);
- */
- }
-
- ~TestDownloadQueueManager()
- {
- CSettings::Get().Unload();
- }
-};
-
-TEST_F(TestDownloadQueueManager, RequestContent)
-{
- IDownloadQueueObserver observer;
- CTestDownloadQueueManagerThread thread;
- int count;
-
- std::vector<CStdString> urls =
- CXBMCTestUtils::Instance().getTestDownloadQueueUrls();
-
- std::vector<CStdString>::iterator it;
- count = 0;
- for (it = urls.begin(); it < urls.end(); it++)
- {
- std::cout << "Testing URL: " << *it << std::endl;
- TICKET t = g_DownloadManager.RequestContent(*it, &observer);
- std::cout << " Ticket Item ID: " << t.dwItemId << std::endl;
- count++;
- }
-
- thread.Sleep(1000);
-}
-
-TEST_F(TestDownloadQueueManager, RequestFile)
-{
- IDownloadQueueObserver observer;
- CTestDownloadQueueManagerThread thread;
- int count;
-
- std::vector<CStdString> urls =
- CXBMCTestUtils::Instance().getTestDownloadQueueUrls();
-
- std::vector<CStdString>::iterator it;
- count = 0;
- for (it = urls.begin(); it < urls.end(); it++)
- {
- std::cout << "Testing URL: " << *it << std::endl;
- TICKET t = g_DownloadManager.RequestFile(*it, &observer);
- std::cout << " Ticket Item ID: " << t.dwItemId << std::endl;
- count++;
- }
-
- thread.Sleep(1000);
-}