Commit 5f462187 authored by Stuart Langley's avatar Stuart Langley Committed by Commit Bot

Change GetAvailableSpaceCallback from RepeatingCallback to OnceCallback.

Part of the ongoing work to cleanup the filesystem callbacks to be OnceCallback
where possible.

No logic changes.

Bug: 875700
Change-Id: I69c5518eaee657e0ce42d8bde3687696fa9047b9
Reviewed-on: https://chromium-review.googlesource.com/1217644Reviewed-by: default avatarAnand Mistry <amistry@chromium.org>
Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590152}
parent 60855f39
......@@ -472,7 +472,7 @@ bool FileManagerPrivateGetSizeStatsFunction::RunAsync() {
return true;
}
file_system->GetAvailableSpace(base::Bind(
file_system->GetAvailableSpace(base::BindOnce(
&FileManagerPrivateGetSizeStatsFunction::OnGetDriveAvailableSpace,
this));
} else if (volume->type() == file_manager::VOLUME_TYPE_MTP) {
......
......@@ -83,7 +83,7 @@ class DummyFileSystem : public FileSystemInterface {
SearchMetadataCallback callback) override {}
void SearchByHashes(const std::set<std::string>& hashes,
SearchByHashesCallback callback) override {}
void GetAvailableSpace(const GetAvailableSpaceCallback& callback) override {}
void GetAvailableSpace(GetAvailableSpaceCallback callback) override {}
void GetShareUrl(const base::FilePath& file_path,
const GURL& embed_origin,
const GetShareUrlCallback& callback) override {}
......
......@@ -204,8 +204,7 @@ void FakeFileSystem::SearchByHashes(const std::set<std::string>& hashes,
DCHECK_CURRENTLY_ON(BrowserThread::UI);
}
void FakeFileSystem::GetAvailableSpace(
const GetAvailableSpaceCallback& callback) {
void FakeFileSystem::GetAvailableSpace(GetAvailableSpaceCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
}
......
......@@ -110,7 +110,7 @@ class FakeFileSystem : public FileSystemInterface {
SearchMetadataCallback callback) override;
void SearchByHashes(const std::set<std::string>& hashes,
SearchByHashesCallback callback) override;
void GetAvailableSpace(const GetAvailableSpaceCallback& callback) override;
void GetAvailableSpace(GetAvailableSpaceCallback callback) override;
void GetShareUrl(const base::FilePath& file_path,
const GURL& embed_origin,
const GetShareUrlCallback& callback) override;
......
......@@ -736,19 +736,17 @@ void FileSystem::ReadDirectory(
directory_path, std::move(entries_callback), completion_callback);
}
void FileSystem::GetAvailableSpace(
const GetAvailableSpaceCallback& callback) {
void FileSystem::GetAvailableSpace(GetAvailableSpaceCallback callback) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(callback);
about_resource_loader_->GetAboutResource(
base::Bind(&FileSystem::OnGetAboutResource,
weak_ptr_factory_.GetWeakPtr(),
callback));
about_resource_loader_->GetAboutResource(base::Bind(
&FileSystem::OnGetAboutResource, weak_ptr_factory_.GetWeakPtr(),
base::Passed(std::move(callback))));
}
void FileSystem::OnGetAboutResource(
const GetAvailableSpaceCallback& callback,
GetAvailableSpaceCallback callback,
google_apis::DriveApiErrorCode status,
std::unique_ptr<google_apis::AboutResource> about_resource) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
......@@ -756,13 +754,13 @@ void FileSystem::OnGetAboutResource(
FileError error = GDataToFileError(status);
if (error != FILE_ERROR_OK) {
callback.Run(error, -1, -1);
std::move(callback).Run(error, -1, -1);
return;
}
DCHECK(about_resource);
callback.Run(FILE_ERROR_OK, about_resource->quota_bytes_total(),
about_resource->quota_bytes_used_aggregate());
std::move(callback).Run(FILE_ERROR_OK, about_resource->quota_bytes_total(),
about_resource->quota_bytes_used_aggregate());
}
void FileSystem::GetShareUrl(const base::FilePath& file_path,
......
......@@ -146,7 +146,7 @@ class FileSystem : public FileSystemInterface,
void ReadDirectory(const base::FilePath& directory_path,
ReadDirectoryEntriesCallback entries_callback,
const FileOperationCallback& completion_callback) override;
void GetAvailableSpace(const GetAvailableSpaceCallback& callback) override;
void GetAvailableSpace(GetAvailableSpaceCallback callback) override;
void GetShareUrl(const base::FilePath& file_path,
const GURL& embed_origin,
const GetShareUrlCallback& callback) override;
......@@ -230,7 +230,7 @@ class FileSystem : public FileSystemInterface,
// Callback for handling about resource fetch.
void OnGetAboutResource(
const GetAvailableSpaceCallback& callback,
GetAvailableSpaceCallback callback,
google_apis::DriveApiErrorCode status,
std::unique_ptr<google_apis::AboutResource> about_resource);
......
......@@ -134,9 +134,9 @@ typedef base::OnceCallback<void(FileError error,
OpenFileCallback;
// Used to get available space for the account from Drive.
typedef base::Callback<void(FileError error,
int64_t bytes_total,
int64_t bytes_used)> GetAvailableSpaceCallback;
typedef base::OnceCallback<
void(FileError error, int64_t bytes_total, int64_t bytes_used)>
GetAvailableSpaceCallback;
// Used to get the url to the sharing dialog.
typedef base::Callback<void(FileError error,
......@@ -435,7 +435,7 @@ class FileSystemInterface {
// Fetches the user's Account Metadata to find out current quota information
// and returns it to the callback.
virtual void GetAvailableSpace(const GetAvailableSpaceCallback& callback) = 0;
virtual void GetAvailableSpace(GetAvailableSpaceCallback callback) = 0;
// Fetches the url to the sharing dialog to be embedded in |embed_origin|,
// for the specified file or directory. |callback| must not be null.
......
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