Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Zolotarev <deathbaba@gmail.com>2011-11-10 13:23:26 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:27:33 +0300
commitecb217280fefcf2a4306f39245c881ad38a96f16 (patch)
tree39b49c77f630c1e6c85dbccd9b2578f3cebd72c8 /platform/chunks_download_strategy.cpp
parent2dc0ca689c0ea24b5e8b28e89cabbf2bbe945fb5 (diff)
[downloader] Some fixes after code review
Diffstat (limited to 'platform/chunks_download_strategy.cpp')
-rw-r--r--platform/chunks_download_strategy.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/platform/chunks_download_strategy.cpp b/platform/chunks_download_strategy.cpp
index 88ead660a8..bc9fe13fdd 100644
--- a/platform/chunks_download_strategy.cpp
+++ b/platform/chunks_download_strategy.cpp
@@ -8,7 +8,7 @@
namespace downloader
{
-ChunksDownloadStrategy::RangeT const ChunksDownloadStrategy::INVALID_RANGE = RangeT(-1, -1);
+ChunksDownloadStrategy::RangeT const ChunksDownloadStrategy::INVALID_RANGE = RangeT(INVALID_CHUNK, INVALID_CHUNK);
ChunksDownloadStrategy::ChunksDownloadStrategy(vector<string> const & urls, int64_t fileSize,
int64_t chunkSize)
@@ -28,21 +28,21 @@ void ChunksDownloadStrategy::SetChunksToDownload(RangesContainerT & chunks)
m_chunksToDownload.swap(chunks);
}
-void ChunksDownloadStrategy::ChunkFinished(bool successfully, int64_t begRange, int64_t endRange)
+void ChunksDownloadStrategy::ChunkFinished(bool successfully, RangeT const & range)
{
- RangeT const chunk(begRange, endRange);
// find server which was downloading this chunk
for (ServersT::iterator it = m_servers.begin(); it != m_servers.end(); ++it)
{
- if (it->second == chunk)
+ if (it->second == range)
{
if (successfully)
it->second = INVALID_RANGE;
else
{
+ // @TODO implement connection retry
// remove failed server and mark chunk as not downloaded
m_servers.erase(it);
- m_chunksToDownload.insert(chunk);
+ m_chunksToDownload.insert(range);
}
break;
}
@@ -50,8 +50,7 @@ void ChunksDownloadStrategy::ChunkFinished(bool successfully, int64_t begRange,
}
ChunksDownloadStrategy::ResultT ChunksDownloadStrategy::NextChunk(string & outUrl,
- int64_t & begRange,
- int64_t & endRange)
+ RangeT & range)
{
if (m_servers.empty())
return EDownloadFailed;
@@ -80,8 +79,7 @@ ChunksDownloadStrategy::ResultT ChunksDownloadStrategy::NextChunk(string & outUr
// found not used server
m_servers[i].second = nextChunk;
outUrl = m_servers[i].first;
- begRange = nextChunk.first;
- endRange = nextChunk.second;
+ range = nextChunk;
m_chunksToDownload.erase(m_chunksToDownload.begin());
return ENextChunk;
}