Commit 6a3550b4 authored by Josip Sokcevic's avatar Josip Sokcevic Committed by Commit Bot

Return CancelCallbackRepeating in drive Multipart*

This changes return type of following functions:
* MultipartUploadNewFile
* MultipartUploadExistingFile

Method calls from:
https://source.chromium.org/chromium/chromium/src/+/master:components/drive/service/drive_api_service.cc;l=159;bpv=1;bpt=1
and
https://source.chromium.org/chromium/chromium/src/+/master:components/drive/drive_uploader.cc;l=167;drc=9a7c42e7b3ce922f16b308e2b295f109b56b9fa2;bpv=1;bpt=1

Bug: 1007686
Change-Id: I363b85d59e254e1481fb4c60c29ff9ec0bdc8c00
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2304727
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790931}
parent 61da5958
......@@ -400,7 +400,8 @@ google_apis::CancelCallback DriveServiceOnWorker::GetUploadStatus(
return google_apis::CancelCallback();
}
google_apis::CancelCallback DriveServiceOnWorker::MultipartUploadNewFile(
google_apis::CancelCallbackRepeating
DriveServiceOnWorker::MultipartUploadNewFile(
const std::string& content_type,
int64_t content_length,
const std::string& parent_resource_id,
......@@ -410,7 +411,7 @@ google_apis::CancelCallback DriveServiceOnWorker::MultipartUploadNewFile(
google_apis::FileResourceCallback callback,
google_apis::ProgressCallback progress_callback) {
NOTREACHED();
return google_apis::CancelCallback();
return google_apis::CancelCallbackRepeating();
}
google_apis::CancelCallback DriveServiceOnWorker::MultipartUploadExistingFile(
......
......@@ -170,7 +170,7 @@ class DriveServiceOnWorker : public drive::DriveServiceInterface {
const GURL& upload_url,
int64_t content_length,
google_apis::drive::UploadRangeCallback callback) override;
google_apis::CancelCallback MultipartUploadNewFile(
google_apis::CancelCallbackRepeating MultipartUploadNewFile(
const std::string& content_type,
int64_t content_length,
const std::string& parent_resource_id,
......@@ -179,7 +179,7 @@ class DriveServiceOnWorker : public drive::DriveServiceInterface {
const drive::UploadNewFileOptions& options,
google_apis::FileResourceCallback callback,
google_apis::ProgressCallback progress_callback) override;
google_apis::CancelCallback MultipartUploadExistingFile(
google_apis::CancelCallbackRepeating MultipartUploadExistingFile(
const std::string& content_type,
int64_t content_length,
const std::string& resource_id,
......
......@@ -19,8 +19,8 @@
#include "google_apis/drive/drive_api_parser.h"
#include "services/device/public/mojom/wake_lock.mojom.h"
using google_apis::CancelCallback;
using google_apis::CancelCallbackOnce;
using google_apis::CancelCallbackRepeating;
using google_apis::DRIVE_CANCELLED;
using google_apis::DRIVE_NO_SPACE;
using google_apis::DriveApiErrorCode;
......@@ -156,7 +156,7 @@ struct DriveUploader::UploadFileInfo {
// once Cancel() is called. DriveUploader will check this field before after
// an async task other than HTTP requests and cancels the subsequent requests
// if this is flagged to true.
CancelCallback cancel_callback;
CancelCallbackRepeating cancel_callback;
bool cancelled;
private:
......@@ -164,7 +164,7 @@ struct DriveUploader::UploadFileInfo {
void Cancel() {
cancelled = true;
if (!cancel_callback.is_null())
cancel_callback.Run();
std::move(cancel_callback).Run();
}
base::WeakPtrFactory<UploadFileInfo> weak_ptr_factory_{this};
......
......@@ -25,10 +25,11 @@
#include "testing/gtest/include/gtest/gtest.h"
using google_apis::CancelCallback;
using google_apis::FileResource;
using google_apis::DriveApiErrorCode;
using google_apis::CancelCallbackRepeating;
using google_apis::DRIVE_NO_CONNECTION;
using google_apis::DRIVE_OTHER_ERROR;
using google_apis::DriveApiErrorCode;
using google_apis::FileResource;
using google_apis::HTTP_CONFLICT;
using google_apis::HTTP_CREATED;
using google_apis::HTTP_NOT_FOUND;
......@@ -56,7 +57,7 @@ const char kTestUploadExistingFileURL[] =
const int64_t kUploadChunkSize = 1024 * 1024 * 1024;
const char kTestETag[] = "test_etag";
CancelCallback SendMultipartUploadResult(
CancelCallbackRepeating SendMultipartUploadResult(
DriveApiErrorCode response_code,
int64_t content_length,
google_apis::FileResourceCallback callback,
......@@ -78,7 +79,7 @@ CancelCallback SendMultipartUploadResult(
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::BindOnce(std::move(callback), response_code, std::move(entry)));
return CancelCallback();
return CancelCallbackRepeating();
}
// Mock DriveService that verifies if the uploaded content matches the preset
......@@ -233,7 +234,7 @@ class MockDriveServiceWithUploadExpectation : public DummyDriveService {
base::BindOnce(std::move(callback), response, std::move(entry)));
}
CancelCallback MultipartUploadNewFile(
CancelCallbackRepeating MultipartUploadNewFile(
const std::string& content_type,
int64_t content_length,
const std::string& parent_resource_id,
......@@ -254,7 +255,7 @@ class MockDriveServiceWithUploadExpectation : public DummyDriveService {
std::move(callback), progress_callback);
}
CancelCallback MultipartUploadExistingFile(
CancelCallbackRepeating MultipartUploadExistingFile(
const std::string& content_type,
int64_t content_length,
const std::string& resource_id,
......@@ -271,7 +272,7 @@ class MockDriveServiceWithUploadExpectation : public DummyDriveService {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::BindOnce(std::move(callback), HTTP_PRECONDITION, nullptr));
return CancelCallback();
return CancelCallbackRepeating();
}
received_bytes_ = content_length;
......@@ -326,7 +327,7 @@ class MockDriveServiceNoConnectionAtInitiate : public DummyDriveService {
return CancelCallback();
}
CancelCallback MultipartUploadNewFile(
CancelCallbackRepeating MultipartUploadNewFile(
const std::string& content_type,
int64_t content_length,
const std::string& parent_resource_id,
......@@ -338,10 +339,10 @@ class MockDriveServiceNoConnectionAtInitiate : public DummyDriveService {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::BindOnce(std::move(callback), DRIVE_NO_CONNECTION, nullptr));
return CancelCallback();
return CancelCallbackRepeating();
}
CancelCallback MultipartUploadExistingFile(
CancelCallbackRepeating MultipartUploadExistingFile(
const std::string& content_type,
int64_t content_length,
const std::string& resource_id,
......@@ -352,7 +353,7 @@ class MockDriveServiceNoConnectionAtInitiate : public DummyDriveService {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::BindOnce(std::move(callback), DRIVE_NO_CONNECTION, nullptr));
return CancelCallback();
return CancelCallbackRepeating();
}
};
......
......@@ -26,6 +26,7 @@ using google_apis::AboutResourceCallback;
using google_apis::AuthStatusCallback;
using google_apis::CancelCallback;
using google_apis::CancelCallbackOnce;
using google_apis::CancelCallbackRepeating;
using google_apis::ChangeList;
using google_apis::ChangeListCallback;
using google_apis::DownloadActionCallback;
......@@ -160,7 +161,8 @@ BatchRequestConfigurator::~BatchRequestConfigurator() {
cancel_callback_.Run();
}
google_apis::CancelCallback BatchRequestConfigurator::MultipartUploadNewFile(
google_apis::CancelCallbackRepeating
BatchRequestConfigurator::MultipartUploadNewFile(
const std::string& content_type,
int64_t content_length,
const std::string& parent_resource_id,
......@@ -723,7 +725,7 @@ CancelCallback DriveAPIService::GetUploadStatus(const GURL& upload_url,
sender_.get(), upload_url, content_length, std::move(callback)));
}
CancelCallback DriveAPIService::MultipartUploadNewFile(
CancelCallbackRepeating DriveAPIService::MultipartUploadNewFile(
const std::string& content_type,
int64_t content_length,
const std::string& parent_resource_id,
......@@ -746,7 +748,7 @@ CancelCallback DriveAPIService::MultipartUploadNewFile(
progress_callback)));
}
CancelCallback DriveAPIService::MultipartUploadExistingFile(
CancelCallbackRepeating DriveAPIService::MultipartUploadExistingFile(
const std::string& content_type,
int64_t content_length,
const std::string& resource_id,
......
......@@ -59,7 +59,7 @@ class BatchRequestConfigurator : public BatchRequestConfiguratorInterface {
~BatchRequestConfigurator() override;
// BatchRequestConfiguratorInterface overrides.
google_apis::CancelCallback MultipartUploadNewFile(
google_apis::CancelCallbackRepeating MultipartUploadNewFile(
const std::string& content_type,
int64_t content_length,
const std::string& parent_resource_id,
......@@ -68,7 +68,7 @@ class BatchRequestConfigurator : public BatchRequestConfiguratorInterface {
const UploadNewFileOptions& options,
google_apis::FileResourceCallback callback,
google_apis::ProgressCallback progress_callback) override;
google_apis::CancelCallback MultipartUploadExistingFile(
google_apis::CancelCallbackRepeating MultipartUploadExistingFile(
const std::string& content_type,
int64_t content_length,
const std::string& resource_id,
......@@ -83,7 +83,7 @@ class BatchRequestConfigurator : public BatchRequestConfiguratorInterface {
base::WeakPtr<google_apis::drive::BatchUploadRequest> batch_request_;
scoped_refptr<base::SequencedTaskRunner> task_runner_;
google_apis::DriveApiUrlGenerator url_generator_;
google_apis::CancelCallback cancel_callback_;
google_apis::CancelCallbackRepeating cancel_callback_;
SEQUENCE_CHECKER(sequence_checker_);
......@@ -234,7 +234,7 @@ class DriveAPIService : public DriveServiceInterface,
const GURL& upload_url,
int64_t content_length,
google_apis::drive::UploadRangeCallback callback) override;
google_apis::CancelCallback MultipartUploadNewFile(
google_apis::CancelCallbackRepeating MultipartUploadNewFile(
const std::string& content_type,
int64_t content_length,
const std::string& parent_resource_id,
......@@ -243,7 +243,7 @@ class DriveAPIService : public DriveServiceInterface,
const drive::UploadNewFileOptions& options,
google_apis::FileResourceCallback callback,
google_apis::ProgressCallback progress_callback) override;
google_apis::CancelCallback MultipartUploadExistingFile(
google_apis::CancelCallbackRepeating MultipartUploadExistingFile(
const std::string& content_type,
int64_t content_length,
const std::string& resource_id,
......
......@@ -118,7 +118,7 @@ class DriveServiceBatchOperationsInterface {
// for small files than using |InitiateUploadNewFile| and |ResumeUpload|.
// |content_type| and |content_length| should be the ones of the file to be
// uploaded. |callback| must not be null. |progress_callback| may be null.
virtual google_apis::CancelCallback MultipartUploadNewFile(
virtual google_apis::CancelCallbackRepeating MultipartUploadNewFile(
const std::string& content_type,
int64_t content_length,
const std::string& parent_resource_id,
......@@ -132,7 +132,7 @@ class DriveServiceBatchOperationsInterface {
// for small files than using |InitiateUploadExistingFile| and |ResumeUpload|.
// |content_type| and |content_length| should be the ones of the file to be
// uploaded. |callback| must not be null. |progress_callback| may be null.
virtual google_apis::CancelCallback MultipartUploadExistingFile(
virtual google_apis::CancelCallbackRepeating MultipartUploadExistingFile(
const std::string& content_type,
int64_t content_length,
const std::string& resource_id,
......
......@@ -24,6 +24,7 @@ typedef base::OnceCallback<void(DriveApiErrorCode error,
// callback passed with the request is invoked with DRIVE_CANCELLED. If the
// request is already finished, nothing happens.
typedef base::OnceClosure CancelCallbackOnce;
typedef base::RepeatingClosure CancelCallbackRepeating;
// TODO(https://crbug.com/1007686): Remove usage of CancelCallback
typedef base::Closure CancelCallback;
......
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