From 40a355a42d4a9444dc753c04c6608dade2f06a23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:27 +0200 Subject: Adding upstream version 125.0.1. Signed-off-by: Daniel Baumann --- dom/ipc/ContentParent.cpp | 136 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 96 insertions(+), 40 deletions(-) (limited to 'dom/ipc/ContentParent.cpp') diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 13206216f3..2dbdb662ff 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -78,6 +78,7 @@ #include "mozilla/StaticPrefs_fission.h" #include "mozilla/StaticPrefs_media.h" #include "mozilla/StaticPrefs_network.h" +#include "mozilla/StaticPrefs_threads.h" #include "mozilla/StaticPrefs_widget.h" #include "mozilla/StorageAccessAPIHelper.h" #include "mozilla/StyleSheet.h" @@ -213,7 +214,6 @@ #include "nsILocalStorageManager.h" #include "nsIMemoryInfoDumper.h" #include "nsIMemoryReporter.h" -#include "nsIMozBrowserFrame.h" #include "nsINetworkLinkService.h" #include "nsIObserverService.h" #include "nsIParentChannel.h" @@ -1601,27 +1601,24 @@ void ContentParent::BroadcastThemeUpdate(widget::ThemeChangeKind aKind) { /*static */ void ContentParent::BroadcastMediaCodecsSupportedUpdate( RemoteDecodeIn aLocation, const media::MediaCodecsSupported& aSupported) { - // Merge incoming codec support with existing support list - media::MCSInfo::AddSupport(aSupported); - auto support = media::MCSInfo::GetSupport(); - - // Update processes - sCodecsSupported[aLocation] = support; + // Update processes and print the support info from the given location. + sCodecsSupported[aLocation] = aSupported; for (auto* cp : AllProcesses(eAll)) { - Unused << cp->SendUpdateMediaCodecsSupported(aLocation, support); + Unused << cp->SendUpdateMediaCodecsSupported(aLocation, aSupported); } - - // Generate + save support string for display in about:support nsCString supportString; - media::MCSInfo::GetMediaCodecsSupportedString(supportString, support); - gfx::gfxVars::SetCodecSupportInfo(supportString); - - // Print the support info only from the given location for debug purpose. - supportString.Truncate(); media::MCSInfo::GetMediaCodecsSupportedString(supportString, aSupported); - supportString.ReplaceSubstring("\n"_ns, ", "_ns); LOGPDM("Broadcast support from '%s', support=%s", RemoteDecodeInToStr(aLocation), supportString.get()); + + // Merge incoming support with existing support list from other locations + media::MCSInfo::AddSupport(aSupported); + auto fullSupport = media::MCSInfo::GetSupport(); + + // Generate + save FULL support string for display in about:support + supportString.Truncate(); + media::MCSInfo::GetMediaCodecsSupportedString(supportString, fullSupport); + gfx::gfxVars::SetCodecSupportInfo(supportString); } const nsACString& ContentParent::GetRemoteType() const { return mRemoteType; } @@ -1798,6 +1795,14 @@ bool ContentParent::ShutDownProcess(ShutDownMethod aMethod) { SetInputPriorityEventEnabled(false); // If we did not earlier, let's signal the shutdown to JS now. SignalImpendingShutdownToContentJS(); + + // Adjust the QoS priorities for shutdown, if they exist. + if (StaticPrefs::threads_use_low_power_enabled() && + StaticPrefs:: + threads_lower_mainthread_priority_in_background_enabled()) { + SetMainThreadQoSPriority(nsIThread::QOS_PRIORITY_NORMAL); + } + // Send a high priority announcement first. If this fails, SendShutdown // will also fail. Unused << SendShutdownConfirmedHP(); @@ -3524,17 +3529,30 @@ mozilla::ipc::IPCResult ContentParent::RecvClipboardHasType( return IPC_OK(); } -mozilla::ipc::IPCResult ContentParent::RecvGetExternalClipboardFormats( - const int32_t& aWhichClipboard, const bool& aPlainTextOnly, - nsTArray* aTypes) { - MOZ_ASSERT(aTypes); - DataTransfer::GetExternalClipboardFormats(aWhichClipboard, aPlainTextOnly, - aTypes); - return IPC_OK(); -} - namespace { +static Result CreateClipboardReadRequest( + ContentParent& aContentParent, + nsIAsyncGetClipboardData& aAsyncGetClipboardData) { + nsTArray flavors; + nsresult rv = aAsyncGetClipboardData.GetFlavorList(flavors); + if (NS_FAILED(rv)) { + return Err(rv); + } + + auto requestParent = MakeNotNull>( + &aContentParent, &aAsyncGetClipboardData); + + // Open a remote endpoint for our PClipboardReadRequest actor. + ManagedEndpoint childEndpoint = + aContentParent.OpenPClipboardReadRequestEndpoint(requestParent); + if (NS_WARN_IF(!childEndpoint.IsValid())) { + return Err(NS_ERROR_FAILURE); + } + + return ClipboardReadRequest(std::move(childEndpoint), std::move(flavors)); +} + class ClipboardGetCallback final : public nsIAsyncClipboardGetCallback { public: ClipboardGetCallback(ContentParent* aContentParent, @@ -3548,20 +3566,16 @@ class ClipboardGetCallback final : public nsIAsyncClipboardGetCallback { // nsIAsyncClipboardGetCallback NS_IMETHOD OnSuccess( nsIAsyncGetClipboardData* aAsyncGetClipboardData) override { - nsTArray flavors; - nsresult rv = aAsyncGetClipboardData->GetFlavorList(flavors); - if (NS_FAILED(rv)) { - return OnError(rv); - } + MOZ_ASSERT(mContentParent); + MOZ_ASSERT(aAsyncGetClipboardData); - auto requestParent = MakeNotNull>( - mContentParent, aAsyncGetClipboardData); - if (!mContentParent->SendPClipboardReadRequestConstructor( - requestParent, std::move(flavors))) { - return OnError(NS_ERROR_FAILURE); + auto result = + CreateClipboardReadRequest(*mContentParent, *aAsyncGetClipboardData); + if (result.isErr()) { + return OnError(result.unwrapErr()); } - mResolver(PClipboardReadRequestOrError(requestParent)); + mResolver(result.unwrap()); return NS_OK; } @@ -3624,6 +3638,48 @@ mozilla::ipc::IPCResult ContentParent::RecvGetClipboardAsync( return IPC_OK(); } +mozilla::ipc::IPCResult ContentParent::RecvGetClipboardDataSnapshotSync( + nsTArray&& aTypes, const int32_t& aWhichClipboard, + const MaybeDiscarded& aRequestingWindowContext, + ClipboardReadRequestOrError* aRequestOrError) { + // If the requesting context has been discarded, cancel the paste. + if (aRequestingWindowContext.IsDiscarded()) { + *aRequestOrError = NS_ERROR_FAILURE; + return IPC_OK(); + } + + RefPtr requestingWindow = + aRequestingWindowContext.get_canonical(); + if (requestingWindow && requestingWindow->GetContentParent() != this) { + return IPC_FAIL( + this, "attempt to paste into WindowContext loaded in another process"); + } + + nsCOMPtr clipboard(do_GetService(kCClipboardCID)); + if (!clipboard) { + *aRequestOrError = NS_ERROR_FAILURE; + return IPC_OK(); + } + + nsCOMPtr asyncGetClipboardData; + nsresult rv = + clipboard->GetDataSnapshotSync(aTypes, aWhichClipboard, requestingWindow, + getter_AddRefs(asyncGetClipboardData)); + if (NS_FAILED(rv)) { + *aRequestOrError = rv; + return IPC_OK(); + } + + auto result = CreateClipboardReadRequest(*this, *asyncGetClipboardData); + if (result.isErr()) { + *aRequestOrError = result.unwrapErr(); + return IPC_OK(); + } + + *aRequestOrError = result.unwrap(); + return IPC_OK(); +} + already_AddRefed ContentParent::AllocPClipboardWriteRequestParent( const int32_t& aClipboardType) { @@ -4444,11 +4500,11 @@ void ContentParent::GeneratePairedMinidump(const char* aReason) { // minidump tagging along, so we have to tell the crash reporter that // it exists and is being appended. nsAutoCString additionalDumps("browser"); - mCrashReporter->AddAnnotation( + mCrashReporter->AddAnnotationNSCString( CrashReporter::Annotation::additional_minidumps, additionalDumps); nsDependentCString reason(aReason); - mCrashReporter->AddAnnotation(CrashReporter::Annotation::ipc_channel_error, - reason); + mCrashReporter->AddAnnotationNSCString( + CrashReporter::Annotation::ipc_channel_error, reason); // Generate the report and insert into the queue for submittal. if (mCrashReporter->GenerateMinidumpAndPair(this, "browser"_ns)) { @@ -7084,7 +7140,7 @@ mozilla::ipc::IPCResult ContentParent::RecvNotifyMediaFullScreenState( mozilla::ipc::IPCResult ContentParent::RecvNotifyPositionStateChanged( const MaybeDiscarded& aContext, - const PositionState& aState) { + const Maybe& aState) { if (aContext.IsNullOrDiscarded()) { return IPC_OK(); } -- cgit v1.2.3