Commit 651950b2 authored by Bence Béky's avatar Bence Béky Committed by Commit Bot

Use OnceCallback for SnapshotFileCallback.

Define SnapshotFileCallback as a OnceCallback<> instead of a Callback<>.
While this CL does not directly touch any net::CompletionCallbacks, it
is a prerequisite for transitioning to net::CompletionOnceCallbacks in
//storage/browser/fileapi.

Bug: 807724

This exact CL has been reviewed and approved at
https://crrev.com/c/1165828.  However, due to a bug in Gerrit, I
inadvertently submitted that CL skipping the CQ.  See
https://crbug.com/872722.  Then I reverted that CL at
https://crrev.com/c/1169344.

In the aftermath of Gerrit issue, the original CL was automatically
reverted at https://crrev.com/c/1169845 to give the author (me) a
heads up that it needs to be relanded.  Before that, of course, the
revert was automatically reverted (that is, the original CL relanded)
at https://crrev.com/c/1169868 for the same reason.

Now that the outage is over, I can reland this CL properly,
using the CQ.  Original reviewer is TBR'd.

TBR=tzik@chromium.org

Change-Id: I1a6fdfb53e0d38e8fd1d6618a4a79f52dcf4739b
Reviewed-on: https://chromium-review.googlesource.com/1169308
Commit-Queue: Bence Béky <bnc@chromium.org>
Reviewed-by: default avatarBence Béky <bnc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582138}
parent a4a5093b
......@@ -4,6 +4,8 @@
#include "chrome/browser/chromeos/file_manager/snapshot_manager.h"
#include <utility>
#include "base/bind.h"
#include "base/containers/circular_deque.h"
#include "base/sys_info.h"
......@@ -85,9 +87,9 @@ void ComputeSpaceNeedToBeFreed(
void CreateSnapshotFileOnIOThread(
scoped_refptr<storage::FileSystemContext> context,
const storage::FileSystemURL& url,
const storage::FileSystemOperation::SnapshotFileCallback& callback) {
storage::FileSystemOperation::SnapshotFileCallback callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
context->operation_runner()->CreateSnapshotFile(url, callback);
context->operation_runner()->CreateSnapshotFile(url, std::move(callback));
}
// Utility for destructing the bound |file_refs| on IO thread. This is meant
......
......@@ -277,9 +277,9 @@ void SyncableFileSystemOperation::Cancel(
void SyncableFileSystemOperation::CreateSnapshotFile(
const FileSystemURL& path,
const SnapshotFileCallback& callback) {
SnapshotFileCallback callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
impl_->CreateSnapshotFile(path, callback);
impl_->CreateSnapshotFile(path, std::move(callback));
}
void SyncableFileSystemOperation::CopyInForeignFile(
......
......@@ -77,7 +77,7 @@ class SyncableFileSystemOperation : public storage::FileSystemOperation {
const OpenFileCallback& callback) override;
void Cancel(const StatusCallback& cancel_callback) override;
void CreateSnapshotFile(const storage::FileSystemURL& path,
const SnapshotFileCallback& callback) override;
SnapshotFileCallback callback) override;
void CopyInForeignFile(const base::FilePath& src_local_disk_path,
const storage::FileSystemURL& dest_url,
const StatusCallback& callback) override;
......
......@@ -109,7 +109,7 @@ class FileSystemOperation {
// longer necessary in the javascript world.
// Please see the comment for ShareableFileReference for details.
//
using SnapshotFileCallback = base::Callback<void(
using SnapshotFileCallback = base::OnceCallback<void(
base::File::Error result,
const base::File::Info& file_info,
const base::FilePath& platform_path,
......@@ -383,7 +383,7 @@ class FileSystemOperation {
// temporary file. Or if the implementaiton already has the local cache
// data for |path| it can simply return the path to the cache.
virtual void CreateSnapshotFile(const FileSystemURL& path,
const SnapshotFileCallback& callback) = 0;
SnapshotFileCallback callback) = 0;
// Copies in a single file from a different filesystem.
//
......
......@@ -277,10 +277,10 @@ void FileSystemOperationImpl::Cancel(const StatusCallback& cancel_callback) {
void FileSystemOperationImpl::CreateSnapshotFile(
const FileSystemURL& url,
const SnapshotFileCallback& callback) {
SnapshotFileCallback callback) {
DCHECK(SetPendingOperationType(kOperationCreateSnapshotFile));
async_file_util_->CreateSnapshotFile(std::move(operation_context_), url,
callback);
std::move(callback));
}
void FileSystemOperationImpl::CopyInForeignFile(
......
......@@ -78,7 +78,7 @@ class STORAGE_EXPORT FileSystemOperationImpl : public FileSystemOperation {
const OpenFileCallback& callback) override;
void Cancel(const StatusCallback& cancel_callback) override;
void CreateSnapshotFile(const FileSystemURL& path,
const SnapshotFileCallback& callback) override;
SnapshotFileCallback callback) override;
void CopyInForeignFile(const base::FilePath& src_local_disk_path,
const FileSystemURL& dest_url,
const StatusCallback& callback) override;
......
......@@ -203,10 +203,8 @@ class FileSystemOperationImplTest
FileSystemOperation::SnapshotFileCallback RecordSnapshotFileCallback(
const base::Closure& closure,
base::File::Error* status) {
return base::Bind(&FileSystemOperationImplTest::DidCreateSnapshotFile,
weak_factory_.GetWeakPtr(),
closure,
status);
return base::BindOnce(&FileSystemOperationImplTest::DidCreateSnapshotFile,
weak_factory_.GetWeakPtr(), closure, status);
}
void DidFinish(const base::Closure& closure,
......
......@@ -367,7 +367,7 @@ OperationID FileSystemOperationRunner::OpenFile(
OperationID FileSystemOperationRunner::CreateSnapshotFile(
const FileSystemURL& url,
const SnapshotFileCallback& callback) {
SnapshotFileCallback callback) {
base::File::Error error = base::File::FILE_OK;
std::unique_ptr<FileSystemOperation> operation = base::WrapUnique(
file_system_context_->CreateFileSystemOperation(url, &error));
......@@ -375,14 +375,14 @@ OperationID FileSystemOperationRunner::CreateSnapshotFile(
OperationID id = BeginOperation(std::move(operation));
base::AutoReset<bool> beginning(&is_beginning_operation_, true);
if (!operation_raw) {
DidCreateSnapshot(id, callback, error, base::File::Info(), base::FilePath(),
nullptr);
DidCreateSnapshot(id, std::move(callback), error, base::File::Info(),
base::FilePath(), nullptr);
return id;
}
PrepareForRead(id, url);
operation_raw->CreateSnapshotFile(
url, base::Bind(&FileSystemOperationRunner::DidCreateSnapshot, weak_ptr_,
id, callback));
url, base::BindOnce(&FileSystemOperationRunner::DidCreateSnapshot,
weak_ptr_, id, std::move(callback)));
return id;
}
......@@ -598,7 +598,7 @@ void FileSystemOperationRunner::DidOpenFile(
void FileSystemOperationRunner::DidCreateSnapshot(
const OperationID id,
const SnapshotFileCallback& callback,
SnapshotFileCallback callback,
base::File::Error rv,
const base::File::Info& file_info,
const base::FilePath& platform_path,
......@@ -606,12 +606,13 @@ void FileSystemOperationRunner::DidCreateSnapshot(
if (is_beginning_operation_) {
finished_operations_.insert(id);
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(&FileSystemOperationRunner::DidCreateSnapshot,
weak_ptr_, id, callback, rv, file_info,
platform_path, std::move(file_ref)));
FROM_HERE,
base::BindOnce(&FileSystemOperationRunner::DidCreateSnapshot, weak_ptr_,
id, std::move(callback), rv, file_info, platform_path,
std::move(file_ref)));
return;
}
callback.Run(rv, file_info, platform_path, std::move(file_ref));
std::move(callback).Run(rv, file_info, platform_path, std::move(file_ref));
FinishOperation(id);
}
......
......@@ -157,7 +157,7 @@ class STORAGE_EXPORT FileSystemOperationRunner {
// temporary file. Or if the implementaiton already has the local cache
// data for |url| it can simply return the url to the cache.
OperationID CreateSnapshotFile(const FileSystemURL& url,
const SnapshotFileCallback& callback);
SnapshotFileCallback callback);
// Copies in a single file from a different filesystem.
//
......@@ -265,7 +265,7 @@ class STORAGE_EXPORT FileSystemOperationRunner {
base::OnceClosure on_close_callback);
void DidCreateSnapshot(
const OperationID id,
const SnapshotFileCallback& callback,
SnapshotFileCallback callback,
base::File::Error rv,
const base::File::Info& file_info,
const base::FilePath& platform_path,
......
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