Commit a58012f7 authored by Josip Sokcevic's avatar Josip Sokcevic Committed by Commit Bot

Return CancelCallbackOnce in drive DownloadFile

Bug: 1007686
Change-Id: Ide3b3717d87de9cf6c49bd57684cd855f3d48b77
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2300049Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarOlya Kalitova <okalitova@chromium.org>
Reviewed-by: default avatarNaoki Fukino <fukino@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Cr-Commit-Position: refs/heads/master@{#790501}
parent 42816a8f
......@@ -184,7 +184,7 @@ void PluginVmDriveImageDownloadService::DispatchDownloadFile() {
void PluginVmDriveImageDownloadService::CancelDownload() {
DCHECK(cancel_callback_);
cancel_callback_.Run();
std::move(cancel_callback_).Run();
}
void PluginVmDriveImageDownloadService::ResetState() {
......
......@@ -79,7 +79,7 @@ class PluginVmDriveImageDownloadService {
int64_t total_bytes_downloaded_ = 0;
base::FilePath download_directory_{kPluginVmDriveDownloadDirectory};
base::FilePath download_file_path_;
google_apis::CancelCallback cancel_callback_;
google_apis::CancelCallbackOnce cancel_callback_;
base::WeakPtrFactory<PluginVmDriveImageDownloadService> weak_ptr_factory_{
this};
......
......@@ -123,7 +123,7 @@ class SimpleFakeDriveService : public drive::DummyDriveService {
bool cancel_callback_called() const { return cancel_callback_called_; }
// DriveServiceInterface override.
google_apis::CancelCallback DownloadFile(
google_apis::CancelCallbackOnce DownloadFile(
const base::FilePath& /*cache_path*/,
const std::string& /*resource_id*/,
const DownloadActionCallback& download_action_callback,
......@@ -135,7 +135,7 @@ class SimpleFakeDriveService : public drive::DummyDriveService {
// It is safe to use base::Unretained as this object will not get deleted
// before the end of the test.
return base::BindRepeating(&SimpleFakeDriveService::CancelCallback,
return base::BindOnce(&SimpleFakeDriveService::CancelCallback,
base::Unretained(this));
}
......
......@@ -63,7 +63,7 @@ google_apis::CancelCallback DriveServiceOnWorker::DeleteResource(
return google_apis::CancelCallback();
}
google_apis::CancelCallback DriveServiceOnWorker::DownloadFile(
google_apis::CancelCallbackOnce DriveServiceOnWorker::DownloadFile(
const base::FilePath& local_cache_path,
const std::string& resource_id,
const google_apis::DownloadActionCallback& download_action_callback,
......@@ -83,7 +83,7 @@ google_apis::CancelCallback DriveServiceOnWorker::DownloadFile(
RelayCallbackToTaskRunner(worker_task_runner_.get(), FROM_HERE,
progress_callback)));
return google_apis::CancelCallback();
return google_apis::CancelCallbackOnce();
}
google_apis::CancelCallback DriveServiceOnWorker::GetAboutResource(
......
......@@ -49,7 +49,7 @@ class DriveServiceOnWorker : public drive::DriveServiceInterface {
const std::string& etag,
const google_apis::EntryActionCallback& callback) override;
google_apis::CancelCallback DownloadFile(
google_apis::CancelCallbackOnce DownloadFile(
const base::FilePath& local_cache_path,
const std::string& resource_id,
const google_apis::DownloadActionCallback& download_action_callback,
......
......@@ -25,11 +25,12 @@
using google_apis::AboutResourceCallback;
using google_apis::AuthStatusCallback;
using google_apis::CancelCallback;
using google_apis::CancelCallbackOnce;
using google_apis::ChangeList;
using google_apis::ChangeListCallback;
using google_apis::DownloadActionCallback;
using google_apis::DRIVE_OTHER_ERROR;
using google_apis::DRIVE_PARSE_ERROR;
using google_apis::DownloadActionCallback;
using google_apis::DriveApiErrorCode;
using google_apis::EntryActionCallback;
using google_apis::FileList;
......@@ -499,7 +500,7 @@ CancelCallback DriveAPIService::GetStartPageToken(
return sender_->StartRequestWithAuthRetry(std::move(request));
}
CancelCallback DriveAPIService::DownloadFile(
CancelCallbackOnce DriveAPIService::DownloadFile(
const base::FilePath& local_cache_path,
const std::string& resource_id,
const DownloadActionCallback& download_action_callback,
......
......@@ -175,7 +175,7 @@ class DriveAPIService : public DriveServiceInterface,
google_apis::CancelCallback TrashResource(
const std::string& resource_id,
const google_apis::EntryActionCallback& callback) override;
google_apis::CancelCallback DownloadFile(
google_apis::CancelCallbackOnce DownloadFile(
const base::FilePath& local_cache_path,
const std::string& resource_id,
const google_apis::DownloadActionCallback& download_action_callback,
......
......@@ -426,7 +426,7 @@ class DriveServiceInterface : public DriveServiceBatchOperationsInterface {
//
// |download_action_callback| must not be null.
// |get_content_callback| and |progress_callback| may be null.
virtual google_apis::CancelCallback DownloadFile(
virtual google_apis::CancelCallbackOnce DownloadFile(
const base::FilePath& local_cache_path,
const std::string& resource_id,
const google_apis::DownloadActionCallback& download_action_callback,
......
......@@ -11,6 +11,7 @@
using google_apis::AboutResourceCallback;
using google_apis::AuthStatusCallback;
using google_apis::CancelCallback;
using google_apis::CancelCallbackOnce;
using google_apis::ChangeListCallback;
using google_apis::DownloadActionCallback;
using google_apis::EntryActionCallback;
......@@ -130,7 +131,7 @@ CancelCallback DummyDriveService::TrashResource(
const std::string& resource_id,
const EntryActionCallback& callback) { return CancelCallback(); }
CancelCallback DummyDriveService::DownloadFile(
CancelCallbackOnce DummyDriveService::DownloadFile(
const base::FilePath& local_cache_path,
const std::string& resource_id,
const DownloadActionCallback& download_action_callback,
......
......@@ -79,7 +79,7 @@ class DummyDriveService : public DriveServiceInterface {
google_apis::CancelCallback TrashResource(
const std::string& resource_id,
const google_apis::EntryActionCallback& callback) override;
google_apis::CancelCallback DownloadFile(
google_apis::CancelCallbackOnce DownloadFile(
const base::FilePath& local_cache_path,
const std::string& resource_id,
const google_apis::DownloadActionCallback& download_action_callback,
......
......@@ -30,6 +30,7 @@
#include "components/drive/drive_api_util.h"
#include "components/drive/file_system_core_util.h"
#include "google_apis/drive/drive_api_parser.h"
#include "google_apis/drive/drive_common_callbacks.h"
#include "google_apis/drive/test_util.h"
#include "net/base/escape.h"
#include "net/base/url_util.h"
......@@ -38,14 +39,15 @@ using google_apis::AboutResource;
using google_apis::AboutResourceCallback;
using google_apis::AuthStatusCallback;
using google_apis::CancelCallback;
using google_apis::CancelCallbackOnce;
using google_apis::ChangeList;
using google_apis::ChangeListCallback;
using google_apis::ChangeListOnceCallback;
using google_apis::ChangeResource;
using google_apis::DownloadActionCallback;
using google_apis::DRIVE_FILE_ERROR;
using google_apis::DRIVE_NO_CONNECTION;
using google_apis::DRIVE_OTHER_ERROR;
using google_apis::DownloadActionCallback;
using google_apis::DriveApiErrorCode;
using google_apis::EntryActionCallback;
using google_apis::FileList;
......@@ -56,8 +58,8 @@ using google_apis::GetContentCallback;
using google_apis::HTTP_BAD_REQUEST;
using google_apis::HTTP_CREATED;
using google_apis::HTTP_FORBIDDEN;
using google_apis::HTTP_NOT_FOUND;
using google_apis::HTTP_NO_CONTENT;
using google_apis::HTTP_NOT_FOUND;
using google_apis::HTTP_PRECONDITION;
using google_apis::HTTP_RESUME_INCOMPLETE;
using google_apis::HTTP_SUCCESS;
......@@ -759,7 +761,7 @@ CancelCallback FakeDriveService::TrashResource(
return CancelCallback();
}
CancelCallback FakeDriveService::DownloadFile(
CancelCallbackOnce FakeDriveService::DownloadFile(
const base::FilePath& local_cache_path,
const std::string& resource_id,
const DownloadActionCallback& download_action_callback,
......@@ -773,7 +775,7 @@ CancelCallback FakeDriveService::DownloadFile(
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(download_action_callback, DRIVE_NO_CONNECTION,
base::FilePath()));
return CancelCallback();
return CancelCallbackOnce();
}
EntryInfo* entry = FindEntryByResourceId(resource_id);
......@@ -781,7 +783,7 @@ CancelCallback FakeDriveService::DownloadFile(
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(download_action_callback, HTTP_NOT_FOUND,
base::FilePath()));
return CancelCallback();
return CancelCallbackOnce();
}
const FileResource* file = entry->change_resource.file();
......@@ -806,7 +808,7 @@ CancelCallback FakeDriveService::DownloadFile(
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(download_action_callback, DRIVE_FILE_ERROR,
base::FilePath()));
return CancelCallback();
return CancelCallbackOnce();
}
if (!progress_callback.is_null()) {
......@@ -821,7 +823,7 @@ CancelCallback FakeDriveService::DownloadFile(
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::BindOnce(download_action_callback, HTTP_SUCCESS, local_cache_path));
return CancelCallback();
return google_apis::CancelCallbackOnce();
}
CancelCallback FakeDriveService::CopyResource(
......
......@@ -181,7 +181,7 @@ class FakeDriveService : public DriveServiceInterface {
google_apis::CancelCallback TrashResource(
const std::string& resource_id,
const google_apis::EntryActionCallback& callback) override;
google_apis::CancelCallback DownloadFile(
google_apis::CancelCallbackOnce DownloadFile(
const base::FilePath& local_cache_path,
const std::string& resource_id,
const google_apis::DownloadActionCallback& download_action_callback,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment