screencast_portal: Add Unknown status for portal RequestResponse
Remote desktop wrapper needs to create a barrier on when the screencast portal is done (either succeeded or failed). This change adds an initial enum to differentiate it from other values. CL also generalizes the helper `PortalFailed` to `OnPortalDone` so as to account for both failure/success scenarios. Bug: chromium:1291247 Change-Id: I188f72533e75a88c9b30ce2bb093dae548cef7b1 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/258540 Reviewed-by: Alexander Cooper <alcooper@chromium.org> Commit-Queue: Salman Malik <salmanmalik@google.com> Cr-Commit-Position: refs/heads/main@{#36526}
This commit is contained in:
parent
f5fd25ca04
commit
49a106c8e6
@ -20,7 +20,9 @@ namespace xdg_portal {
|
||||
class ScreenCapturePortalInterface {
|
||||
public:
|
||||
virtual ~ScreenCapturePortalInterface() {}
|
||||
// Gets details about the session such as session handle.
|
||||
virtual xdg_portal::SessionDetails GetSessionDetails() = 0;
|
||||
// Starts the portal setup.
|
||||
virtual void Start() = 0;
|
||||
};
|
||||
|
||||
|
||||
@ -116,7 +116,7 @@ xdg_portal::SessionDetails ScreenCastPortal::GetSessionDetails() {
|
||||
return {}; // No-op
|
||||
}
|
||||
|
||||
void ScreenCastPortal::PortalFailed(RequestResponse result) {
|
||||
void ScreenCastPortal::OnPortalDone(RequestResponse result) {
|
||||
notifier_->OnScreenCastRequestResult(result, pw_stream_node_id_, pw_fd_);
|
||||
}
|
||||
|
||||
@ -240,7 +240,7 @@ void ScreenCastPortal::OnSourcesRequested(GDBusProxy* proxy,
|
||||
if (g_error_matches(error.get(), G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
return;
|
||||
RTC_LOG(LS_ERROR) << "Failed to request the sources: " << error->message;
|
||||
that->PortalFailed(RequestResponse::kError);
|
||||
that->OnPortalDone(RequestResponse::kError);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -255,7 +255,7 @@ void ScreenCastPortal::OnSourcesRequested(GDBusProxy* proxy,
|
||||
that->sources_request_signal_id_);
|
||||
that->sources_request_signal_id_ = 0;
|
||||
}
|
||||
that->PortalFailed(RequestResponse::kError);
|
||||
that->OnPortalDone(RequestResponse::kError);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -281,7 +281,7 @@ void ScreenCastPortal::OnSourcesRequestResponseSignal(
|
||||
if (portal_response) {
|
||||
RTC_LOG(LS_ERROR)
|
||||
<< "Failed to select sources for the screen cast session.";
|
||||
that->PortalFailed(RequestResponse::kError);
|
||||
that->OnPortalDone(RequestResponse::kError);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -321,7 +321,7 @@ void ScreenCastPortal::OnStartRequestResponseSignal(GDBusConnection* connection,
|
||||
response_data.receive());
|
||||
if (portal_response || !response_data) {
|
||||
RTC_LOG(LS_ERROR) << "Failed to start the screen cast session.";
|
||||
that->PortalFailed(static_cast<RequestResponse>(portal_response));
|
||||
that->OnPortalDone(static_cast<RequestResponse>(portal_response));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -388,7 +388,7 @@ void ScreenCastPortal::OnOpenPipeWireRemoteRequested(GDBusProxy* proxy,
|
||||
return;
|
||||
RTC_LOG(LS_ERROR) << "Failed to open the PipeWire remote: "
|
||||
<< error->message;
|
||||
that->PortalFailed(RequestResponse::kError);
|
||||
that->OnPortalDone(RequestResponse::kError);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -400,12 +400,11 @@ void ScreenCastPortal::OnOpenPipeWireRemoteRequested(GDBusProxy* proxy,
|
||||
if (that->pw_fd_ == -1) {
|
||||
RTC_LOG(LS_ERROR) << "Failed to get file descriptor from the list: "
|
||||
<< error->message;
|
||||
that->PortalFailed(RequestResponse::kError);
|
||||
that->OnPortalDone(RequestResponse::kError);
|
||||
return;
|
||||
}
|
||||
|
||||
that->notifier_->OnScreenCastRequestResult(
|
||||
RequestResponse::kSuccess, that->pw_stream_node_id_, that->pw_fd_);
|
||||
that->OnPortalDone(RequestResponse::kSuccess);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -92,7 +92,7 @@ class ScreenCastPortal : public xdg_portal::ScreenCapturePortalInterface {
|
||||
xdg_portal::SessionDetails GetSessionDetails() override;
|
||||
|
||||
// Method to notify the reason for failure of a portal request.
|
||||
void PortalFailed(xdg_portal::RequestResponse result);
|
||||
void OnPortalDone(xdg_portal::RequestResponse result);
|
||||
|
||||
// Sends a create session request to the portal.
|
||||
void SessionRequest(GDBusProxy* proxy);
|
||||
|
||||
@ -17,6 +17,8 @@ namespace xdg_portal {
|
||||
|
||||
std::string RequestResponseToString(RequestResponse request) {
|
||||
switch (request) {
|
||||
case RequestResponse::kUnknown:
|
||||
return "kUnknown";
|
||||
case RequestResponse::kSuccess:
|
||||
return "kSuccess";
|
||||
case RequestResponse::kUserCancelled:
|
||||
|
||||
@ -64,6 +64,8 @@ using SessionStartRequestedHandler = void (*)(GDBusProxy*,
|
||||
// Contains type of responses that can be observed when making a request to
|
||||
// a desktop portal interface.
|
||||
enum class RequestResponse {
|
||||
// Unknown, the initialized status.
|
||||
kUnknown,
|
||||
// Success, the request is carried out.
|
||||
kSuccess,
|
||||
// The user cancelled the interaction.
|
||||
@ -133,7 +135,7 @@ void RequestSessionUsingProxy(T* portal,
|
||||
return;
|
||||
RTC_LOG(LS_ERROR) << "Failed to get a proxy for the portal: "
|
||||
<< error->message;
|
||||
portal->PortalFailed(RequestResponse::kError);
|
||||
portal->OnPortalDone(RequestResponse::kError);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -155,7 +157,7 @@ void SessionRequestHandler(T* portal,
|
||||
if (g_error_matches(error.get(), G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
return;
|
||||
RTC_LOG(LS_ERROR) << "Failed to session: " << error->message;
|
||||
portal->PortalFailed(RequestResponse::kError);
|
||||
portal->OnPortalDone(RequestResponse::kError);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -167,7 +169,7 @@ void SessionRequestHandler(T* portal,
|
||||
if (!handle) {
|
||||
RTC_LOG(LS_ERROR) << "Failed to initialize the session.";
|
||||
portal->UnsubscribeSignalHandlers();
|
||||
portal->PortalFailed(RequestResponse::kError);
|
||||
portal->OnPortalDone(RequestResponse::kError);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -192,7 +194,7 @@ void SessionRequestResponseSignalHelper(
|
||||
|
||||
if (session_handle.empty() || portal_response) {
|
||||
RTC_LOG(LS_ERROR) << "Failed to request the session subscription.";
|
||||
portal->PortalFailed(RequestResponse::kError);
|
||||
portal->OnPortalDone(RequestResponse::kError);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -213,7 +215,7 @@ void StartRequestedHandler(T* portal, GDBusProxy* proxy, GAsyncResult* result) {
|
||||
return;
|
||||
RTC_LOG(LS_ERROR) << "Failed to start the portal session: "
|
||||
<< error->message;
|
||||
portal->PortalFailed(RequestResponse::kError);
|
||||
portal->OnPortalDone(RequestResponse::kError);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -222,7 +224,7 @@ void StartRequestedHandler(T* portal, GDBusProxy* proxy, GAsyncResult* result) {
|
||||
if (!handle) {
|
||||
RTC_LOG(LS_ERROR) << "Failed to initialize the start portal session.";
|
||||
portal->UnsubscribeSignalHandlers();
|
||||
portal->PortalFailed(RequestResponse::kError);
|
||||
portal->OnPortalDone(RequestResponse::kError);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user