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

Convert MediaPerceptionApiManager to OnceCallback

The GetDiagnostics callback was the only one left in this class that
hasn't been converted to OnceCallback. It's only ever bound to a
BindOnce callback and then invoked once from there so it too is a
OnceCallback.

Bug: 1152268
Change-Id: Ib826d861d984fb57c7a9797c6b9589eb144574a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2601227Reviewed-by: default avatarToni Baržić <tbarzic@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#839751}
parent d4ab59fc
......@@ -358,10 +358,10 @@ void MediaPerceptionAPIManager::SetStateInternal(APIStateCallback callback,
}
void MediaPerceptionAPIManager::GetDiagnostics(
const APIGetDiagnosticsCallback& callback) {
APIGetDiagnosticsCallback callback) {
chromeos::MediaAnalyticsClient::Get()->GetDiagnostics(
base::BindOnce(&MediaPerceptionAPIManager::GetDiagnosticsCallback,
weak_ptr_factory_.GetWeakPtr(), callback));
weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
}
void MediaPerceptionAPIManager::UpstartStartProcessCallback(
......@@ -566,16 +566,17 @@ void MediaPerceptionAPIManager::StateCallback(
}
void MediaPerceptionAPIManager::GetDiagnosticsCallback(
const APIGetDiagnosticsCallback& callback,
APIGetDiagnosticsCallback callback,
base::Optional<mri::Diagnostics> result) {
if (!result.has_value()) {
callback.Run(GetDiagnosticsForServiceError(
std::move(callback).Run(GetDiagnosticsForServiceError(
extensions::api::media_perception_private::
SERVICE_ERROR_SERVICE_UNREACHABLE));
return;
}
callback.Run(extensions::api::media_perception_private::DiagnosticsProtoToIdl(
result.value()));
std::move(callback).Run(
extensions::api::media_perception_private::DiagnosticsProtoToIdl(
result.value()));
}
void MediaPerceptionAPIManager::OnDetectionSignal(
......
......@@ -34,7 +34,7 @@ class MediaPerceptionAPIManager
using APIStateCallback = base::OnceCallback<void(
extensions::api::media_perception_private::State state)>;
using APIGetDiagnosticsCallback = base::Callback<void(
using APIGetDiagnosticsCallback = base::OnceCallback<void(
extensions::api::media_perception_private::Diagnostics diagnostics)>;
explicit MediaPerceptionAPIManager(content::BrowserContext* context);
......@@ -64,7 +64,7 @@ class MediaPerceptionAPIManager
void GetState(APIStateCallback callback);
void SetState(const extensions::api::media_perception_private::State& state,
APIStateCallback callback);
void GetDiagnostics(const APIGetDiagnosticsCallback& callback);
void GetDiagnostics(APIGetDiagnosticsCallback callback);
// For testing purposes only. Allows the unittest to set the mount_point to
// something non-empty.
......@@ -102,7 +102,7 @@ class MediaPerceptionAPIManager
// Callback for GetDiagnostics D-Bus method calls to the media analytics
// process.
void GetDiagnosticsCallback(const APIGetDiagnosticsCallback& callback,
void GetDiagnosticsCallback(APIGetDiagnosticsCallback callback,
base::Optional<mri::Diagnostics> diagnostics);
// Callbacks for Upstart command to start media analytics process.
......
......@@ -147,8 +147,8 @@ media_perception::ServiceError GetDiagnosticsAndWaitForResponse(
base::RunLoop run_loop;
media_perception::ServiceError service_error;
manager->GetDiagnostics(
base::Bind(&RecordServiceErrorFromDiagnosticsAndRunClosure,
run_loop.QuitClosure(), &service_error));
base::BindOnce(&RecordServiceErrorFromDiagnosticsAndRunClosure,
run_loop.QuitClosure(), &service_error));
run_loop.Run();
return service_error;
}
......
......@@ -108,7 +108,7 @@ ExtensionFunction::ResponseAction
MediaPerceptionPrivateGetDiagnosticsFunction::Run() {
MediaPerceptionAPIManager* manager =
MediaPerceptionAPIManager::Get(browser_context());
manager->GetDiagnostics(base::Bind(
manager->GetDiagnostics(base::BindOnce(
&MediaPerceptionPrivateGetDiagnosticsFunction::GetDiagnosticsCallback,
this));
return RespondLater();
......
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