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