![]() |
Audacity 3.2.0
|
#include <RemoteProjectSnapshot.h>
Classes | |
| struct | Tag |
Public Member Functions | |
| RemoteProjectSnapshot (Tag, ProjectInfo projectInfo, SnapshotInfo snapshotInfo, std::string path, RemoteProjectSnapshotStateCallback callback, bool downloadDetached) | |
| ~RemoteProjectSnapshot () | |
| RemoteProjectSnapshot (const RemoteProjectSnapshot &)=delete | |
| RemoteProjectSnapshot & | operator= (const RemoteProjectSnapshot &)=delete |
| RemoteProjectSnapshot (RemoteProjectSnapshot &&)=delete | |
| RemoteProjectSnapshot & | operator= (RemoteProjectSnapshot &&)=delete |
| void | Cancel () |
| TransferStats | GetTransferStats () const |
| std::string_view | GetProjectId () const |
Static Public Member Functions | |
| static std::shared_ptr< RemoteProjectSnapshot > | Sync (ProjectInfo projectInfo, SnapshotInfo snapshotInfo, std::string path, RemoteProjectSnapshotStateCallback callback, bool downloadDetached) |
Private Types | |
| enum class | State { Downloading , Cancelled , Failed , Succeeded } |
| using | SuccessHandler = std::function< void(audacity::network_manager::ResponsePtr)> |
| using | Clock = std::chrono::steady_clock |
| using | TimePoint = Clock::time_point |
Private Member Functions | |
| std::string | AttachOriginalDB () |
| void | SetupBlocksCopy (const std::string &dbName, std::unordered_set< std::string > blocks) |
| std::unordered_set< std::string > | CalculateKnownBlocks (const std::string &attachedDbName) const |
| void | DoCancel () |
| void | DownloadBlob (std::string url, SuccessHandler onSuccess, int retries=3) |
| void | OnProjectBlobDownloaded (audacity::network_manager::ResponsePtr response) |
| void | OnBlockDownloaded (std::string blockHash, audacity::network_manager::ResponsePtr response) |
| void | OnFailure (ResponseResult result) |
| void | RemoveResponse (audacity::network_manager::IResponse *response) |
| void | MarkProjectInDB (bool successfulDownload) |
| void | ReportProgress () |
| bool | InProgress () const |
| void | RequestsThread () |
| void | SetState (State state) |
| void | CleanupOrphanBlocks () |
Private Attributes | |
| const std::string | mSnapshotDBName |
| const ProjectInfo | mProjectInfo |
| const SnapshotInfo | mSnapshotInfo |
| const std::string | mPath |
| RemoteProjectSnapshotStateCallback | mCallback |
| std::vector< std::string > | mAttachedDBNames |
| std::atomic< State > | mState { State::Downloading } |
| TimePoint | mStartTime { Clock::now() } |
| TimePoint | mEndTime |
| std::thread | mRequestsThread |
| std::mutex | mRequestsMutex |
| std::condition_variable | mRequestsCV |
| std::vector< std::pair< std::string, SuccessHandler > > | mRequests |
| int | mRequestsInProgress { 0 } |
| size_t | mNextRequestIndex { 0 } |
| std::mutex | mResponsesMutex |
| std::vector< std::shared_ptr< audacity::network_manager::IResponse > > | mResponses |
| std::condition_variable | mResponsesEmptyCV |
| std::atomic< int64_t > | mDownloadedBlocks { 0 } |
| std::atomic< int64_t > | mCopiedBlocks { 0 } |
| std::atomic< int64_t > | mDownloadedBytes { 0 } |
| int64_t | mMissingBlocks { 0 } |
| std::optional< std::future< bool > > | mCopyBlocksFuture |
| std::atomic< bool > | mProjectDownloaded { false } |
| bool | mNothingToDo { false } |
| const bool | mDownloadDetached { false } |
Definition at line 51 of file RemoteProjectSnapshot.h.
|
private |
Definition at line 134 of file RemoteProjectSnapshot.h.
|
private |
Definition at line 89 of file RemoteProjectSnapshot.h.
|
private |
Definition at line 135 of file RemoteProjectSnapshot.h.
|
strongprivate |
| Enumerator | |
|---|---|
| Downloading | |
| Cancelled | |
| Failed | |
| Succeeded | |
Definition at line 81 of file RemoteProjectSnapshot.h.
| audacity::cloud::audiocom::sync::RemoteProjectSnapshot::RemoteProjectSnapshot | ( | Tag | , |
| ProjectInfo | projectInfo, | ||
| SnapshotInfo | snapshotInfo, | ||
| std::string | path, | ||
| RemoteProjectSnapshotStateCallback | callback, | ||
| bool | downloadDetached | ||
| ) |
Definition at line 60 of file RemoteProjectSnapshot.cpp.
References AttachOriginalDB(), audacity::cloud::audiocom::sync::SnapshotInfo::Blocks, CalculateKnownBlocks(), CleanupOrphanBlocks(), audacity::sqlite::Connection::CreateStatement(), audacity::cloud::audiocom::sync::SnapshotInfo::FileUrl, audacity::cloud::audiocom::sync::CloudProjectsDatabase::Get(), audacity::cloud::audiocom::sync::CloudProjectsDatabase::GetConnection(), audacity::cloud::audiocom::sync::CloudProjectsDatabase::GetProjectData(), audacity::cloud::audiocom::sync::SnapshotInfo::Id, audacity::cloud::audiocom::sync::ProjectInfo::Id, MarkProjectInDB(), mAttachedDBNames, mCallback, mDownloadDetached, mMissingBlocks, mNothingToDo, mPath, mProjectInfo, mRequests, mRequestsThread, mSnapshotDBName, mSnapshotInfo, name, RequestsThread(), SetupBlocksCopy(), audacity::cloud::audiocom::sync::DBProjectData::SyncStatusSynced, and ToUpper().
| audacity::cloud::audiocom::sync::RemoteProjectSnapshot::~RemoteProjectSnapshot | ( | ) |
Definition at line 144 of file RemoteProjectSnapshot.cpp.
References audacity::sqlite::Connection::CreateStatement(), DoCancel(), audacity::cloud::audiocom::sync::CloudProjectsDatabase::Get(), audacity::cloud::audiocom::sync::CloudProjectsDatabase::GetConnection(), audacity::cloud::audiocom::sync::anonymous_namespace{RemoteProjectSnapshot.cpp}::ListAttachedDatabases(), mCopyBlocksFuture, mRequestsThread, mResponses, mResponsesEmptyCV, and mResponsesMutex.
|
delete |
|
delete |
|
private |
Definition at line 226 of file RemoteProjectSnapshot.cpp.
References audacity::sqlite::Connection::CreateStatement(), audacity::cloud::audiocom::sync::CloudProjectsDatabase::Get(), audacity::cloud::audiocom::sync::CloudProjectsDatabase::GetConnection(), audacity::cloud::audiocom::sync::CloudProjectsDatabase::GetProjectData(), audacity::cloud::audiocom::sync::ProjectInfo::Id, mAttachedDBNames, and mProjectInfo.
Referenced by RemoteProjectSnapshot().
|
private |
Definition at line 315 of file RemoteProjectSnapshot.cpp.
References audacity::cloud::audiocom::sync::SnapshotInfo::Blocks, fn, audacity::cloud::audiocom::sync::CloudProjectsDatabase::Get(), audacity::cloud::audiocom::sync::CloudProjectsDatabase::GetConnection(), audacity::cloud::audiocom::sync::ProjectInfo::Id, mProjectInfo, mSnapshotInfo, and ToUpper().
Referenced by RemoteProjectSnapshot().
| void audacity::cloud::audiocom::sync::RemoteProjectSnapshot::Cancel | ( | ) |
Definition at line 196 of file RemoteProjectSnapshot.cpp.
References audacity::cloud::audiocom::Cancelled, DoCancel(), mCallback, mCopiedBlocks, mDownloadedBlocks, mMissingBlocks, and mProjectDownloaded.
|
private |
Definition at line 768 of file RemoteProjectSnapshot.cpp.
References BasicUI::Get(), and ToUpper().
Referenced by RemoteProjectSnapshot().
|
private |
Definition at line 353 of file RemoteProjectSnapshot.cpp.
References Cancelled, Downloading, mRequestsCV, mResponses, mResponsesMutex, mState, and SetState().
Referenced by Cancel(), and ~RemoteProjectSnapshot().
|
private |
Definition at line 369 of file RemoteProjectSnapshot.cpp.
References audacity::cloud::audiocom::Cancelled, audacity::cloud::audiocom::ConnectionFailed, audacity::network_manager::NetworkManager::doGet(), DownloadBlob(), audacity::network_manager::NetworkManager::GetInstance(), audacity::cloud::audiocom::GetResponseResult(), mDownloadedBytes, mResponses, mResponsesMutex, RemoveResponse(), and audacity::cloud::audiocom::Success.
Referenced by DownloadBlob().
| std::string_view audacity::cloud::audiocom::sync::RemoteProjectSnapshot::GetProjectId | ( | ) | const |
Definition at line 221 of file RemoteProjectSnapshot.cpp.
References audacity::cloud::audiocom::sync::ProjectInfo::Id, and mProjectInfo.
| TransferStats audacity::cloud::audiocom::sync::RemoteProjectSnapshot::GetTransferStats | ( | ) | const |
Definition at line 206 of file RemoteProjectSnapshot.cpp.
References Downloading, mDownloadedBlocks, mDownloadedBytes, mEndTime, mProjectDownloaded, mStartTime, mState, audacity::cloud::audiocom::TransferStats::SetBlocksTransferred(), audacity::cloud::audiocom::TransferStats::SetBytesTransferred(), audacity::cloud::audiocom::TransferStats::SetProjectFilesTransferred(), and audacity::cloud::audiocom::TransferStats::SetTransferDuration().
|
private |
Definition at line 717 of file RemoteProjectSnapshot.cpp.
References mState.
Referenced by SetupBlocksCopy().
|
private |
Definition at line 661 of file RemoteProjectSnapshot.cpp.
References BasicUI::Get(), and audacity::cloud::audiocom::sync::DBProjectData::ProjectId.
Referenced by RemoteProjectSnapshot().
|
private |
Definition at line 540 of file RemoteProjectSnapshot.cpp.
References audacity::cloud::audiocom::sync::DecompressBlock(), BasicUI::Get(), audacity::cloud::audiocom::InternalClientError, audacity::cloud::audiocom::sync::anonymous_namespace{RemoteProjectSnapshot.cpp}::ReadResponseData(), audacity::ToUTF8(), and XO().
|
private |
Definition at line 630 of file RemoteProjectSnapshot.cpp.
Referenced by SetupBlocksCopy().
|
private |
Definition at line 445 of file RemoteProjectSnapshot.cpp.
References BasicUI::Get(), audacity::cloud::audiocom::InternalClientError, IsLittleEndian(), audacity::cloud::audiocom::sync::anonymous_namespace{RemoteProjectSnapshot.cpp}::ReadResponseData(), SwapIntBytes(), audacity::ToUTF8(), and audacity::cloud::audiocom::UnexpectedResponse.
|
delete |
|
delete |
|
private |
Definition at line 640 of file RemoteProjectSnapshot.cpp.
Referenced by DownloadBlob().
|
private |
Definition at line 690 of file RemoteProjectSnapshot.cpp.
References mState.
Referenced by SetupBlocksCopy().
|
private |
Definition at line 722 of file RemoteProjectSnapshot.cpp.
Referenced by RemoteProjectSnapshot().
|
private |
Definition at line 760 of file RemoteProjectSnapshot.cpp.
References mState.
Referenced by DoCancel().
|
private |
Definition at line 251 of file RemoteProjectSnapshot.cpp.
References audacity::sqlite::Connection::CreateStatement(), audacity::cloud::audiocom::sync::CloudProjectsDatabase::Get(), audacity::cloud::audiocom::sync::CloudProjectsDatabase::GetConnection(), InProgress(), audacity::cloud::audiocom::InternalClientError, mCopiedBlocks, mCopyBlocksFuture, mSnapshotDBName, OnFailure(), ReportProgress(), and audacity::ToUTF8().
Referenced by RemoteProjectSnapshot().
|
static |
Definition at line 168 of file RemoteProjectSnapshot.cpp.
References audacity::cloud::audiocom::InternalClientError, audacity::ToUTF8(), and XO().
|
private |
Definition at line 130 of file RemoteProjectSnapshot.h.
Referenced by AttachOriginalDB(), and RemoteProjectSnapshot().
|
private |
Definition at line 128 of file RemoteProjectSnapshot.h.
Referenced by Cancel(), and RemoteProjectSnapshot().
|
private |
Definition at line 155 of file RemoteProjectSnapshot.h.
Referenced by Cancel(), and SetupBlocksCopy().
|
private |
Definition at line 160 of file RemoteProjectSnapshot.h.
Referenced by SetupBlocksCopy(), and ~RemoteProjectSnapshot().
|
private |
Definition at line 165 of file RemoteProjectSnapshot.h.
Referenced by RemoteProjectSnapshot().
|
private |
Definition at line 154 of file RemoteProjectSnapshot.h.
Referenced by Cancel(), and GetTransferStats().
|
private |
Definition at line 156 of file RemoteProjectSnapshot.h.
Referenced by DownloadBlob(), and GetTransferStats().
|
private |
Definition at line 138 of file RemoteProjectSnapshot.h.
Referenced by GetTransferStats().
|
private |
Definition at line 158 of file RemoteProjectSnapshot.h.
Referenced by Cancel(), and RemoteProjectSnapshot().
|
private |
Definition at line 147 of file RemoteProjectSnapshot.h.
|
private |
Definition at line 164 of file RemoteProjectSnapshot.h.
Referenced by RemoteProjectSnapshot().
|
private |
Definition at line 127 of file RemoteProjectSnapshot.h.
Referenced by RemoteProjectSnapshot().
|
private |
Definition at line 162 of file RemoteProjectSnapshot.h.
Referenced by Cancel(), and GetTransferStats().
|
private |
Definition at line 125 of file RemoteProjectSnapshot.h.
Referenced by AttachOriginalDB(), CalculateKnownBlocks(), GetProjectId(), and RemoteProjectSnapshot().
|
private |
Definition at line 144 of file RemoteProjectSnapshot.h.
Referenced by RemoteProjectSnapshot().
|
private |
Definition at line 142 of file RemoteProjectSnapshot.h.
Referenced by DoCancel().
|
private |
Definition at line 146 of file RemoteProjectSnapshot.h.
|
private |
Definition at line 141 of file RemoteProjectSnapshot.h.
|
private |
Definition at line 140 of file RemoteProjectSnapshot.h.
Referenced by RemoteProjectSnapshot(), and ~RemoteProjectSnapshot().
|
private |
Definition at line 151 of file RemoteProjectSnapshot.h.
Referenced by DoCancel(), DownloadBlob(), and ~RemoteProjectSnapshot().
|
private |
Definition at line 152 of file RemoteProjectSnapshot.h.
Referenced by ~RemoteProjectSnapshot().
|
private |
Definition at line 149 of file RemoteProjectSnapshot.h.
Referenced by DoCancel(), DownloadBlob(), and ~RemoteProjectSnapshot().
|
private |
Definition at line 124 of file RemoteProjectSnapshot.h.
Referenced by RemoteProjectSnapshot(), and SetupBlocksCopy().
|
private |
Definition at line 126 of file RemoteProjectSnapshot.h.
Referenced by CalculateKnownBlocks(), and RemoteProjectSnapshot().
|
private |
Definition at line 137 of file RemoteProjectSnapshot.h.
Referenced by GetTransferStats().
|
private |
Definition at line 132 of file RemoteProjectSnapshot.h.
Referenced by DoCancel(), and GetTransferStats().