Convert google_apis::BatchableDelegate::NotifyResult to OnceClosure
Bug: 1007788 Change-Id: I8628a694a5e38552f4527bb81bd808fed4dc6cb1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1978201 Commit-Queue: Anand Mistry <amistry@chromium.org> Auto-Submit: Anand Mistry <amistry@chromium.org> Reviewed-by: Stuart Langley <slangley@chromium.org> Cr-Commit-Position: refs/heads/master@{#728808}
This commit is contained in:

committed by
Commit Bot

parent
cb15ec6746
commit
fd2e64be2d
@ -942,7 +942,7 @@ bool MultipartUploadRequestBase::GetContentData(
|
||||
void MultipartUploadRequestBase::NotifyResult(
|
||||
DriveApiErrorCode code,
|
||||
const std::string& body,
|
||||
const base::Closure& notify_complete_callback) {
|
||||
base::OnceClosure notify_complete_callback) {
|
||||
// The upload is successfully done. Parse the response which should be
|
||||
// the entry's metadata.
|
||||
if (code == HTTP_CREATED || code == HTTP_SUCCESS) {
|
||||
@ -950,10 +950,10 @@ void MultipartUploadRequestBase::NotifyResult(
|
||||
blocking_task_runner_.get(), body,
|
||||
base::BindOnce(&MultipartUploadRequestBase::OnDataParsed,
|
||||
weak_ptr_factory_.GetWeakPtr(), code,
|
||||
notify_complete_callback));
|
||||
std::move(notify_complete_callback)));
|
||||
} else {
|
||||
NotifyError(MapJsonError(code, body));
|
||||
notify_complete_callback.Run();
|
||||
std::move(notify_complete_callback).Run();
|
||||
}
|
||||
}
|
||||
|
||||
@ -969,14 +969,14 @@ void MultipartUploadRequestBase::NotifyUploadProgress(int64_t current,
|
||||
|
||||
void MultipartUploadRequestBase::OnDataParsed(
|
||||
DriveApiErrorCode code,
|
||||
const base::Closure& notify_complete_callback,
|
||||
base::OnceClosure notify_complete_callback,
|
||||
std::unique_ptr<base::Value> value) {
|
||||
DCHECK(thread_checker_.CalledOnValidThread());
|
||||
if (value)
|
||||
callback_.Run(code, google_apis::FileResource::CreateFrom(*value));
|
||||
else
|
||||
NotifyError(DRIVE_PARSE_ERROR);
|
||||
notify_complete_callback.Run();
|
||||
std::move(notify_complete_callback).Run();
|
||||
}
|
||||
|
||||
//============================ DownloadFileRequestBase =========================
|
||||
|
@ -309,7 +309,7 @@ class BatchableDelegate {
|
||||
// |callback|.
|
||||
virtual void NotifyResult(DriveApiErrorCode code,
|
||||
const std::string& response_body,
|
||||
const base::Closure& callback) = 0;
|
||||
base::OnceClosure callback) = 0;
|
||||
|
||||
// Notifies error. Unlike |NotifyResult|, it must report error
|
||||
// synchronously. The instance may be deleted just after calling
|
||||
@ -575,12 +575,12 @@ class MultipartUploadRequestBase : public BatchableDelegate {
|
||||
std::string* upload_content) override;
|
||||
void NotifyResult(DriveApiErrorCode code,
|
||||
const std::string& body,
|
||||
const base::Closure& callback) override;
|
||||
base::OnceClosure callback) override;
|
||||
void NotifyError(DriveApiErrorCode code) override;
|
||||
void NotifyUploadProgress(int64_t current, int64_t total) override;
|
||||
// Parses the response value and invokes |callback_| with |FileResource|.
|
||||
void OnDataParsed(DriveApiErrorCode code,
|
||||
const base::Closure& callback,
|
||||
base::OnceClosure callback,
|
||||
std::unique_ptr<base::Value> value);
|
||||
|
||||
private:
|
||||
|
@ -1144,7 +1144,7 @@ void SingleBatchableDelegateRequest::ProcessURLFetchResults(
|
||||
std::string response_body) {
|
||||
delegate_->NotifyResult(
|
||||
GetErrorCode(), response_body,
|
||||
base::Bind(
|
||||
base::BindOnce(
|
||||
&SingleBatchableDelegateRequest::OnProcessURLFetchResultsComplete,
|
||||
weak_ptr_factory_.GetWeakPtr()));
|
||||
}
|
||||
@ -1347,9 +1347,10 @@ void BatchUploadRequest::ProcessURLFetchResults(
|
||||
BatchableDelegate* delegate = child_requests_[i]->request.get();
|
||||
// Pass ownership of |delegate| so that child_requests_.clear() won't
|
||||
// kill the delegate. It has to be deleted after the notification.
|
||||
delegate->NotifyResult(parts[i].code, parts[i].body,
|
||||
base::Bind(&base::DeletePointer<BatchableDelegate>,
|
||||
child_requests_[i]->request.release()));
|
||||
delegate->NotifyResult(
|
||||
parts[i].code, parts[i].body,
|
||||
base::BindOnce(&base::DeletePointer<BatchableDelegate>,
|
||||
child_requests_[i]->request.release()));
|
||||
}
|
||||
child_requests_.clear();
|
||||
|
||||
|
@ -100,9 +100,9 @@ class TestBatchableDelegate : public BatchableDelegate {
|
||||
void NotifyError(DriveApiErrorCode code) override { callback_.Run(); }
|
||||
void NotifyResult(DriveApiErrorCode code,
|
||||
const std::string& body,
|
||||
const base::Closure& closure) override {
|
||||
base::OnceClosure closure) override {
|
||||
callback_.Run();
|
||||
closure.Run();
|
||||
std::move(closure).Run();
|
||||
}
|
||||
void NotifyUploadProgress(int64_t current, int64_t total) override {
|
||||
progress_values_.push_back(current);
|
||||
|
Reference in New Issue
Block a user