Commit d07754fc authored by Yannic Bonenberger's avatar Yannic Bonenberger Committed by Commit Bot

Remove remaining occurrences of base::Closure from ServiceWorker code

Bug: 755477
Change-Id: I59ca20a9d958a2bcad929b9a83b1ab9053ee8d42
Reviewed-on: https://chromium-review.googlesource.com/1212062Reviewed-by: default avatarMakoto Shimazu <shimazu@chromium.org>
Commit-Queue: Yannic Bonenberger <contact@yannic-bonenberger.com>
Cr-Commit-Position: refs/heads/master@{#589866}
parent a465cc5a
...@@ -1621,7 +1621,7 @@ class EventCallbackHelper : public EmbeddedWorkerTestHelper { ...@@ -1621,7 +1621,7 @@ class EventCallbackHelper : public EmbeddedWorkerTestHelper {
void OnInstallEvent( void OnInstallEvent(
mojom::ServiceWorker::DispatchInstallEventCallback callback) override { mojom::ServiceWorker::DispatchInstallEventCallback callback) override {
if (!install_callback_.is_null()) if (!install_callback_.is_null())
install_callback_.Run(); std::move(install_callback_).Run();
std::move(callback).Run(install_event_result_, has_fetch_handler_, std::move(callback).Run(install_event_result_, has_fetch_handler_,
base::Time::Now()); base::Time::Now());
} }
...@@ -1631,8 +1631,8 @@ class EventCallbackHelper : public EmbeddedWorkerTestHelper { ...@@ -1631,8 +1631,8 @@ class EventCallbackHelper : public EmbeddedWorkerTestHelper {
std::move(callback).Run(activate_event_result_, base::Time::Now()); std::move(callback).Run(activate_event_result_, base::Time::Now());
} }
void set_install_callback(const base::Closure& callback) { void set_install_callback(base::OnceClosure callback) {
install_callback_ = callback; install_callback_ = std::move(callback);
} }
void set_install_event_result(blink::mojom::ServiceWorkerEventStatus result) { void set_install_event_result(blink::mojom::ServiceWorkerEventStatus result) {
install_event_result_ = result; install_event_result_ = result;
...@@ -1646,7 +1646,7 @@ class EventCallbackHelper : public EmbeddedWorkerTestHelper { ...@@ -1646,7 +1646,7 @@ class EventCallbackHelper : public EmbeddedWorkerTestHelper {
} }
private: private:
base::Closure install_callback_; base::OnceClosure install_callback_;
blink::mojom::ServiceWorkerEventStatus install_event_result_; blink::mojom::ServiceWorkerEventStatus install_event_result_;
blink::mojom::ServiceWorkerEventStatus activate_event_result_; blink::mojom::ServiceWorkerEventStatus activate_event_result_;
bool has_fetch_handler_ = true; bool has_fetch_handler_ = true;
...@@ -1673,8 +1673,8 @@ TEST_F(ServiceWorkerJobTest, RemoveControlleeDuringInstall) { ...@@ -1673,8 +1673,8 @@ TEST_F(ServiceWorkerJobTest, RemoveControlleeDuringInstall) {
// Register another script. While installing, old_version loses controllee. // Register another script. While installing, old_version loses controllee.
helper->set_install_callback( helper->set_install_callback(
base::BindRepeating(&ServiceWorkerVersion::RemoveControllee, old_version, base::BindOnce(&ServiceWorkerVersion::RemoveControllee, old_version,
host->client_uuid())); host->client_uuid()));
EXPECT_EQ(registration, RunRegisterJob(script2, options)); EXPECT_EQ(registration, RunRegisterJob(script2, options));
EXPECT_FALSE(registration->is_uninstalling()); EXPECT_FALSE(registration->is_uninstalling());
...@@ -1715,8 +1715,8 @@ TEST_F(ServiceWorkerJobTest, RemoveControlleeDuringRejectedInstall) { ...@@ -1715,8 +1715,8 @@ TEST_F(ServiceWorkerJobTest, RemoveControlleeDuringRejectedInstall) {
// Register another script that fails to install. While installing, // Register another script that fails to install. While installing,
// old_version loses controllee. // old_version loses controllee.
helper->set_install_callback( helper->set_install_callback(
base::BindRepeating(&ServiceWorkerVersion::RemoveControllee, old_version, base::BindOnce(&ServiceWorkerVersion::RemoveControllee, old_version,
host->client_uuid())); host->client_uuid()));
helper->set_install_event_result( helper->set_install_event_result(
blink::mojom::ServiceWorkerEventStatus::REJECTED); blink::mojom::ServiceWorkerEventStatus::REJECTED);
EXPECT_EQ(registration, RunRegisterJob(script2, options)); EXPECT_EQ(registration, RunRegisterJob(script2, options));
...@@ -1754,8 +1754,8 @@ TEST_F(ServiceWorkerJobTest, RemoveControlleeDuringInstall_RejectActivate) { ...@@ -1754,8 +1754,8 @@ TEST_F(ServiceWorkerJobTest, RemoveControlleeDuringInstall_RejectActivate) {
// Register another script that fails to activate. While installing, // Register another script that fails to activate. While installing,
// old_version loses controllee. // old_version loses controllee.
helper->set_install_callback( helper->set_install_callback(
base::BindRepeating(&ServiceWorkerVersion::RemoveControllee, old_version, base::BindOnce(&ServiceWorkerVersion::RemoveControllee, old_version,
host->client_uuid())); host->client_uuid()));
helper->set_activate_event_result( helper->set_activate_event_result(
blink::mojom::ServiceWorkerEventStatus::REJECTED); blink::mojom::ServiceWorkerEventStatus::REJECTED);
EXPECT_EQ(registration, RunRegisterJob(script2, options)); EXPECT_EQ(registration, RunRegisterJob(script2, options));
......
...@@ -40,19 +40,19 @@ const int64_t kNonExistentResourceId = 12; ...@@ -40,19 +40,19 @@ const int64_t kNonExistentResourceId = 12;
const int64_t kResourceSize = 100; const int64_t kResourceSize = 100;
void DidStoreRegistration(blink::ServiceWorkerStatusCode* status_out, void DidStoreRegistration(blink::ServiceWorkerStatusCode* status_out,
const base::Closure& quit_closure, base::OnceClosure quit_closure,
blink::ServiceWorkerStatusCode status) { blink::ServiceWorkerStatusCode status) {
*status_out = status; *status_out = status;
quit_closure.Run(); std::move(quit_closure).Run();
} }
void DidFindRegistration( void DidFindRegistration(
blink::ServiceWorkerStatusCode* status_out, blink::ServiceWorkerStatusCode* status_out,
const base::Closure& quit_closure, base::OnceClosure quit_closure,
blink::ServiceWorkerStatusCode status, blink::ServiceWorkerStatusCode status,
scoped_refptr<ServiceWorkerRegistration> registration) { scoped_refptr<ServiceWorkerRegistration> registration) {
*status_out = status; *status_out = status;
quit_closure.Run(); std::move(quit_closure).Run();
} }
} // namespace } // namespace
......
...@@ -465,10 +465,10 @@ void ServiceWorkerRegistration::DeleteVersion( ...@@ -465,10 +465,10 @@ void ServiceWorkerRegistration::DeleteVersion(
} }
void ServiceWorkerRegistration::NotifyRegistrationFinished() { void ServiceWorkerRegistration::NotifyRegistrationFinished() {
std::vector<base::Closure> callbacks; std::vector<base::OnceClosure> callbacks;
callbacks.swap(registration_finished_callbacks_); callbacks.swap(registration_finished_callbacks_);
for (const auto& callback : callbacks) for (auto& callback : callbacks)
callback.Run(); std::move(callback).Run();
} }
void ServiceWorkerRegistration::SetTaskRunnerForTest( void ServiceWorkerRegistration::SetTaskRunnerForTest(
...@@ -490,11 +490,11 @@ void ServiceWorkerRegistration::SetNavigationPreloadHeader( ...@@ -490,11 +490,11 @@ void ServiceWorkerRegistration::SetNavigationPreloadHeader(
} }
void ServiceWorkerRegistration::RegisterRegistrationFinishedCallback( void ServiceWorkerRegistration::RegisterRegistrationFinishedCallback(
const base::Closure& callback) { base::OnceClosure callback) {
// This should only be called if the registration is in progress. // This should only be called if the registration is in progress.
DCHECK(!active_version() && !waiting_version() && !is_uninstalled() && DCHECK(!active_version() && !waiting_version() && !is_uninstalled() &&
!is_uninstalling()); !is_uninstalling());
registration_finished_callbacks_.push_back(callback); registration_finished_callbacks_.push_back(std::move(callback));
} }
void ServiceWorkerRegistration::DispatchActivateEvent( void ServiceWorkerRegistration::DispatchActivateEvent(
......
...@@ -175,7 +175,7 @@ class CONTENT_EXPORT ServiceWorkerRegistration ...@@ -175,7 +175,7 @@ class CONTENT_EXPORT ServiceWorkerRegistration
// registration from storage if there is no longer a stored version. // registration from storage if there is no longer a stored version.
void DeleteVersion(const scoped_refptr<ServiceWorkerVersion>& version); void DeleteVersion(const scoped_refptr<ServiceWorkerVersion>& version);
void RegisterRegistrationFinishedCallback(const base::Closure& callback); void RegisterRegistrationFinishedCallback(base::OnceClosure callback);
void NotifyRegistrationFinished(); void NotifyRegistrationFinished();
void SetTaskRunnerForTest( void SetTaskRunnerForTest(
...@@ -245,7 +245,7 @@ class CONTENT_EXPORT ServiceWorkerRegistration ...@@ -245,7 +245,7 @@ class CONTENT_EXPORT ServiceWorkerRegistration
scoped_refptr<ServiceWorkerVersion> installing_version_; scoped_refptr<ServiceWorkerVersion> installing_version_;
base::ObserverList<Listener>::Unchecked listeners_; base::ObserverList<Listener>::Unchecked listeners_;
std::vector<base::Closure> registration_finished_callbacks_; std::vector<base::OnceClosure> registration_finished_callbacks_;
base::WeakPtr<ServiceWorkerContextCore> context_; base::WeakPtr<ServiceWorkerContextCore> context_;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_; scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
......
...@@ -69,10 +69,10 @@ const uint8_t kTestPublicKey[] = { ...@@ -69,10 +69,10 @@ const uint8_t kTestPublicKey[] = {
}; };
void StatusAndQuitCallback(blink::ServiceWorkerStatusCode* result, void StatusAndQuitCallback(blink::ServiceWorkerStatusCode* result,
const base::Closure& quit_closure, base::OnceClosure quit_closure,
blink::ServiceWorkerStatusCode status) { blink::ServiceWorkerStatusCode status) {
*result = status; *result = status;
quit_closure.Run(); std::move(quit_closure).Run();
} }
void StatusCallback(bool* was_called, void StatusCallback(bool* was_called,
......
...@@ -33,29 +33,30 @@ class ServiceWorkerVersion; ...@@ -33,29 +33,30 @@ class ServiceWorkerVersion;
template <typename Arg> template <typename Arg>
void ReceiveResult(BrowserThread::ID run_quit_thread, void ReceiveResult(BrowserThread::ID run_quit_thread,
const base::Closure& quit, base::OnceClosure quit,
base::Optional<Arg>* out, base::Optional<Arg>* out,
Arg actual) { Arg actual) {
*out = actual; *out = actual;
if (!quit.is_null()) if (!quit.is_null())
BrowserThread::PostTask(run_quit_thread, FROM_HERE, quit); BrowserThread::PostTask(run_quit_thread, FROM_HERE, std::move(quit));
} }
template <typename Arg> template <typename Arg>
base::OnceCallback<void(Arg)> CreateReceiver(BrowserThread::ID run_quit_thread, base::OnceCallback<void(Arg)> CreateReceiver(BrowserThread::ID run_quit_thread,
const base::RepeatingClosure& quit, base::OnceClosure quit,
base::Optional<Arg>* out) { base::Optional<Arg>* out) {
return base::BindOnce(&ReceiveResult<Arg>, run_quit_thread, quit, out); return base::BindOnce(&ReceiveResult<Arg>, run_quit_thread, std::move(quit),
out);
} }
template <typename Arg> template <typename Arg>
base::OnceCallback<void(Arg)> CreateReceiverOnCurrentThread( base::OnceCallback<void(Arg)> CreateReceiverOnCurrentThread(
base::Optional<Arg>* out, base::Optional<Arg>* out,
const base::Closure& quit = base::Closure()) { base::OnceClosure quit = base::OnceClosure()) {
BrowserThread::ID id; BrowserThread::ID id;
bool ret = BrowserThread::GetCurrentThreadIdentifier(&id); bool ret = BrowserThread::GetCurrentThreadIdentifier(&id);
DCHECK(ret); DCHECK(ret);
return CreateReceiver(id, quit, out); return CreateReceiver(id, std::move(quit), out);
} }
// Container for keeping the Mojo connection to the service worker provider on // Container for keeping the Mojo connection to the service worker provider on
......
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