This is an automated email from the git hooks/post-receive script.
richard pushed a change to branch tor-browser-91.13.0esr-11.5-1 in repository tor-browser.
from d5af74fa1bd2 fixup! Bug 10760: Integrate TorButton to TorBrowser core new 4c2181c10c70 Bug 1782211 - Init feature policy; r=ckerschb, a=RyanVM new c70f1d687f32 Bug 1787633 - Make nsTextToSubURI::UnEscapeNonAsciiURI static. r=m_kato, a=RyanVM new 6b11a0a00ce6 Bug 1779993 - Reject cookies with no name and a __Secure- or __Host- prefix r=necko-reviewers,kershaw a=RyanVM new 61fc2cfa6d99 Bug 1770094 r=freddyb,emilio a=RyanVM new 97dc7924d1a3 Bug 1767360 - use correct image size retrieved from the output type to create video frames buffer. r=media-playback-reviewers,jolin a=RyanVM new 954750b1e67e Bug 1776655 - Allocate input report context for each gamepad. r=mccr8, a=RyanVM new aae8a38c9aaf Bug 1785109, mark CustomElementRegistry as multizone holder, r=mccr8 a=RyanVM new 1b2bdfec0911 Bug 1786502 - Lock access to DeviceInfo devicechange callbacks. r=webrtc-reviewers,jib a=RyanVM new e2491522e54d Bug 1789440 - Track reply message IDs for MessageChannel async replies, r=ipc-reviewers,mccr8 a=RyanVM
The 9 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
Summary of changes: docshell/base/nsDocShell.cpp | 2 + dom/base/CustomElementRegistry.cpp | 3 +- dom/base/Document.cpp | 8 +++- dom/base/Document.h | 1 + dom/gamepad/cocoa/CocoaGamepad.cpp | 48 ++++++++++++++-------- dom/html/HTMLFormSubmission.cpp | 3 +- dom/html/HTMLSharedElement.cpp | 8 ++-- .../security/nsIContentSecurityPolicy.idl | 11 ++--- dom/jsurl/nsJSProtocolHandler.cpp | 12 ++---- dom/media/platforms/wmf/WMFVideoMFTManager.cpp | 38 ++++++++++------- dom/media/platforms/wmf/WMFVideoMFTManager.h | 11 ++++- dom/media/systemservices/CamerasParent.h | 2 +- dom/security/nsCSPContext.cpp | 11 ++--- intl/uconv/moz.build | 1 + intl/uconv/nsITextToSubURI.idl | 1 + intl/uconv/nsTextToSubURI.cpp | 14 +++++-- intl/uconv/nsTextToSubURI.h | 10 ++++- ipc/glue/MessageChannel.cpp | 7 ++-- ipc/glue/MessageChannel.h | 38 +++++++++-------- ipc/glue/ProtocolUtils.cpp | 6 ++- ipc/glue/ProtocolUtils.h | 8 ++-- ipc/ipdl/ipdl/lower.py | 10 ++++- netwerk/cookie/CookieService.cpp | 33 ++++++++++++++- netwerk/cookie/CookieService.h | 1 + netwerk/test/gtest/TestCookie.cpp | 26 ++++++++++++ parser/html/nsHtml5TreeOpExecutor.cpp | 40 ++++++++++++++++-- .../webrtc/modules/video_capture/video_capture.h | 8 +++- uriloader/exthandler/win/nsMIMEInfoWin.cpp | 11 ++--- 28 files changed, 263 insertions(+), 109 deletions(-)
This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch tor-browser-91.13.0esr-11.5-1 in repository tor-browser.
commit 4c2181c10c70fd1337d24588d67bb009604ddafe Author: Edgar Chen echen@mozilla.com AuthorDate: Wed Aug 24 20:56:16 2022 +0000
Bug 1782211 - Init feature policy; r=ckerschb, a=RyanVM
Differential Revision: https://phabricator.services.mozilla.com/D154161 --- docshell/base/nsDocShell.cpp | 2 ++ dom/base/Document.cpp | 8 ++++++-- dom/base/Document.h | 1 + 3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 2d0e65131382..8f1cf78208db 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -6655,6 +6655,8 @@ nsresult nsDocShell::CreateAboutBlankContentViewer( // after being set here. blankDoc->SetSandboxFlags(sandboxFlags);
+ blankDoc->InitFeaturePolicy(); + // create a content viewer for us and the new document docFactory->CreateInstanceForDocument( NS_ISUPPORTS_CAST(nsIDocShell*, this), blankDoc, "view", diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index 7bce87a3cbdb..0bf1bbdc7281 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -3744,8 +3744,8 @@ already_AddRefeddom::FeaturePolicy Document::GetParentFeaturePolicy() { return do_AddRef(child->GetContainerFeaturePolicy()); }
-nsresult Document::InitFeaturePolicy(nsIChannel* aChannel) { - MOZ_ASSERT(mFeaturePolicy, "we should only call init once"); +void Document::InitFeaturePolicy() { + MOZ_ASSERT(mFeaturePolicy, "we should have FeaturePolicy created");
mFeaturePolicy->ResetDeclaredPolicy();
@@ -3757,6 +3757,10 @@ nsresult Document::InitFeaturePolicy(nsIChannel* aChannel) { mFeaturePolicy->InheritPolicy(parentPolicy); mFeaturePolicy->SetSrcOrigin(parentPolicy->GetSrcOrigin()); } +} + +nsresult Document::InitFeaturePolicy(nsIChannel* aChannel) { + InitFeaturePolicy();
// We don't want to parse the http Feature-Policy header if this pref is off. if (!StaticPrefs::dom_security_featurePolicy_header_enabled()) { diff --git a/dom/base/Document.h b/dom/base/Document.h index 18caa8aaabef..8754803b1377 100644 --- a/dom/base/Document.h +++ b/dom/base/Document.h @@ -1517,6 +1517,7 @@ class Document : public nsINode,
void DoNotifyPossibleTitleChange();
+ void InitFeaturePolicy(); nsresult InitFeaturePolicy(nsIChannel* aChannel);
protected:
This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch tor-browser-91.13.0esr-11.5-1 in repository tor-browser.
commit c70f1d687f3275d8aed7ae111c6aac8fe6d796b4 Author: Masatoshi Kimura VYV03354@nifty.ne.jp AuthorDate: Tue Sep 6 15:59:06 2022 +0000
Bug 1787633 - Make nsTextToSubURI::UnEscapeNonAsciiURI static. r=m_kato, a=RyanVM
Differential Revision: https://phabricator.services.mozilla.com/D156007 --- dom/jsurl/nsJSProtocolHandler.cpp | 12 +++--------- intl/uconv/moz.build | 1 + intl/uconv/nsITextToSubURI.idl | 1 + intl/uconv/nsTextToSubURI.cpp | 14 +++++++++++--- intl/uconv/nsTextToSubURI.h | 10 ++++++++-- uriloader/exthandler/win/nsMIMEInfoWin.cpp | 11 +++-------- 6 files changed, 27 insertions(+), 22 deletions(-)
diff --git a/dom/jsurl/nsJSProtocolHandler.cpp b/dom/jsurl/nsJSProtocolHandler.cpp index 09b729442ed5..9257bb933924 100644 --- a/dom/jsurl/nsJSProtocolHandler.cpp +++ b/dom/jsurl/nsJSProtocolHandler.cpp @@ -36,10 +36,10 @@ #include "mozilla/dom/Document.h" #include "nsIObjectInputStream.h" #include "nsIObjectOutputStream.h" -#include "nsITextToSubURI.h" #include "nsIWritablePropertyBag2.h" #include "nsIContentSecurityPolicy.h" #include "nsSandboxFlags.h" +#include "nsTextToSubURI.h" #include "mozilla/BasePrincipal.h" #include "mozilla/CycleCollectedJSContext.h" #include "mozilla/dom/AutoEntryScript.h" @@ -1100,15 +1100,9 @@ NS_IMPL_ISUPPORTS(nsJSProtocolHandler, nsIProtocolHandler) const nsCString& aSpec, const char* aCharset, nsACString& aUTF8Spec) { aUTF8Spec.Truncate();
- nsresult rv; - - nsCOMPtr<nsITextToSubURI> txtToSubURI = - do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - nsAutoString uStr; - rv = txtToSubURI->UnEscapeNonAsciiURI(nsDependentCString(aCharset), aSpec, - uStr); + nsresult rv = nsTextToSubURI::UnEscapeNonAsciiURI( + nsDependentCString(aCharset), aSpec, uStr); NS_ENSURE_SUCCESS(rv, rv);
if (!IsAscii(uStr)) { diff --git a/intl/uconv/moz.build b/intl/uconv/moz.build index acad06dfa178..1e5db20d720a 100644 --- a/intl/uconv/moz.build +++ b/intl/uconv/moz.build @@ -15,6 +15,7 @@ XPIDL_MODULE = "uconv"
EXPORTS += [ "nsConverterInputStream.h", + "nsTextToSubURI.h", ]
UNIFIED_SOURCES += [ diff --git a/intl/uconv/nsITextToSubURI.idl b/intl/uconv/nsITextToSubURI.idl index ce53121a296b..075952648eaf 100644 --- a/intl/uconv/nsITextToSubURI.idl +++ b/intl/uconv/nsITextToSubURI.idl @@ -47,5 +47,6 @@ interface nsITextToSubURI : nsISupports * @throws NS_ERROR_UCONV_NOCONV when there is no decoder for aCharset * or NS_ERROR_UDEC_ILLEGALINPUT in case of conversion failure */ + [binaryname(UnEscapeNonAsciiURIJS)] AString unEscapeNonAsciiURI(in ACString aCharset, in AUTF8String aURIFragment); }; diff --git a/intl/uconv/nsTextToSubURI.cpp b/intl/uconv/nsTextToSubURI.cpp index b293a93ec595..cb52a7dc9a6e 100644 --- a/intl/uconv/nsTextToSubURI.cpp +++ b/intl/uconv/nsTextToSubURI.cpp @@ -73,6 +73,7 @@ static bool statefulCharset(const char* charset) { return false; }
+// static nsresult nsTextToSubURI::convertURItoUnicode(const nsCString& aCharset, const nsCString& aURI, nsAString& aOut) { @@ -138,9 +139,16 @@ NS_IMETHODIMP nsTextToSubURI::UnEscapeURIForUI(const nsACString& aURIFragment, }
NS_IMETHODIMP -nsTextToSubURI::UnEscapeNonAsciiURI(const nsACString& aCharset, - const nsACString& aURIFragment, - nsAString& _retval) { +nsTextToSubURI::UnEscapeNonAsciiURIJS(const nsACString& aCharset, + const nsACString& aURIFragment, + nsAString& _retval) { + return UnEscapeNonAsciiURI(aCharset, aURIFragment, _retval); +} + +// static +nsresult nsTextToSubURI::UnEscapeNonAsciiURI(const nsACString& aCharset, + const nsACString& aURIFragment, + nsAString& _retval) { nsAutoCString unescapedSpec; NS_UnescapeURL(PromiseFlatCString(aURIFragment), esc_AlwaysCopy | esc_OnlyNonASCII, unescapedSpec); diff --git a/intl/uconv/nsTextToSubURI.h b/intl/uconv/nsTextToSubURI.h index 6b2b742888b3..1eaeb554dc89 100644 --- a/intl/uconv/nsTextToSubURI.h +++ b/intl/uconv/nsTextToSubURI.h @@ -15,12 +15,18 @@ class nsTextToSubURI : public nsITextToSubURI { NS_DECL_ISUPPORTS NS_DECL_NSITEXTTOSUBURI
+ // Thread-safe function for C++ callers + static nsresult UnEscapeNonAsciiURI(const nsACString& aCharset, + const nsACString& aURIFragment, + nsAString& _retval); + private: virtual ~nsTextToSubURI();
// We assume that the URI is encoded as UTF-8. - nsresult convertURItoUnicode(const nsCString& aCharset, const nsCString& aURI, - nsAString& _retval); + static nsresult convertURItoUnicode(const nsCString& aCharset, + const nsCString& aURI, + nsAString& _retval);
// Characters defined in netwerk/dns/IDNCharacterBlocklist.inc or via the // network.IDN.extra_allowed_chars and network.IDN.extra_blocked_chars prefs. diff --git a/uriloader/exthandler/win/nsMIMEInfoWin.cpp b/uriloader/exthandler/win/nsMIMEInfoWin.cpp index b7007ff89d78..267076749ae1 100644 --- a/uriloader/exthandler/win/nsMIMEInfoWin.cpp +++ b/uriloader/exthandler/win/nsMIMEInfoWin.cpp @@ -16,7 +16,7 @@ #include <shlobj.h> #include "nsIWindowsRegKey.h" #include "nsUnicharUtils.h" -#include "nsITextToSubURI.h" +#include "nsTextToSubURI.h" #include "nsVariant.h" #include "mozilla/CmdLineAndEnvUtils.h" #include "mozilla/ShellHeaderOnlyUtils.h" @@ -283,13 +283,8 @@ nsresult nsMIMEInfoWin::LoadUriInternal(nsIURI* aURL) {
// Unescape non-ASCII characters in the URL nsAutoString utf16Spec; - - nsCOMPtr<nsITextToSubURI> textToSubURI = - do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - if (NS_FAILED(textToSubURI->UnEscapeNonAsciiURI("UTF-8"_ns, urlSpec, - utf16Spec))) { + if (NS_FAILED(nsTextToSubURI::UnEscapeNonAsciiURI("UTF-8"_ns, urlSpec, + utf16Spec))) { CopyASCIItoUTF16(urlSpec, utf16Spec); }
This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch tor-browser-91.13.0esr-11.5-1 in repository tor-browser.
commit 6b11a0a00ce64add6ca5dc8da581d563515afa5c Author: Valentin Gosu valentin.gosu@gmail.com AuthorDate: Wed Sep 7 19:04:22 2022 +0000
Bug 1779993 - Reject cookies with no name and a __Secure- or __Host- prefix r=necko-reviewers,kershaw a=RyanVM
Differential Revision: https://phabricator.services.mozilla.com/D156554 --- netwerk/cookie/CookieService.cpp | 33 ++++++++++++++++++++++++++++++++- netwerk/cookie/CookieService.h | 1 + netwerk/test/gtest/TestCookie.cpp | 26 ++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/netwerk/cookie/CookieService.cpp b/netwerk/cookie/CookieService.cpp index 956090aabca6..4c55fbe8307a 100644 --- a/netwerk/cookie/CookieService.cpp +++ b/netwerk/cookie/CookieService.cpp @@ -1139,6 +1139,18 @@ bool CookieService::CanSetCookie( return newCookie; }
+ if (!CheckHiddenPrefix(aCookieData)) { + COOKIE_LOGFAILURE(SET_COOKIE, aHostURI, savedCookieHeader, + "failed the CheckHiddenPrefix tests"); + CookieLogging::LogMessageToConsole( + aCRC, aHostURI, nsIScriptError::warningFlag, CONSOLE_REJECTION_CATEGORY, + "CookieRejectedInvalidPrefix"_ns, + AutoTArray<nsString, 1>{ + NS_ConvertUTF8toUTF16(aCookieData.name()), + }); + return newCookie; + } + // magic prefix checks. MUST be run after CheckDomain() and CheckPath() if (!CheckPrefixes(aCookieData, potentiallyTurstworthy)) { COOKIE_LOGFAILURE(SET_COOKIE, aHostURI, savedCookieHeader, @@ -1773,6 +1785,25 @@ bool CookieService::CheckDomain(CookieStruct& aCookieData, nsIURI* aHostURI, return true; }
+// static +bool CookieService::CheckHiddenPrefix(CookieStruct& aCookieData) { + // If a cookie is nameless, then its value must not start with + // `__Host-` or `__Secure-` + if (!aCookieData.name().IsEmpty()) { + return true; + } + + if (StringBeginsWith(aCookieData.value(), "__Host-"_ns)) { + return false; + } + + if (StringBeginsWith(aCookieData.value(), "__Secure-"_ns)) { + return false; + } + + return true; +} + namespace { nsAutoCString GetPathFromURI(nsIURI* aHostURI) { // strip down everything after the last slash to get the path, @@ -1849,7 +1880,7 @@ bool CookieService::CheckPath(CookieStruct& aCookieData, // CheckPrefixes // // Reject cookies whose name starts with the magic prefixes from -// https://tools.ietf.org/html/draft-ietf-httpbis-cookie-prefixes-00 +// https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis // if they do not meet the criteria required by the prefix. // // Must not be called until after CheckDomain() and CheckPath() have diff --git a/netwerk/cookie/CookieService.h b/netwerk/cookie/CookieService.h index fbb5ff04bf28..06323ee53e93 100644 --- a/netwerk/cookie/CookieService.h +++ b/netwerk/cookie/CookieService.h @@ -122,6 +122,7 @@ class CookieService final : public nsICookieService, static bool CheckDomain(CookieStruct& aCookieData, nsIURI* aHostURI, const nsACString& aBaseDomain, bool aRequireHostMatch); + static bool CheckHiddenPrefix(CookieStruct& aCookieData); static bool CheckPath(CookieStruct& aCookieData, nsIConsoleReportCollector* aCRC, nsIURI* aHostURI); static bool CheckPrefixes(CookieStruct& aCookieData, bool aSecureRequest); diff --git a/netwerk/test/gtest/TestCookie.cpp b/netwerk/test/gtest/TestCookie.cpp index 368915f99d57..7fc9f01632c1 100644 --- a/netwerk/test/gtest/TestCookie.cpp +++ b/netwerk/test/gtest/TestCookie.cpp @@ -1061,3 +1061,29 @@ TEST(TestCookie, OnionSite) GetACookieNoHttp(cookieService, "http://123456789abcdef.onion/", cookie); EXPECT_TRUE(CheckResult(cookie.get(), MUST_EQUAL, "test=onion-security4")); } + +TEST(TestCookie, HiddenPrefix) +{ + nsresult rv; + nsCString cookie; + + nsCOMPtr<nsICookieService> cookieService = + do_GetService(kCookieServiceCID, &rv); + ASSERT_TRUE(NS_SUCCEEDED(rv)); + + SetACookie(cookieService, "http://hiddenprefix.test/", "=__Host-test=a"); + GetACookie(cookieService, "http://hiddenprefix.test/", cookie); + EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL)); + + SetACookie(cookieService, "http://hiddenprefix.test/", "=__Secure-test=a"); + GetACookie(cookieService, "http://hiddenprefix.test/", cookie); + EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL)); + + SetACookie(cookieService, "http://hiddenprefix.test/", "=__Host-check"); + GetACookie(cookieService, "http://hiddenprefix.test/", cookie); + EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL)); + + SetACookie(cookieService, "http://hiddenprefix.test/", "=__Secure-check"); + GetACookie(cookieService, "http://hiddenprefix.test/", cookie); + EXPECT_TRUE(CheckResult(cookie.get(), MUST_BE_NULL)); +}
This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch tor-browser-91.13.0esr-11.5-1 in repository tor-browser.
commit 61fc2cfa6d994d4f41a360b9d7c1c9667626e880 Author: Tom Schuster tschuster@mozilla.com AuthorDate: Mon Aug 15 14:41:10 2022 +0000
Bug 1770094 r=freddyb,emilio a=RyanVM
Differential Revision: https://phabricator.services.mozilla.com/D154518 --- dom/html/HTMLFormSubmission.cpp | 3 +- dom/html/HTMLSharedElement.cpp | 8 ++--- .../security/nsIContentSecurityPolicy.idl | 11 +++--- dom/security/nsCSPContext.cpp | 11 +++--- parser/html/nsHtml5TreeOpExecutor.cpp | 40 +++++++++++++++++++--- 5 files changed, 54 insertions(+), 19 deletions(-)
diff --git a/dom/html/HTMLFormSubmission.cpp b/dom/html/HTMLFormSubmission.cpp index 4ea6b0b01176..82943df1ff5f 100644 --- a/dom/html/HTMLFormSubmission.cpp +++ b/dom/html/HTMLFormSubmission.cpp @@ -793,7 +793,8 @@ nsresult HTMLFormSubmission::GetFromForm(HTMLFormElement* aForm, // policy - do *not* consult default-src, see: // http://www.w3.org/TR/CSP2/#directive-default-src rv = csp->Permits(aForm, nullptr /* nsICSPEventListener */, actionURL, - nsIContentSecurityPolicy::FORM_ACTION_DIRECTIVE, true, + nsIContentSecurityPolicy::FORM_ACTION_DIRECTIVE, + true /* aSpecific */, true /* aSendViolationReports */, &permitsFormAction); NS_ENSURE_SUCCESS(rv, rv); if (!permitsFormAction) { diff --git a/dom/html/HTMLSharedElement.cpp b/dom/html/HTMLSharedElement.cpp index 4e3e1453846b..b168f327823e 100644 --- a/dom/html/HTMLSharedElement.cpp +++ b/dom/html/HTMLSharedElement.cpp @@ -155,10 +155,10 @@ static void SetBaseURIUsingFirstBaseWithHref(Document* aDocument, // policy - do *not* consult default-src, see: // http://www.w3.org/TR/CSP2/#directive-default-src bool cspPermitsBaseURI = true; - rv = csp->Permits(child->AsElement(), nullptr /* nsICSPEventListener */, - newBaseURI, - nsIContentSecurityPolicy::BASE_URI_DIRECTIVE, true, - &cspPermitsBaseURI); + rv = csp->Permits( + child->AsElement(), nullptr /* nsICSPEventListener */, newBaseURI, + nsIContentSecurityPolicy::BASE_URI_DIRECTIVE, true /* aSpecific */, + true /* aSendViolationReports */, &cspPermitsBaseURI); if (NS_FAILED(rv) || !cspPermitsBaseURI) { newBaseURI = nullptr; } diff --git a/dom/interfaces/security/nsIContentSecurityPolicy.idl b/dom/interfaces/security/nsIContentSecurityPolicy.idl index ca4703fcd108..3f15a072441a 100644 --- a/dom/interfaces/security/nsIContentSecurityPolicy.idl +++ b/dom/interfaces/security/nsIContentSecurityPolicy.idl @@ -288,11 +288,8 @@ interface nsIContentSecurityPolicy : nsISerializable /** * Checks if a specific directive permits loading of a URI. * - * NOTE: Calls to this may trigger violation reports when queried, so the - * return value should not be cached. - * * @param aTriggeringElement - * The element that triggers this CSP check. It can be null. + * The element that triggers this CSP check. It can be null. * @param aURI * The URI about to be loaded or used. * @param aDir @@ -304,6 +301,9 @@ interface nsIContentSecurityPolicy : nsISerializable * "false" allows CSP to fall back to default-src. This function * behaves the same for both values of canUseDefault when querying * directives that don't fall-back. + * @param aSendViolationReports + * If `true` and the uri is not allowed then trigger violation reports. + * This should be `false` for caching or preloads. * @return * Whether or not the provided URI is allowed by CSP under the given * directive. (block the pending operation if false). @@ -312,7 +312,8 @@ interface nsIContentSecurityPolicy : nsISerializable in nsICSPEventListener aCSPEventListener, in nsIURI aURI, in nsIContentSecurityPolicy_CSPDirective aDir, - in boolean aSpecific); + in boolean aSpecific, + in boolean aSendViolationReports);
/** * Delegate method called by the service when sub-elements of the protected diff --git a/dom/security/nsCSPContext.cpp b/dom/security/nsCSPContext.cpp index 113ee2cf95a1..9b7a99f272c3 100644 --- a/dom/security/nsCSPContext.cpp +++ b/dom/security/nsCSPContext.cpp @@ -1632,7 +1632,8 @@ nsCSPContext::PermitsAncestry(nsILoadInfo* aLoadInfo, NS_IMETHODIMP nsCSPContext::Permits(Element* aTriggeringElement, nsICSPEventListener* aCSPEventListener, nsIURI* aURI, - CSPDirective aDir, bool aSpecific, bool* outPermits) { + CSPDirective aDir, bool aSpecific, + bool aSendViolationReports, bool* outPermits) { // Can't perform check without aURI if (aURI == nullptr) { return NS_ERROR_FAILURE; @@ -1654,14 +1655,14 @@ nsCSPContext::Permits(Element* aTriggeringElement, permitsInternal(aDir, aTriggeringElement, aCSPEventListener, aURI, nullptr, // no original (pre-redirect) URI u""_ns, // no nonce - aSpecific, - true, // send violation reports + aSpecific, aSendViolationReports, true, // send blocked URI in violation reports false); // not parser created
if (CSPCONTEXTLOGENABLED()) { - CSPCONTEXTLOG(("nsCSPContext::Permits, aUri: %s, aDir: %d, isAllowed: %s", - aURI->GetSpecOrDefault().get(), aDir, + CSPCONTEXTLOG(("nsCSPContext::Permits, aUri: %s, aDir: %s, isAllowed: %s", + aURI->GetSpecOrDefault().get(), + CSP_CSPDirectiveToString(aDir), *outPermits ? "allow" : "deny")); }
diff --git a/parser/html/nsHtml5TreeOpExecutor.cpp b/parser/html/nsHtml5TreeOpExecutor.cpp index dd865ee6eb22..484aeb68635c 100644 --- a/parser/html/nsHtml5TreeOpExecutor.cpp +++ b/parser/html/nsHtml5TreeOpExecutor.cpp @@ -1262,11 +1262,44 @@ void nsHtml5TreeOpExecutor::SetSpeculationBase(const nsAString& aURL) { // the first one wins return; } + auto encoding = mDocument->GetDocumentCharacterSet(); - DebugOnly<nsresult> rv = NS_NewURI(getter_AddRefs(mSpeculationBaseURI), aURL, - encoding, mDocument->GetDocumentURI()); + nsCOMPtr<nsIURI> newBaseURI; + DebugOnly<nsresult> rv = NS_NewURI(getter_AddRefs(newBaseURI), aURL, encoding, + mDocument->GetDocumentURI()); NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to create a URI"); + if (!newBaseURI) { + return; + } + + // Check the document's CSP usually delivered via the CSP header. + if (nsCOMPtr<nsIContentSecurityPolicy> csp = mDocument->GetCsp()) { + // base-uri should not fallback to the default-src and preloads should not + // trigger violation reports. + bool cspPermitsBaseURI = true; + nsresult rv = csp->Permits( + nullptr, nullptr, newBaseURI, + nsIContentSecurityPolicy::BASE_URI_DIRECTIVE, true /* aSpecific */, + false /* aSendViolationReports */, &cspPermitsBaseURI); + if (NS_FAILED(rv) || !cspPermitsBaseURI) { + return; + } + } + + // Also check the CSP discovered from the <meta> tag during speculative + // parsing. + if (nsCOMPtr<nsIContentSecurityPolicy> csp = mDocument->GetPreloadCsp()) { + bool cspPermitsBaseURI = true; + nsresult rv = csp->Permits( + nullptr, nullptr, newBaseURI, + nsIContentSecurityPolicy::BASE_URI_DIRECTIVE, true /* aSpecific */, + false /* aSendViolationReports */, &cspPermitsBaseURI); + if (NS_FAILED(rv) || !cspPermitsBaseURI) { + return; + } + }
+ mSpeculationBaseURI = newBaseURI; mDocument->Preloads().SetSpeculationBase(mSpeculationBaseURI); }
@@ -1290,8 +1323,7 @@ void nsHtml5TreeOpExecutor::AddSpeculationCSP(const nsAString& aCSP) { NS_ENSURE_SUCCESS_VOID(rv); }
- // please note that meta CSPs and CSPs delivered through a header need - // to be joined together. + // Please note that multiple meta CSPs need to be joined together. rv = preloadCsp->AppendPolicy( aCSP, false, // csp via meta tag can not be report only
This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch tor-browser-91.13.0esr-11.5-1 in repository tor-browser.
commit 97dc7924d1a369deda583cac7aa8f01fb73ca057 Author: alwu alwu@mozilla.com AuthorDate: Wed Aug 31 01:34:44 2022 +0000
Bug 1767360 - use correct image size retrieved from the output type to create video frames buffer. r=media-playback-reviewers,jolin a=RyanVM
Differential Revision: https://phabricator.services.mozilla.com/D154310 --- dom/media/platforms/wmf/WMFVideoMFTManager.cpp | 38 ++++++++++++++++---------- dom/media/platforms/wmf/WMFVideoMFTManager.h | 11 +++++++- 2 files changed, 34 insertions(+), 15 deletions(-)
diff --git a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp index 084736e0a70c..6ef81eac494f 100644 --- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp +++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp @@ -114,7 +114,8 @@ WMFVideoMFTManager::WMFVideoMFTManager( const CreateDecoderParams::OptionSet& aOptions, bool aDXVAEnabled) : mVideoInfo(aConfig), mImageSize(aConfig.mImage), - mDecodedImageSize(aConfig.mImage), + mSoftwareImageSize(aConfig.mImage), + mSoftwarePictureSize(aConfig.mImage), mVideoStride(0), mColorSpace(aConfig.mColorSpace), mColorRange(aConfig.mColorRange), @@ -144,8 +145,8 @@ WMFVideoMFTManager::WMFVideoMFTManager( // The V and U planes are stored 16-row-aligned, so we need to add padding // to the row heights to ensure the Y'CbCr planes are referenced properly. // This value is only used with software decoder. - if (mDecodedImageSize.height % 16 != 0) { - mDecodedImageSize.height += 16 - (mDecodedImageSize.height % 16); + if (mSoftwareImageSize.height % 16 != 0) { + mSoftwareImageSize.height += 16 - (mSoftwareImageSize.height % 16); } }
@@ -582,8 +583,8 @@ WMFVideoMFTManager::CreateBasicVideoFrame(IMFSample* aSample, // https://docs.microsoft.com/en-us/windows/desktop/medfound/10-bit-and-16-bit-... VideoData::YCbCrBuffer b;
- uint32_t videoWidth = mImageSize.width; - uint32_t videoHeight = mImageSize.height; + const uint32_t videoWidth = mSoftwareImageSize.width; + const uint32_t videoHeight = mSoftwareImageSize.height;
// Y (Y') plane b.mPlanes[0].mData = data; @@ -592,13 +593,13 @@ WMFVideoMFTManager::CreateBasicVideoFrame(IMFSample* aSample, b.mPlanes[0].mWidth = videoWidth; b.mPlanes[0].mSkip = 0;
- MOZ_DIAGNOSTIC_ASSERT(mDecodedImageSize.height % 16 == 0, + MOZ_DIAGNOSTIC_ASSERT(mSoftwareImageSize.height % 16 == 0, "decoded height must be 16 bytes aligned"); - uint32_t y_size = stride * mDecodedImageSize.height; - uint32_t v_size = stride * mDecodedImageSize.height / 4; - uint32_t halfStride = (stride + 1) / 2; - uint32_t halfHeight = (videoHeight + 1) / 2; - uint32_t halfWidth = (videoWidth + 1) / 2; + const uint32_t y_size = stride * mSoftwareImageSize.height; + const uint32_t v_size = stride * mSoftwareImageSize.height / 4; + const uint32_t halfStride = (stride + 1) / 2; + const uint32_t halfHeight = (videoHeight + 1) / 2; + const uint32_t halfWidth = (videoWidth + 1) / 2;
if (subType == MFVideoFormat_YV12) { // U plane (Cb) @@ -640,8 +641,8 @@ WMFVideoMFTManager::CreateBasicVideoFrame(IMFSample* aSample, NS_ENSURE_TRUE(pts.IsValid(), E_FAIL); TimeUnit duration = GetSampleDurationOrLastKnownDuration(aSample); NS_ENSURE_TRUE(duration.IsValid(), E_FAIL); - gfx::IntRect pictureRegion = - mVideoInfo.ScaledImageRect(videoWidth, videoHeight); + gfx::IntRect pictureRegion = mVideoInfo.ScaledImageRect( + mSoftwarePictureSize.width, mSoftwarePictureSize.height);
if (colorDepth != gfx::ColorDepth::COLOR_8 || !mKnowsCompositor || !mKnowsCompositor->SupportsD3D11() || !mIMFUsable) { @@ -763,7 +764,16 @@ WMFVideoMFTManager::Output(int64_t aStreamOffset, RefPtr<MediaData>& aOutData) { NS_ENSURE_TRUE(SUCCEEDED(hr), hr); NS_ENSURE_TRUE(width <= MAX_VIDEO_WIDTH, E_FAIL); NS_ENSURE_TRUE(height <= MAX_VIDEO_HEIGHT, E_FAIL); - mDecodedImageSize = gfx::IntSize(width, height); + mSoftwareImageSize = gfx::IntSize(width, height); + + gfx::IntRect picture; + hr = GetPictureRegion(outputType, picture); + NS_ENSURE_TRUE(SUCCEEDED(hr), hr); + MOZ_ASSERT(picture.width != 0 && picture.height != 0); + mSoftwarePictureSize = gfx::IntSize(picture.width, picture.height); + LOG("Output stream change, image size=[%ux%u], picture=[%u,%u]", + mSoftwareImageSize.width, mSoftwareImageSize.height, + mSoftwarePictureSize.width, mSoftwarePictureSize.height); } // Catch infinite loops, but some decoders perform at least 2 stream // changes on consecutive calls, so be permissive. diff --git a/dom/media/platforms/wmf/WMFVideoMFTManager.h b/dom/media/platforms/wmf/WMFVideoMFTManager.h index f35524c061e1..378089a000db 100644 --- a/dom/media/platforms/wmf/WMFVideoMFTManager.h +++ b/dom/media/platforms/wmf/WMFVideoMFTManager.h @@ -79,7 +79,16 @@ class WMFVideoMFTManager : public MFTManager { // Video frame geometry. const VideoInfo mVideoInfo; const gfx::IntSize mImageSize; - gfx::IntSize mDecodedImageSize; + + // The size we update from the IMFMediaType which might include paddings when + // the stream format changes. This is only used for software decoding. + gfx::IntSize mSoftwareImageSize; + + // The picture size we update from the IMFMediaType when the stream format + // changes. We assume it's equal to the image size by default (no cropping). + // This is only used for software decoding. + gfx::IntSize mSoftwarePictureSize; + uint32_t mVideoStride; Maybegfx::YUVColorSpace mColorSpace; gfx::ColorRange mColorRange;
This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch tor-browser-91.13.0esr-11.5-1 in repository tor-browser.
commit 954750b1e67e67a8beff83be52262f6dd7018d14 Author: Chris Martin cmartin@mozilla.com AuthorDate: Mon Aug 29 19:12:58 2022 +0000
Bug 1776655 - Allocate input report context for each gamepad. r=mccr8, a=RyanVM
Differential Revision: https://phabricator.services.mozilla.com/D152938 --- dom/gamepad/cocoa/CocoaGamepad.cpp | 48 ++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 18 deletions(-)
diff --git a/dom/gamepad/cocoa/CocoaGamepad.cpp b/dom/gamepad/cocoa/CocoaGamepad.cpp index 16316c1c69e0..c744edf137a8 100644 --- a/dom/gamepad/cocoa/CocoaGamepad.cpp +++ b/dom/gamepad/cocoa/CocoaGamepad.cpp @@ -28,7 +28,6 @@ namespace {
using namespace mozilla; using namespace mozilla::dom; -using std::vector; class DarwinGamepadService;
DarwinGamepadService* gService = nullptr; @@ -80,6 +79,11 @@ const unsigned kBackUsage = 0x224; // 50ms is arbitrarily chosen. const uint32_t kDarwinGamepadPollInterval = 50;
+struct GamepadInputReportContext { + DarwinGamepadService* service; + size_t gamepadSlot; +}; + class Gamepad { private: IOHIDDeviceRef mDevice; @@ -120,7 +124,8 @@ class Gamepad {
GamepadHandle mHandle; RefPtr<GamepadRemapper> mRemapper; - std::vector<uint8_t> mInputReport; + nsTArray<uint8_t> mInputReport; + UniquePtr<GamepadInputReportContext> mInputReportContext; };
void Gamepad::init(IOHIDDeviceRef aDevice, bool aDefaultRemapper) { @@ -179,7 +184,7 @@ void Gamepad::init(IOHIDDeviceRef aDevice, bool aDefaultRemapper) { class DarwinGamepadService { private: IOHIDManagerRef mManager; - vector<Gamepad> mGamepads; + nsTArray<Gamepad> mGamepads;
nsCOMPtr<nsIThread> mMonitorThread; nsCOMPtr<nsIThread> mBackgroundThread; @@ -272,14 +277,14 @@ void DarwinGamepadService::DeviceAdded(IOHIDDeviceRef device) { }
size_t slot = size_t(-1); - for (size_t i = 0; i < mGamepads.size(); i++) { + for (size_t i = 0; i < mGamepads.Length(); i++) { if (mGamepads[i] == device) return; if (slot == size_t(-1) && mGamepads[i].empty()) slot = i; }
if (slot == size_t(-1)) { - slot = mGamepads.size(); - mGamepads.push_back(Gamepad()); + slot = mGamepads.Length(); + mGamepads.AppendElement(Gamepad()); }
// Gather some identifying information @@ -322,13 +327,15 @@ void DarwinGamepadService::DeviceAdded(IOHIDDeviceRef device) { }
mGamepads[slot].mHandle = handle; - mGamepads[slot].mInputReport.resize(remapper->GetMaxInputReportLength()); + mGamepads[slot].mInputReport.SetLength(remapper->GetMaxInputReportLength()); + mGamepads[slot].mInputReportContext = UniquePtr<GamepadInputReportContext>( + new GamepadInputReportContext{this, slot}); mGamepads[slot].mRemapper = remapper.forget();
IOHIDDeviceRegisterInputReportCallback( - device, mGamepads[slot].mInputReport.data(), - mGamepads[slot].mInputReport.size(), ReportChangedCallback, - &mGamepads[slot]); + device, mGamepads[slot].mInputReport.Elements(), + mGamepads[slot].mInputReport.Length(), ReportChangedCallback, + mGamepads[slot].mInputReportContext.get()); }
void DarwinGamepadService::DeviceRemoved(IOHIDDeviceRef device) { @@ -337,13 +344,16 @@ void DarwinGamepadService::DeviceRemoved(IOHIDDeviceRef device) { if (!service) { return; } - for (size_t i = 0; i < mGamepads.size(); i++) { - if (mGamepads[i] == device) { + for (Gamepad& gamepad : mGamepads) { + if (gamepad == device) { IOHIDDeviceRegisterInputReportCallback( - device, mGamepads[i].mInputReport.data(), 0, NULL, &mGamepads[i]); + device, gamepad.mInputReport.Elements(), 0, NULL, + gamepad.mInputReportContext.get()); + + gamepad.mInputReportContext.reset();
- service->RemoveGamepad(mGamepads[i].mHandle); - mGamepads[i].clear(); + service->RemoveGamepad(gamepad.mHandle); + gamepad.clear(); return; } } @@ -354,7 +364,10 @@ void DarwinGamepadService::ReportChangedCallback( void* context, IOReturn result, void* sender, IOHIDReportType report_type, uint32_t report_id, uint8_t* report, CFIndex report_length) { if (context && report_type == kIOHIDReportTypeInput && report_length) { - reinterpret_cast<Gamepad*>(context)->ReportChanged(report, report_length); + auto reportContext = static_cast<GamepadInputReportContext*>(context); + DarwinGamepadService* service = reportContext->service; + service->mGamepads[reportContext->gamepadSlot].ReportChanged(report, + report_length); } }
@@ -388,8 +401,7 @@ void DarwinGamepadService::InputValueChanged(IOHIDValueRef value) { IOHIDElementRef element = IOHIDValueGetElement(value); IOHIDDeviceRef device = IOHIDElementGetDevice(element);
- for (unsigned i = 0; i < mGamepads.size(); i++) { - Gamepad& gamepad = mGamepads[i]; + for (Gamepad& gamepad : mGamepads) { if (gamepad == device) { // Axis elements represent axes and d-pads. if (Axis* axis = gamepad.lookupAxis(element)) {
This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch tor-browser-91.13.0esr-11.5-1 in repository tor-browser.
commit aae8a38c9aaf1d0f8a0e51dde544f899424f9fdb Author: Olli Pettay Olli.Pettay@helsinki.fi AuthorDate: Mon Aug 22 16:12:26 2022 +0000
Bug 1785109, mark CustomElementRegistry as multizone holder, r=mccr8 a=RyanVM
Differential Revision: https://phabricator.services.mozilla.com/D154878 --- dom/base/CustomElementRegistry.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/dom/base/CustomElementRegistry.cpp b/dom/base/CustomElementRegistry.cpp index 11446f05bc1c..504d7dd18ba7 100644 --- a/dom/base/CustomElementRegistry.cpp +++ b/dom/base/CustomElementRegistry.cpp @@ -266,8 +266,7 @@ class MOZ_RAII AutoConstructionStackEntry final {
} // namespace
-// Only needed for refcounted objects. -NS_IMPL_CYCLE_COLLECTION_CLASS(CustomElementRegistry) +NS_IMPL_CYCLE_COLLECTION_MULTI_ZONE_JSHOLDER_CLASS(CustomElementRegistry)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(CustomElementRegistry) tmp->mConstructors.clear();
This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch tor-browser-91.13.0esr-11.5-1 in repository tor-browser.
commit 1b2bdfec0911435074f8e3d5f360c886c195c2f2 Author: Andreas Pehrson apehrson@mozilla.com AuthorDate: Mon Sep 5 13:56:11 2022 +0000
Bug 1786502 - Lock access to DeviceInfo devicechange callbacks. r=webrtc-reviewers,jib a=RyanVM
Differential Revision: https://phabricator.services.mozilla.com/D155365 --- dom/media/systemservices/CamerasParent.h | 2 +- .../libwebrtc/webrtc/modules/video_capture/video_capture.h | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/dom/media/systemservices/CamerasParent.h b/dom/media/systemservices/CamerasParent.h index adf85e176eb7..d29664d1c458 100644 --- a/dom/media/systemservices/CamerasParent.h +++ b/dom/media/systemservices/CamerasParent.h @@ -62,7 +62,7 @@ class InputObserver : public webrtc::VideoInputFeedBack { private: ~InputObserver() = default;
- RefPtr<CamerasParent> mParent; + const RefPtr<CamerasParent> mParent; };
class CamerasParent final : public PCamerasParent, diff --git a/third_party/libwebrtc/webrtc/modules/video_capture/video_capture.h b/third_party/libwebrtc/webrtc/modules/video_capture/video_capture.h index 11c880baa772..2ae33fba98a8 100644 --- a/third_party/libwebrtc/webrtc/modules/video_capture/video_capture.h +++ b/third_party/libwebrtc/webrtc/modules/video_capture/video_capture.h @@ -16,6 +16,8 @@ #include "media/base/videosinkinterface.h" #include "modules/include/module.h" #include "modules/video_capture/video_capture_defines.h" +#include "rtc_base/synchronization/mutex.h" +#include "rtc_base/thread_annotations.h" #include <set>
#if defined(ANDROID) @@ -81,15 +83,18 @@ class VideoCaptureModule: public rtc::RefCountInterface { virtual uint32_t NumberOfDevices() = 0; virtual int32_t Refresh() = 0; virtual void DeviceChange() { + MutexLock lock(&_inputCallbacksMutex); for (auto inputCallBack : _inputCallBacks) { inputCallBack->OnDeviceChange(); } } virtual void RegisterVideoInputFeedBack(VideoInputFeedBack* callBack) { + MutexLock lock(&_inputCallbacksMutex); _inputCallBacks.insert(callBack); }
virtual void DeRegisterVideoInputFeedBack(VideoInputFeedBack* callBack) { + MutexLock lock(&_inputCallbacksMutex); auto it = _inputCallBacks.find(callBack); if (it != _inputCallBacks.end()) { _inputCallBacks.erase(it); @@ -147,7 +152,8 @@ class VideoCaptureModule: public rtc::RefCountInterface {
virtual ~DeviceInfo() {} private: - std::set<VideoInputFeedBack*> _inputCallBacks; + Mutex _inputCallbacksMutex; + std::set<VideoInputFeedBack*> _inputCallBacks RTC_GUARDED_BY(_inputCallbacksMutex); };
// Register capture data callback
This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch tor-browser-91.13.0esr-11.5-1 in repository tor-browser.
commit e2491522e54dd23286d872b3518578589b84ff51 Author: Nika Layzell nika@thelayzells.com AuthorDate: Wed Sep 7 23:38:45 2022 +0000
Bug 1789440 - Track reply message IDs for MessageChannel async replies, r=ipc-reviewers,mccr8 a=RyanVM
Differential Revision: https://phabricator.services.mozilla.com/D156569 --- ipc/glue/MessageChannel.cpp | 7 ++++--- ipc/glue/MessageChannel.h | 38 ++++++++++++++++++++------------------ ipc/glue/ProtocolUtils.cpp | 6 ++++-- ipc/glue/ProtocolUtils.h | 8 +++++--- ipc/ipdl/ipdl/lower.py | 10 ++++++++-- 5 files changed, 41 insertions(+), 28 deletions(-)
diff --git a/ipc/glue/MessageChannel.cpp b/ipc/glue/MessageChannel.cpp index ac1c4d9a7b36..bb10e7f4610e 100644 --- a/ipc/glue/MessageChannel.cpp +++ b/ipc/glue/MessageChannel.cpp @@ -940,9 +940,10 @@ void MessageChannel::StopPostponingSends() { }
UniquePtrMessageChannel::UntypedCallbackHolder MessageChannel::PopCallback( - const Message& aMsg) { + const Message& aMsg, int32_t aActorId) { auto iter = mPendingResponses.find(aMsg.seqno()); - if (iter != mPendingResponses.end()) { + if (iter != mPendingResponses.end() && iter->second->mActorId == aActorId && + iter->second->mReplyMsgId == aMsg.type()) { UniquePtrMessageChannel::UntypedCallbackHolder ret = std::move(iter->second); mPendingResponses.erase(iter); @@ -952,7 +953,7 @@ UniquePtrMessageChannel::UntypedCallbackHolder MessageChannel::PopCallback( return nullptr; }
-void MessageChannel::RejectPendingResponsesForActor(ActorIdType aActorId) { +void MessageChannel::RejectPendingResponsesForActor(int32_t aActorId) { auto itr = mPendingResponses.begin(); while (itr != mPendingResponses.end()) { if (itr->second.get()->mActorId != aActorId) { diff --git a/ipc/glue/MessageChannel.h b/ipc/glue/MessageChannel.h index bc65f0e29bce..2c7f33736950 100644 --- a/ipc/glue/MessageChannel.h +++ b/ipc/glue/MessageChannel.h @@ -112,29 +112,30 @@ class MessageChannel : HasResultCodes {
typedef mozilla::Monitor Monitor;
- // We could templatize the actor type but it would unnecessarily - // expand the code size. Using the actor address as the - // identifier is already good enough. - typedef void* ActorIdType; - public: + using Message = IPC::Message; + struct UntypedCallbackHolder { - UntypedCallbackHolder(ActorIdType aActorId, RejectCallback&& aReject) - : mActorId(aActorId), mReject(std::move(aReject)) {} + UntypedCallbackHolder(int32_t aActorId, Message::msgid_t aReplyMsgId, + RejectCallback&& aReject) + : mActorId(aActorId), + mReplyMsgId(aReplyMsgId), + mReject(std::move(aReject)) {}
virtual ~UntypedCallbackHolder() = default;
void Reject(ResponseRejectReason&& aReason) { mReject(std::move(aReason)); }
- ActorIdType mActorId; + int32_t mActorId; + Message::msgid_t mReplyMsgId; RejectCallback mReject; };
template <typename Value> struct CallbackHolder : public UntypedCallbackHolder { - CallbackHolder(ActorIdType aActorId, ResolveCallback<Value>&& aResolve, - RejectCallback&& aReject) - : UntypedCallbackHolder(aActorId, std::move(aReject)), + CallbackHolder(int32_t aActorId, Message::msgid_t aReplyMsgId, + ResolveCallback<Value>&& aResolve, RejectCallback&& aReject) + : UntypedCallbackHolder(aActorId, aReplyMsgId, std::move(aReject)), mResolve(std::move(aResolve)) {}
void Resolve(Value&& aReason) { mResolve(std::move(aReason)); } @@ -149,7 +150,6 @@ class MessageChannel : HasResultCodes { public: static const int32_t kNoTimeout;
- typedef IPC::Message Message; typedef IPC::MessageInfo MessageInfo; typedef mozilla::ipc::Transport Transport; using ScopedPort = mozilla::ipc::ScopedPort; @@ -232,8 +232,9 @@ class MessageChannel : HasResultCodes { // Asynchronously send a message to the other side of the channel // and wait for asynchronous reply. template <typename Value> - void Send(UniquePtr<Message> aMsg, ActorIdType aActorId, - ResolveCallback<Value>&& aResolve, RejectCallback&& aReject) { + void Send(UniquePtr<Message> aMsg, int32_t aActorId, + Message::msgid_t aReplyMsgId, ResolveCallback<Value>&& aResolve, + RejectCallback&& aReject) { int32_t seqno = NextSeqno(); aMsg->set_seqno(seqno); if (!Send(std::move(aMsg))) { @@ -242,8 +243,8 @@ class MessageChannel : HasResultCodes { }
UniquePtr<UntypedCallbackHolder> callback = - MakeUnique<CallbackHolder<Value>>(aActorId, std::move(aResolve), - std::move(aReject)); + MakeUnique<CallbackHolder<Value>>( + aActorId, aReplyMsgId, std::move(aResolve), std::move(aReject)); mPendingResponses.insert(std::make_pair(seqno, std::move(callback))); gUnresolvedResponses++; } @@ -263,11 +264,12 @@ class MessageChannel : HasResultCodes { bool CanSend() const;
// Remove and return a callback that needs reply - UniquePtr<UntypedCallbackHolder> PopCallback(const Message& aMsg); + UniquePtr<UntypedCallbackHolder> PopCallback(const Message& aMsg, + int32_t aActorId);
// Used to reject and remove pending responses owned by the given // actor when it's about to be destroyed. - void RejectPendingResponsesForActor(ActorIdType aActorId); + void RejectPendingResponsesForActor(int32_t aActorId);
// If sending a sync message returns an error, this function gives a more // descriptive error message. diff --git a/ipc/glue/ProtocolUtils.cpp b/ipc/glue/ProtocolUtils.cpp index ea88763c9af2..4f46c1965be1 100644 --- a/ipc/glue/ProtocolUtils.cpp +++ b/ipc/glue/ProtocolUtils.cpp @@ -585,9 +585,11 @@ void IProtocol::DestroySubtree(ActorDestroyReason aWhy) { MOZ_ASSERT(CanRecv(), "destroying non-connected actor"); MOZ_ASSERT(mLifecycleProxy, "destroying zombie actor");
+ int32_t id = Id(); + // If we're a managed actor, unregister from our manager if (Manager()) { - Unregister(Id()); + Unregister(id); }
// Destroy subtree @@ -614,7 +616,7 @@ void IProtocol::DestroySubtree(ActorDestroyReason aWhy) { // The actor is being destroyed, reject any pending responses, invoke // `ActorDestroy` to destroy it, and then clear our status to // `LinkStatus::Destroyed`. - GetIPCChannel()->RejectPendingResponsesForActor(this); + GetIPCChannel()->RejectPendingResponsesForActor(id); ActorDestroy(aWhy); mLinkStatus = LinkStatus::Destroyed; } diff --git a/ipc/glue/ProtocolUtils.h b/ipc/glue/ProtocolUtils.h index 3d024686727a..a0b64b05ccfd 100644 --- a/ipc/glue/ProtocolUtils.h +++ b/ipc/glue/ProtocolUtils.h @@ -302,12 +302,14 @@ class IProtocol : public HasResultCodes { bool ChannelSend(IPC::Message* aMsg, IPC::Message* aReply); bool ChannelCall(IPC::Message* aMsg, IPC::Message* aReply); template <typename Value> - void ChannelSend(IPC::Message* aMsg, ResolveCallback<Value>&& aResolve, + void ChannelSend(IPC::Message* aMsg, + IPC::Message::msgid_t aReplyMsgId, + ResolveCallback<Value>&& aResolve, RejectCallback&& aReject) { UniquePtrIPC::Message msg(aMsg); if (CanSend()) { - GetIPCChannel()->Send(std::move(msg), this, std::move(aResolve), - std::move(aReject)); + GetIPCChannel()->Send(std::move(msg), Id(), aReplyMsgId, + std::move(aResolve), std::move(aReject)); } else { NS_WARNING("IPC message discarded: actor cannot send"); aReject(ResponseRejectReason::SendError); diff --git a/ipc/ipdl/ipdl/lower.py b/ipc/ipdl/ipdl/lower.py index e40cbcf46353..fbd174032e46 100644 --- a/ipc/ipdl/ipdl/lower.py +++ b/ipc/ipdl/ipdl/lower.py @@ -4803,7 +4803,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): $*{prologue}
UniquePtrMessageChannel::UntypedCallbackHolder untypedCallback = - GetIPCChannel()->PopCallback(${msgvar}); + GetIPCChannel()->PopCallback(${msgvar}, Id());
typedef MessageChannel::CallbackHolder<${resolvetype}> CallbackHolder; auto* callback = static_cast<CallbackHolder*>(untypedCallback.get()); @@ -5342,7 +5342,13 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor): stmts.append( StmtExpr( ExprCall( - send, args=[msgexpr, ExprMove(resolvefn), ExprMove(rejectfn)] + send, + args=[ + ExprMove(msgexpr), + ExprVar(md.pqReplyId()), + ExprMove(resolvefn), + ExprMove(rejectfn), + ], ) ) )
tor-commits@lists.torproject.org