Commit ec4ac041 authored by David Bokan's avatar David Bokan Committed by Chromium LUCI CQ

Convert FeedbackPrivateGetStringsFunction to OnceClosure

This class has a test method that allows storing a closure to be called
when this ExtensionFunction is invoked. Since ExtensionFunctions should
only call Run() (at most) once, this Closure can be a OnceClosure.

We also clean it up to avoid using a pointer.

Bug: 1152268
Change-Id: Ie7ebc98ad8569ac31f8b6b553426c2bc40c3ea8a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2602888Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#840435}
parent df875fe0
......@@ -65,12 +65,12 @@ class FeedbackTest : public ExtensionBrowserTest {
const std::string& extra_diagnostics,
bool from_assistant = false,
bool include_bluetooth_logs = false) {
base::Closure callback = base::Bind(&StopMessageLoopCallback);
base::OnceClosure callback = base::BindOnce(&StopMessageLoopCallback);
extensions::FeedbackPrivateGetStringsFunction::set_test_callback(&callback);
InvokeFeedbackUI(flow, extra_diagnostics, from_assistant,
include_bluetooth_logs);
content::RunMessageLoop();
extensions::FeedbackPrivateGetStringsFunction::set_test_callback(NULL);
extensions::FeedbackPrivateGetStringsFunction::set_test_callback(nullptr);
}
void VerifyFeedbackAppLaunch() {
......
......@@ -194,7 +194,7 @@ void FeedbackPrivateAPI::RequestFeedbackForFlow(
}
// static
base::Closure* FeedbackPrivateGetStringsFunction::test_callback_ = NULL;
base::OnceClosure* FeedbackPrivateGetStringsFunction::test_callback_ = nullptr;
ExtensionFunction::ResponseAction FeedbackPrivateGetStringsFunction::Run() {
auto params = feedback_private::GetStrings::Params::Create(*args_);
......@@ -209,7 +209,7 @@ ExtensionFunction::ResponseAction FeedbackPrivateGetStringsFunction::Run() {
params->flow == FeedbackFlow::FEEDBACK_FLOW_SADTABCRASH);
if (test_callback_ && !test_callback_->is_null())
test_callback_->Run();
std::move(*test_callback_).Run();
return RespondNow(
OneArgument(base::Value::FromUniquePtrValue(std::move(dict))));
......
......@@ -81,7 +81,7 @@ class FeedbackPrivateGetStringsFunction : public ExtensionFunction {
FEEDBACKPRIVATE_GETSTRINGS)
// Invoke this callback when this function is called - used for testing.
static void set_test_callback(base::Closure* const callback) {
static void set_test_callback(base::OnceClosure* callback) {
test_callback_ = callback;
}
......@@ -92,7 +92,7 @@ class FeedbackPrivateGetStringsFunction : public ExtensionFunction {
ResponseAction Run() override;
private:
static base::Closure* test_callback_;
static base::OnceClosure* test_callback_;
};
class FeedbackPrivateGetUserEmailFunction : public ExtensionFunction {
......
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