Audacity 3.2.0
Classes | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
audacity::cloud::audiocom::sync::DataUploader Class Referencefinal

#include <DataUploader.h>

Collaboration diagram for audacity::cloud::audiocom::sync::DataUploader:
[legend]

Classes

struct  UploadOperation
 

Public Member Functions

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={})
 
void Upload (CancellationContextPtr cancellationContex, const ServiceConfig &config, const UploadUrls &target, std::string filePath, std::function< void(ResponseResult)> callback, std::function< void(double)> progressCallback={})
 

Static Public Member Functions

static DataUploaderGet ()
 

Private Types

using ResponsesList = std::vector< std::shared_ptr< UploadOperation > >
 

Private Member Functions

 DataUploader ()=default
 
 ~DataUploader ()
 
 DataUploader (const DataUploader &)=delete
 
 DataUploader (DataUploader &&)=delete
 
DataUploaderoperator= (const DataUploader &)=delete
 
DataUploaderoperator= (DataUploader &&)=delete
 
void RemoveResponse (UploadOperation &response)
 

Private Attributes

std::mutex mResponseMutex
 
ResponsesList mResponses
 

Detailed Description

Definition at line 34 of file DataUploader.h.

Member Typedef Documentation

◆ ResponsesList

using audacity::cloud::audiocom::sync::DataUploader::ResponsesList = std::vector<std::shared_ptr<UploadOperation> >
private

Definition at line 66 of file DataUploader.h.

Constructor & Destructor Documentation

◆ DataUploader() [1/3]

audacity::cloud::audiocom::sync::DataUploader::DataUploader ( )
privatedefault

◆ ~DataUploader()

audacity::cloud::audiocom::sync::DataUploader::~DataUploader ( )
private

Definition at line 205 of file DataUploader.cpp.

206{
207}

◆ DataUploader() [2/3]

audacity::cloud::audiocom::sync::DataUploader::DataUploader ( const DataUploader )
privatedelete

◆ DataUploader() [3/3]

audacity::cloud::audiocom::sync::DataUploader::DataUploader ( DataUploader &&  )
privatedelete

Member Function Documentation

◆ Get()

DataUploader & audacity::cloud::audiocom::sync::DataUploader::Get ( )
static

◆ operator=() [1/2]

DataUploader & audacity::cloud::audiocom::sync::DataUploader::operator= ( const DataUploader )
privatedelete

◆ operator=() [2/2]

DataUploader & audacity::cloud::audiocom::sync::DataUploader::operator= ( DataUploader &&  )
privatedelete

◆ RemoveResponse()

void audacity::cloud::audiocom::sync::DataUploader::RemoveResponse ( UploadOperation response)
private

Definition at line 275 of file DataUploader.cpp.

276{
277 auto lock = std::lock_guard { mResponseMutex };
278
279 mResponses.erase(
280 std::remove_if(
281 mResponses.begin(), mResponses.end(),
282 [&response](const auto& item) { return item.get() == &response; }),
283 mResponses.end());
284}

References mResponseMutex, and mResponses.

Referenced by audacity::cloud::audiocom::sync::DataUploader::UploadOperation::CleanUp().

Here is the caller graph for this function:

◆ Upload() [1/2]

void audacity::cloud::audiocom::sync::DataUploader::Upload ( CancellationContextPtr  cancellationContex,
const ServiceConfig config,
const UploadUrls target,
std::string  filePath,
std::function< void(ResponseResult)>  callback,
std::function< void(double)>  progressCallback = {} 
)

Definition at line 240 of file DataUploader.cpp.

245{
246 if (!callback)
247 callback = [](auto...) {};
248
249 if (!progressCallback)
250 progressCallback = [](auto...) { return true; };
251
252 if (!cancellationContex)
253 cancellationContex = concurrency::CancellationContext::Create();
254
255 if (!wxFileExists(audacity::ToWXString(filePath)))
256 {
257 if (callback)
258 callback(ResponseResult {
260 audacity::ToUTF8(XO("File not found").Translation()) });
261
262 return;
263 }
264
265 auto lock = std::lock_guard { mResponseMutex };
266
267 mResponses.emplace_back(std::make_shared<UploadOperation>(
268 *this, cancellationContex, target, std::move(filePath),
270 std::move(callback), std::move(progressCallback)));
271
272 mResponses.back()->PerformUpload(RetriesCount);
273}
XO("Cut/Copy/Paste")
std::string ToUTF8(const std::wstring &wstr)
wxString ToWXString(const std::string &str)

References audacity::network_manager::common_content_types::ApplicationXOctetStream, audacity::concurrency::CancellationContext::Create(), mResponseMutex, mResponses, audacity::cloud::audiocom::sync::RetriesCount, audacity::ToUTF8(), audacity::ToWXString(), audacity::cloud::audiocom::UnknownError, and XO().

Here is the call graph for this function:

◆ Upload() [2/2]

void audacity::cloud::audiocom::sync::DataUploader::Upload ( CancellationContextPtr  cancellationContex,
const ServiceConfig config,
const UploadUrls target,
std::vector< uint8_t >  data,
std::function< void(ResponseResult)>  callback,
std::function< void(double)>  progressCallback = {} 
)

Definition at line 215 of file DataUploader.cpp.

220{
221 if (!callback)
222 callback = [](auto...) {};
223
224 if (!progressCallback)
225 progressCallback = [](auto...) { return true; };
226
227 if (!cancellationContex)
228 cancellationContex = concurrency::CancellationContext::Create();
229
230 auto lock = std::lock_guard { mResponseMutex };
231
232 mResponses.emplace_back(std::make_unique<UploadOperation>(
233 *this, cancellationContex, target, std::move(data),
235 std::move(callback), std::move(progressCallback)));
236
237 mResponses.back()->PerformUpload(RetriesCount);
238}

References audacity::network_manager::common_content_types::ApplicationXOctetStream, audacity::concurrency::CancellationContext::Create(), mResponseMutex, mResponses, and audacity::cloud::audiocom::sync::RetriesCount.

Referenced by audacity::cloud::audiocom::sync::MissingBlocksUploader::ConsumeBlock(), audacity::cloud::audiocom::sync::LocalProjectSnapshot::OnSnapshotCreated(), audacity::cloud::audiocom::sync::MixdownUploader::UploadMixdown(), and audacity::cloud::audiocom::sync::anonymous_namespace{ResumedSnaphotUploadOperation.cpp}::ResumedSnaphotUploadOperation::UploadSnapshot().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mResponseMutex

std::mutex audacity::cloud::audiocom::sync::DataUploader::mResponseMutex
private

Definition at line 64 of file DataUploader.h.

Referenced by RemoveResponse(), and Upload().

◆ mResponses

ResponsesList audacity::cloud::audiocom::sync::DataUploader::mResponses
private

Definition at line 67 of file DataUploader.h.

Referenced by RemoveResponse(), and Upload().


The documentation for this class was generated from the following files: