aboutsummaryrefslogtreecommitdiff
path: root/backends/cloud/downloadrequest.cpp
diff options
context:
space:
mode:
authorAlexander Tkachev2016-07-14 09:27:08 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commit1a53dccf51aaf02ca4d0d7a176cca20d385d1ac4 (patch)
tree5cbf5f7456dca1b02a7cd53b4f77a1d3b6bf5ae3 /backends/cloud/downloadrequest.cpp
parentb4e9e35e07538a118588742aff6fd4a7a2b4d600 (diff)
downloadscummvm-rg350-1a53dccf51aaf02ca4d0d7a176cca20d385d1ac4.tar.gz
scummvm-rg350-1a53dccf51aaf02ca4d0d7a176cca20d385d1ac4.tar.bz2
scummvm-rg350-1a53dccf51aaf02ca4d0d7a176cca20d385d1ac4.zip
CLOUD: Update DownloadRequest
It now uses a dynamically allocated 1 MB buffer.
Diffstat (limited to 'backends/cloud/downloadrequest.cpp')
-rw-r--r--backends/cloud/downloadrequest.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/backends/cloud/downloadrequest.cpp b/backends/cloud/downloadrequest.cpp
index c95b8b81af..43bb02a756 100644
--- a/backends/cloud/downloadrequest.cpp
+++ b/backends/cloud/downloadrequest.cpp
@@ -29,7 +29,7 @@ namespace Cloud {
DownloadRequest::DownloadRequest(Storage *storage, Storage::BoolCallback callback, Networking::ErrorCallback ecb, Common::String remoteFileId, Common::DumpFile *dumpFile):
Request(nullptr, ecb), _boolCallback(callback), _localFile(dumpFile), _remoteFileId(remoteFileId), _storage(storage),
- _remoteFileStream(nullptr), _workingRequest(nullptr), _ignoreCallback(false) {
+ _remoteFileStream(nullptr), _workingRequest(nullptr), _ignoreCallback(false), _buffer(new byte[DOWNLOAD_REQUEST_BUFFER_SIZE]) {
start();
}
@@ -38,6 +38,7 @@ DownloadRequest::~DownloadRequest() {
if (_workingRequest) _workingRequest->finish();
delete _boolCallback;
delete _localFile;
+ delete[] _buffer;
}
void DownloadRequest::start() {
@@ -84,12 +85,10 @@ void DownloadRequest::handle() {
return;
}
- const int kBufSize = 640 * 1024; //640 KB is enough to everyone?..
- char buf[kBufSize];
- uint32 readBytes = _remoteFileStream->read(buf, kBufSize);
+ uint32 readBytes = _remoteFileStream->read(_buffer, DOWNLOAD_REQUEST_BUFFER_SIZE);
if (readBytes != 0)
- if (_localFile->write(buf, readBytes) != readBytes) {
+ if (_localFile->write(_buffer, readBytes) != readBytes) {
warning("DownloadRequest: unable to write all received bytes into output file");
finishError(Networking::ErrorResponse(this, false, true, "", -1));
return;