blob: fd1dab10e115068b384243a9b2bee5aee5e97f29 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#pragma once
#include "platform/http_request.hpp"
#include "std/function.hpp"
#include "std/string.hpp"
#include "std/utility.hpp"
#include "std/vector.hpp"
namespace storage
{
// This interface encapsulates HTTP routines for receiving servers
// URLs and downloading a single map file.
class MapFilesDownloader
{
public:
// Denotes bytes downloaded and total number of bytes.
using TProgress = pair<int64_t, int64_t>;
using TFileDownloadedCallback = function<void(downloader::HttpRequest::Status status, TProgress const & progress)>;
using TDownloadingProgressCallback = function<void(TProgress const & progress)>;
using TServersListCallback = function<void(vector<string> & urls)>;
virtual ~MapFilesDownloader() = default;
/// Asynchronously receives a list of all servers that can be asked
/// for a map file and invokes callback on the original thread.
virtual void GetServersList(TServersListCallback const & callback) = 0;
/// Asynchronously downloads a map file, periodically invokes
/// onProgress callback and finally invokes onDownloaded
/// callback. Both callbacks will be invoked on the original thread.
virtual void DownloadMapFile(vector<string> const & urls, string const & path, int64_t size,
TFileDownloadedCallback const & onDownloaded,
TDownloadingProgressCallback const & onProgress) = 0;
/// Returns current downloading progress.
virtual TProgress GetDownloadingProgress() = 0;
/// Returns true when downloader does not perform any job.
virtual bool IsIdle() = 0;
/// Resets downloader to the idle state.
virtual void Reset() = 0;
};
} // namespace storage
|