Commit 18743708 authored by danakj's avatar danakj Committed by Commit Bot

Convert base::Bind to base::Bind{Once,Repeating} in content/browser/tracing

This CL converts base::Bind to BindOnce or BindRepeating, and also changes
relevant base::Callbacks or base::Closures to appropriate types.

TBR=clamy@chromium.org

Bug: 1007760
Change-Id: Ib3ad0192ccbaecf6b1f931b81dbadfdcc7650ab2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1943337Reviewed-by: default avatardanakj <danakj@chromium.org>
Commit-Queue: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#720289}
parent 4fe43911
...@@ -246,9 +246,10 @@ class HistogramRule : public BackgroundTracingRule, ...@@ -246,9 +246,10 @@ class HistogramRule : public BackgroundTracingRule,
void Install() override { void Install() override {
base::StatisticsRecorder::SetCallback( base::StatisticsRecorder::SetCallback(
histogram_name_, histogram_name_,
base::Bind(&HistogramRule::OnHistogramChangedCallback, base::BindRepeating(&HistogramRule::OnHistogramChangedCallback,
base::Unretained(this), histogram_name_, base::Unretained(this), histogram_name_,
histogram_lower_value_, histogram_upper_value_, repeat_)); histogram_lower_value_, histogram_upper_value_,
repeat_));
BackgroundTracingManagerImpl::GetInstance()->AddAgentObserver(this); BackgroundTracingManagerImpl::GetInstance()->AddAgentObserver(this);
installed_ = true; installed_ = true;
...@@ -447,8 +448,9 @@ class TraceAtRandomIntervalsRule : public BackgroundTracingRule { ...@@ -447,8 +448,9 @@ class TraceAtRandomIntervalsRule : public BackgroundTracingRule {
void OnTriggerTimer() { void OnTriggerTimer() {
BackgroundTracingManagerImpl::GetInstance()->TriggerNamedEvent( BackgroundTracingManagerImpl::GetInstance()->TriggerNamedEvent(
handle_, base::Bind(&TraceAtRandomIntervalsRule::OnStartedFinalizing, handle_,
base::Unretained(this))); base::BindOnce(&TraceAtRandomIntervalsRule::OnStartedFinalizing,
base::Unretained(this)));
} }
void StartTimer() { void StartTimer() {
......
...@@ -65,7 +65,7 @@ std::unique_ptr<GlobalMemoryDump> DoGlobalDump() { ...@@ -65,7 +65,7 @@ std::unique_ptr<GlobalMemoryDump> DoGlobalDump() {
memory_instrumentation::MemoryInstrumentation::GetInstance() memory_instrumentation::MemoryInstrumentation::GetInstance()
->RequestGlobalDump( ->RequestGlobalDump(
{}, base::BindOnce( {}, base::BindOnce(
[](base::Closure quit_closure, [](base::OnceClosure quit_closure,
std::unique_ptr<GlobalMemoryDump>* out_result, std::unique_ptr<GlobalMemoryDump>* out_result,
bool success, std::unique_ptr<GlobalMemoryDump> result) { bool success, std::unique_ptr<GlobalMemoryDump> result) {
EXPECT_TRUE(success); EXPECT_TRUE(success);
......
...@@ -50,7 +50,7 @@ class MemoryTracingTest : public ContentBrowserTest { ...@@ -50,7 +50,7 @@ class MemoryTracingTest : public ContentBrowserTest {
// Used as callback argument for MemoryDumpManager::RequestGlobalDump(): // Used as callback argument for MemoryDumpManager::RequestGlobalDump():
void OnGlobalMemoryDumpDone( void OnGlobalMemoryDumpDone(
scoped_refptr<base::SingleThreadTaskRunner> task_runner, scoped_refptr<base::SingleThreadTaskRunner> task_runner,
base::Closure closure, base::OnceClosure closure,
uint32_t request_index, uint32_t request_index,
bool success, bool success,
uint64_t dump_guid) { uint64_t dump_guid) {
...@@ -67,7 +67,7 @@ class MemoryTracingTest : public ContentBrowserTest { ...@@ -67,7 +67,7 @@ class MemoryTracingTest : public ContentBrowserTest {
if (success) if (success)
EXPECT_NE(0u, dump_guid); EXPECT_NE(0u, dump_guid);
OnMemoryDumpDone(request_index, success); OnMemoryDumpDone(request_index, success);
if (!closure.is_null()) if (closure)
std::move(closure).Run(); std::move(closure).Run();
} }
...@@ -75,11 +75,11 @@ class MemoryTracingTest : public ContentBrowserTest { ...@@ -75,11 +75,11 @@ class MemoryTracingTest : public ContentBrowserTest {
bool from_renderer_thread, bool from_renderer_thread,
const MemoryDumpType& dump_type, const MemoryDumpType& dump_type,
const MemoryDumpLevelOfDetail& level_of_detail, const MemoryDumpLevelOfDetail& level_of_detail,
const base::Closure& closure) { base::OnceClosure closure) {
uint32_t request_index = next_request_index_++; uint32_t request_index = next_request_index_++;
auto callback = base::Bind( auto callback = base::BindOnce(
&MemoryTracingTest::OnGlobalMemoryDumpDone, base::Unretained(this), &MemoryTracingTest::OnGlobalMemoryDumpDone, base::Unretained(this),
base::ThreadTaskRunnerHandle::Get(), closure, request_index); base::ThreadTaskRunnerHandle::Get(), std::move(closure), request_index);
if (from_renderer_thread) { if (from_renderer_thread) {
PostTaskToInProcessRendererAndWait(base::BindOnce( PostTaskToInProcessRendererAndWait(base::BindOnce(
&memory_instrumentation::MemoryInstrumentation:: &memory_instrumentation::MemoryInstrumentation::
...@@ -161,7 +161,7 @@ class MemoryTracingTest : public ContentBrowserTest { ...@@ -161,7 +161,7 @@ class MemoryTracingTest : public ContentBrowserTest {
const MemoryDumpType& dump_type, const MemoryDumpType& dump_type,
const MemoryDumpLevelOfDetail& level_of_detail) { const MemoryDumpLevelOfDetail& level_of_detail) {
RequestGlobalDumpWithClosure(from_renderer_thread, dump_type, RequestGlobalDumpWithClosure(from_renderer_thread, dump_type,
level_of_detail, base::Closure()); level_of_detail, base::NullCallback());
} }
void Navigate(Shell* shell) { void Navigate(Shell* shell) {
...@@ -170,7 +170,6 @@ class MemoryTracingTest : public ContentBrowserTest { ...@@ -170,7 +170,6 @@ class MemoryTracingTest : public ContentBrowserTest {
MOCK_METHOD2(OnMemoryDumpDone, void(uint32_t request_index, bool successful)); MOCK_METHOD2(OnMemoryDumpDone, void(uint32_t request_index, bool successful));
base::Closure on_memory_dump_complete_closure_;
std::unique_ptr<MockDumpProvider> mock_dump_provider_; std::unique_ptr<MockDumpProvider> mock_dump_provider_;
uint32_t next_request_index_; uint32_t next_request_index_;
bool last_callback_success_; bool last_callback_success_;
......
...@@ -126,14 +126,14 @@ class TracingControllerTest : public ContentBrowserTest { ...@@ -126,14 +126,14 @@ class TracingControllerTest : public ContentBrowserTest {
return std::move(metadata_); return std::move(metadata_);
} }
void GetCategoriesDoneCallbackTest(base::Closure quit_callback, void GetCategoriesDoneCallbackTest(base::OnceClosure quit_callback,
const std::set<std::string>& categories) { const std::set<std::string>& categories) {
get_categories_done_callback_count_++; get_categories_done_callback_count_++;
EXPECT_FALSE(categories.empty()); EXPECT_FALSE(categories.empty());
std::move(quit_callback).Run(); std::move(quit_callback).Run();
} }
void StartTracingDoneCallbackTest(base::Closure quit_callback) { void StartTracingDoneCallbackTest(base::OnceClosure quit_callback) {
enable_recording_done_callback_count_++; enable_recording_done_callback_count_++;
std::move(quit_callback).Run(); std::move(quit_callback).Run();
} }
...@@ -146,7 +146,7 @@ class TracingControllerTest : public ContentBrowserTest { ...@@ -146,7 +146,7 @@ class TracingControllerTest : public ContentBrowserTest {
std::move(quit_callback).Run(); std::move(quit_callback).Run();
} }
void StopTracingFileDoneCallbackTest(base::Closure quit_callback, void StopTracingFileDoneCallbackTest(base::OnceClosure quit_callback,
const base::FilePath& file_path) { const base::FilePath& file_path) {
disable_recording_done_callback_count_++; disable_recording_done_callback_count_++;
{ {
...@@ -243,8 +243,8 @@ class TracingControllerTest : public ContentBrowserTest { ...@@ -243,8 +243,8 @@ class TracingControllerTest : public ContentBrowserTest {
metadata_ = std::make_unique<base::DictionaryValue>(); metadata_ = std::make_unique<base::DictionaryValue>();
metadata_->SetString("not-whitelisted", "this_not_found"); metadata_->SetString("not-whitelisted", "this_not_found");
tracing::TraceEventAgent::GetInstance()->AddMetadataGeneratorFunction( tracing::TraceEventAgent::GetInstance()->AddMetadataGeneratorFunction(
base::Bind(&TracingControllerTest::GenerateMetadataDict, base::BindRepeating(&TracingControllerTest::GenerateMetadataDict,
base::Unretained(this))); base::Unretained(this)));
bool result = bool result =
controller->StopTracing(trace_data_endpoint, /*agent_label=*/"", controller->StopTracing(trace_data_endpoint, /*agent_label=*/"",
......
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