Commit be551c4a authored by Cammie Smith Barnes's avatar Cammie Smith Barnes Committed by Chromium LUCI CQ

CodeHealth: Change base::Closure to OnceClosure in chrome/test/base.

This CL is part of the Code Health Rotation
(https://sites.google.com/corp/google.com/chrome-code-health/) and
changes the two remaining occurrences in chrome/test/base of
base::Closure to base::OnceClosure, as they are used in a waiter method
that can only be invoked once.

Bug: 1007643
Change-Id: If7040fe9041e88cfa89314224d98423aa6696432
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2623193Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Cammie Smith Barnes <cammie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842385}
parent 2baca567
...@@ -19,9 +19,9 @@ ExtensionJSBrowserTest::ExtensionJSBrowserTest() {} ...@@ -19,9 +19,9 @@ ExtensionJSBrowserTest::ExtensionJSBrowserTest() {}
ExtensionJSBrowserTest::~ExtensionJSBrowserTest() {} ExtensionJSBrowserTest::~ExtensionJSBrowserTest() {}
void ExtensionJSBrowserTest::WaitForExtension(const char* extension_id, void ExtensionJSBrowserTest::WaitForExtension(const char* extension_id,
const base::Closure& load_cb) { base::OnceClosure load_cb) {
load_waiter_.reset(new ExtensionLoadWaiterOneShot()); load_waiter_.reset(new ExtensionLoadWaiterOneShot());
load_waiter_->WaitForExtension(extension_id, load_cb); load_waiter_->WaitForExtension(extension_id, std::move(load_cb));
} }
bool ExtensionJSBrowserTest::RunJavascriptTestF(bool is_async, bool ExtensionJSBrowserTest::RunJavascriptTestF(bool is_async,
......
...@@ -22,7 +22,7 @@ class ExtensionJSBrowserTest : public JavaScriptBrowserTest { ...@@ -22,7 +22,7 @@ class ExtensionJSBrowserTest : public JavaScriptBrowserTest {
protected: protected:
// Waits for an extension to load; returns immediately if already loaded. // Waits for an extension to load; returns immediately if already loaded.
void WaitForExtension(const char* extension_id, const base::Closure& load_cb); void WaitForExtension(const char* extension_id, base::OnceClosure load_cb);
// Method required for js2gtest. // Method required for js2gtest.
// Runs |test_fixture|.|test_name| using the framework in test_api.js. // Runs |test_fixture|.|test_name| using the framework in test_api.js.
......
...@@ -16,7 +16,7 @@ ExtensionLoadWaiterOneShot::ExtensionLoadWaiterOneShot() = default; ...@@ -16,7 +16,7 @@ ExtensionLoadWaiterOneShot::ExtensionLoadWaiterOneShot() = default;
ExtensionLoadWaiterOneShot::~ExtensionLoadWaiterOneShot() = default; ExtensionLoadWaiterOneShot::~ExtensionLoadWaiterOneShot() = default;
void ExtensionLoadWaiterOneShot::WaitForExtension(const char* extension_id, void ExtensionLoadWaiterOneShot::WaitForExtension(const char* extension_id,
const base::Closure& load_cb) { base::OnceClosure load_cb) {
CHECK(!extension_id_) << CHECK(!extension_id_) <<
"ExtensionLoadWaiterOneShot should only be used once."; "ExtensionLoadWaiterOneShot should only be used once.";
extension_id_ = extension_id; extension_id_ = extension_id;
...@@ -24,7 +24,7 @@ void ExtensionLoadWaiterOneShot::WaitForExtension(const char* extension_id, ...@@ -24,7 +24,7 @@ void ExtensionLoadWaiterOneShot::WaitForExtension(const char* extension_id,
registrar_.Add(this, registrar_.Add(this,
extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_FIRST_LOAD, extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_FIRST_LOAD,
content::NotificationService::AllSources()); content::NotificationService::AllSources());
load_cb.Run(); std::move(load_cb).Run();
load_looper_->Run(); load_looper_->Run();
} }
......
...@@ -26,7 +26,7 @@ class ExtensionLoadWaiterOneShot : public content::NotificationObserver { ...@@ -26,7 +26,7 @@ class ExtensionLoadWaiterOneShot : public content::NotificationObserver {
// Waits for extension with |extension_id| to load. The id should be a pointer // Waits for extension with |extension_id| to load. The id should be a pointer
// to a static char array. // to a static char array.
void WaitForExtension(const char* extension_id, const base::Closure& load_cb); void WaitForExtension(const char* extension_id, base::OnceClosure load_cb);
// content::NotificationObserver overrides. // content::NotificationObserver overrides.
void Observe(int type, void Observe(int type,
......
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