Skip to content

Commit

Permalink
Use base::BindOnce() and OnceClosure for a callback only run once.
Browse files Browse the repository at this point in the history
R=bokan@chromium.org

Bug: 954011, 1028284
Change-Id: I852b389c12b5bb96cbe2bdef52516b546fe6fdb2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1934651
Reviewed-by: David Bokan <bokan@chromium.org>
Commit-Queue: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#719177}
  • Loading branch information
danakj authored and Commit Bot committed Nov 26, 2019
1 parent 8948b51 commit 8705b2c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions cc/input/scrollbar_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ InputHandlerPointerResult ScrollbarController::HandlePointerDown(
// have the potential of initiating an autoscroll (if held down for long
// enough).
DCHECK(scrollbar_part != ScrollbarPart::THUMB);
cancelable_autoscroll_task_ = std::make_unique<base::CancelableClosure>(
base::Bind(&ScrollbarController::StartAutoScrollAnimation,
base::Unretained(this),
InitialDeltaToAutoscrollVelocity(
scrollbar, scroll_result.scroll_offset),
scrollbar, scrollbar_part));
cancelable_autoscroll_task_ = std::make_unique<base::CancelableOnceClosure>(
base::BindOnce(&ScrollbarController::StartAutoScrollAnimation,
base::Unretained(this),
InitialDeltaToAutoscrollVelocity(
scrollbar, scroll_result.scroll_offset),
scrollbar, scrollbar_part));
layer_tree_host_impl_->task_runner_provider()
->ImplThreadTaskRunner()
->PostDelayedTask(FROM_HERE, cancelable_autoscroll_task_->callback(),
Expand Down
2 changes: 1 addition & 1 deletion cc/input/scrollbar_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class CC_EXPORT ScrollbarController {
// pointermoves are not VSync aligned).
bool drag_processed_for_current_frame_;

std::unique_ptr<base::CancelableClosure> cancelable_autoscroll_task_;
std::unique_ptr<base::CancelableOnceClosure> cancelable_autoscroll_task_;
};

} // namespace cc
Expand Down

0 comments on commit 8705b2c

Please sign in to comment.