Skip to content

Commit

Permalink
[storage] Rename DelegateComposite's helpers to Create*
Browse files Browse the repository at this point in the history
The helper functions for the CopyOfMoveHookDelegateComposite are named
Get* (`GetBarrier`, `GetStatusCallback`), but they don't return any
existing entity. Instead, they create things from scratch, so let's
rename them to Create*.

Bug: b:304957331
Change-Id: Id589238c5fe901da9cb4e8a00a55d52650cd84e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4994245
Commit-Queue: Austin Sullivan <asully@chromium.org>
Auto-Submit: Oleg Davydov <burunduk@chromium.org>
Reviewed-by: Austin Sullivan <asully@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1217634}
  • Loading branch information
burunduk3 authored and Chromium LUCI CQ committed Oct 31, 2023
1 parent e82f837 commit e873b2e
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions storage/browser/file_system/copy_or_move_hook_delegate_composite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,21 @@ void ErrorReduction(CopyOrMoveHookDelegate::ErrorCallback callback,
std::move(callback).Run(CopyOrMoveHookDelegate::ErrorAction::kDefault);
}

base::RepeatingCallback<void(std::pair<int, base::File::Error>)> GetBarrier(
base::RepeatingCallback<void(std::pair<int, base::File::Error>)> CreateBarrier(
size_t size,
CopyOrMoveHookDelegate::StatusCallback callback) {
return base::BarrierCallback<std::pair<int, base::File::Error>>(
size, base::BindOnce(&StatusReduction, std::move(callback)));
}

base::RepeatingCallback<void(CopyOrMoveHookDelegate::ErrorAction)>
GetErrorBarrier(size_t size, CopyOrMoveHookDelegate::ErrorCallback callback) {
CreateErrorBarrier(size_t size,
CopyOrMoveHookDelegate::ErrorCallback callback) {
return base::BarrierCallback<CopyOrMoveHookDelegate::ErrorAction>(
size, base::BindOnce(&ErrorReduction, std::move(callback)));
}

CopyOrMoveHookDelegate::StatusCallback GetStatusCallback(
CopyOrMoveHookDelegate::StatusCallback CreateStatusCallback(
base::RepeatingCallback<void(std::pair<int, base::File::Error>)> barrier,
size_t index) {
return base::BindOnce(
Expand All @@ -65,7 +66,7 @@ CopyOrMoveHookDelegate::StatusCallback GetStatusCallback(
barrier, index);
}

CopyOrMoveHookDelegate::ErrorCallback GetErrorCallback(
CopyOrMoveHookDelegate::ErrorCallback CreateErrorCallback(
base::RepeatingCallback<void(CopyOrMoveHookDelegate::ErrorAction)>
barrier) {
return base::BindOnce(
Expand Down Expand Up @@ -103,10 +104,10 @@ void CopyOrMoveHookDelegateComposite::OnBeginProcessFile(
const FileSystemURL& destination_url,
StatusCallback callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
auto barrier = GetBarrier(delegates_.size(), std::move(callback));
auto barrier = CreateBarrier(delegates_.size(), std::move(callback));
for (size_t i = 0; i < delegates_.size(); ++i) {
delegates_[i]->OnBeginProcessFile(source_url, destination_url,
GetStatusCallback(barrier, i));
CreateStatusCallback(barrier, i));
}
}

Expand All @@ -115,10 +116,10 @@ void CopyOrMoveHookDelegateComposite::OnBeginProcessDirectory(
const FileSystemURL& destination_url,
StatusCallback callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
auto barrier = GetBarrier(delegates_.size(), std::move(callback));
auto barrier = CreateBarrier(delegates_.size(), std::move(callback));
for (size_t i = 0; i < delegates_.size(); ++i) {
delegates_[i]->OnBeginProcessDirectory(source_url, destination_url,
GetStatusCallback(barrier, i));
CreateStatusCallback(barrier, i));
}
}

Expand All @@ -138,10 +139,10 @@ void CopyOrMoveHookDelegateComposite::OnError(
base::File::Error error,
ErrorCallback callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
auto barrier = GetErrorBarrier(delegates_.size(), std::move(callback));
auto barrier = CreateErrorBarrier(delegates_.size(), std::move(callback));
for (std::unique_ptr<CopyOrMoveHookDelegate>& delegate : delegates_) {
delegate->OnError(source_url, destination_url, error,
GetErrorCallback(barrier));
CreateErrorCallback(barrier));
}
}

Expand Down

0 comments on commit e873b2e

Please sign in to comment.