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

map_files_downloader.hpp « storage - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1cd7b8b7b89af98a07438a3ab3c3949651624b1b (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
#pragma once

#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(bool success, 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