Skip to content

Commit

Permalink
Migrate //courgette to RepeatingCallback
Browse files Browse the repository at this point in the history
This updates //courgette to use base::RepeatingCallback instead of
legacy base::Callback. No intended functional change is included.

This reduces the number of 'base::Bind' in //courgette from 3 to 0 as
tracked at http://goo.gl/LUVhDj

Bug: 714018
Change-Id: I40ec7c5cd7486f6b1110f13e35fd0368a4db9f3c
Reviewed-on: https://chromium-review.googlesource.com/954886
Reviewed-by: Samuel Huang <huangs@chromium.org>
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541735}
  • Loading branch information
tzik authored and Commit Bot committed Mar 8, 2018
1 parent 9fd6385 commit 0881a40
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion courgette/adjustment_method_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class AdjustmentMethodTest : public testing::Test {
Label* labelA = prog->FindAbs32Label(kRvaA);
Label* labelB = prog->FindAbs32Label(kRvaB);

InstructionGenerator gen = base::Bind(
InstructionGenerator gen = base::BindRepeating(
[](Label* labelA, Label* labelB,
InstructionReceptor* receptor) -> CheckBool {
EXPECT_TRUE(receptor->EmitAbs32(labelA));
Expand Down
4 changes: 2 additions & 2 deletions courgette/disassembler_elf_32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ void DisassemblerElf32::RemoveUnusedRel32Locations(AssemblyProgram* program) {

InstructionGenerator DisassemblerElf32::GetInstructionGenerator(
AssemblyProgram* program) {
return base::Bind(&DisassemblerElf32::ParseFile, base::Unretained(this),
program);
return base::BindRepeating(&DisassemblerElf32::ParseFile,
base::Unretained(this), program);
}

CheckBool DisassemblerElf32::ParseFile(AssemblyProgram* program,
Expand Down
4 changes: 2 additions & 2 deletions courgette/disassembler_win32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,8 @@ void DisassemblerWin32::RemoveUnusedRel32Locations(

InstructionGenerator DisassemblerWin32::GetInstructionGenerator(
AssemblyProgram* program) {
return base::Bind(&DisassemblerWin32::ParseFile, base::Unretained(this),
program);
return base::BindRepeating(&DisassemblerWin32::ParseFile,
base::Unretained(this), program);
}

CheckBool DisassemblerWin32::ParseFile(AssemblyProgram* program,
Expand Down
3 changes: 2 additions & 1 deletion courgette/instruction_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ class InstructionReceptor {

// A rerunable callback that emit instructions to a provided receptor. Returns
// true on success, and false otherwise.
using InstructionGenerator = base::Callback<CheckBool(InstructionReceptor*)>;
using InstructionGenerator =
base::RepeatingCallback<CheckBool(InstructionReceptor*)>;

// A counter that increments via .push_back(), so it can be passed via template
// to substitute std::vector<T>, to count elements instead of storing them.
Expand Down

0 comments on commit 0881a40

Please sign in to comment.