Audacity 3.2.0
DataUploader.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*!********************************************************************
3
4 Audacity: A Digital Audio Editor
5
6 DataUploader.h
7
8 Dmitry Vedenko
9
10**********************************************************************/
11
12#pragma once
13
14#include <cstdint>
15#include <functional>
16#include <memory>
17#include <mutex>
18#include <vector>
19
20#include "CloudSyncDTO.h"
21#include "NetworkUtils.h"
22
24
26{
27class ServiceConfig;
28}
29
31{
33
34class DataUploader final
35{
36 DataUploader() = default;
38
39 DataUploader(const DataUploader&) = delete;
43
44public:
45 static DataUploader& Get();
46
47 void Upload(
48 CancellationContextPtr cancellationContex, const ServiceConfig& config,
49 const UploadUrls& target, std::vector<uint8_t> data,
50 std::function<void(ResponseResult)> callback,
51 std::function<void(double)> progressCallback = {});
52
53 void Upload(
54 CancellationContextPtr cancellationContex, const ServiceConfig& config,
55 const UploadUrls& target, std::string filePath,
56 std::function<void(ResponseResult)> callback,
57 std::function<void(double)> progressCallback = {});
58
59private:
60 struct UploadOperation;
61
62 void RemoveResponse(UploadOperation& response);
63
64 std::mutex mResponseMutex;
65
66 using ResponsesList = std::vector<std::shared_ptr<UploadOperation>>;
68};
69
70} // namespace audacity::cloud::audiocom::sync
Configuration for the audio.com.
Definition: ServiceConfig.h:25
Class used to track the upload operation.
Definition: UploadService.h:93
std::vector< std::shared_ptr< UploadOperation > > ResponsesList
Definition: DataUploader.h:66
DataUploader(const DataUploader &)=delete
void Upload(CancellationContextPtr cancellationContex, const ServiceConfig &config, const UploadUrls &target, std::vector< uint8_t > data, std::function< void(ResponseResult)> callback, std::function< void(double)> progressCallback={})
DataUploader & operator=(const DataUploader &)=delete
void RemoveResponse(UploadOperation &response)
DataUploader & operator=(DataUploader &&)=delete
std::shared_ptr< CancellationContext > CancellationContextPtr