diff options
43 files changed, 192 insertions, 1871 deletions
@@ -22,4 +22,4 @@ # changes to stick? As of bug 928195, this shouldn't be necessary! Please # don't change CLOBBER for WebIDL changes any more. -Removal of SIMD.js and associated scalar types requires CLOBBER. (Issue #2307) +Switching to C++17 requires CLOBBER to pick up compiler conf. (Issue #2281) diff --git a/build/moz.configure/toolchain.configure b/build/moz.configure/toolchain.configure index cc0540ea1c..40b87cf626 100644 --- a/build/moz.configure/toolchain.configure +++ b/build/moz.configure/toolchain.configure @@ -340,17 +340,16 @@ def check_compiler(compiler, language, target): if info.type in ('clang-cl', 'clang', 'gcc'): append_flag('-std=gnu99') - # Note: this is a strict version check because we used to always add - # -std=gnu++14. - cxx14_version = 201402 + cxx17_version = 201703 if info.language == 'C++': - if info.type in ('clang', 'gcc') and info.language_version != cxx14_version: - append_flag('-std=gnu++14') - # MSVC 2015 headers include C++14 features, but don't guard them - # with appropriate checks. - if info.type == 'clang-cl' and info.language_version != cxx14_version: - append_flag('-std=c++14') - # MSVC from 2015 on defaults to C++14. + if info.language_version != cxx17_version: + # Compiler doesn't default to C++17, so add the appropriate flag. + if info.type in ('clang', 'gcc'): + # We're on Clang or GCC, enable C++17 and add GNU extensions. + append_flag('-std=gnu++17') + else: + # We're on MSVC; enable C++17 language mode. + append_flag('-std:c++17') # We force clang-cl to emulate Visual C++ 2015 Update 3 with fallback to # cl.exe. diff --git a/build/moz.configure/warnings.configure b/build/moz.configure/warnings.configure index 2edf1748ad..0704f94a09 100644 --- a/build/moz.configure/warnings.configure +++ b/build/moz.configure/warnings.configure @@ -52,7 +52,7 @@ check_and_add_gcc_warning('-Wclass-varargs') check_and_add_gcc_warning('-Wloop-analysis') # catches C++ version forward-compat issues -check_and_add_gcc_warning('-Wc++1z-compat', cxx_compiler) +# check_and_add_gcc_warning('-Wc++2a-compat', cxx_compiler) # catches unintentional switch case fallthroughs check_and_add_gcc_warning('-Wimplicit-fallthrough', cxx_compiler) diff --git a/dom/base/EventSource.cpp b/dom/base/EventSource.cpp index 06cabc3098..32329098e2 100644 --- a/dom/base/EventSource.cpp +++ b/dom/base/EventSource.cpp @@ -190,6 +190,7 @@ public: bool IsClosed() { + MutexAutoLock lock(mMutex); return ReadyState() == CLOSED; } diff --git a/dom/media/gmp/GMPChild.cpp b/dom/media/gmp/GMPChild.cpp index 0bf9d44036..1b02a0c244 100644 --- a/dom/media/gmp/GMPChild.cpp +++ b/dom/media/gmp/GMPChild.cpp @@ -10,7 +10,6 @@ #include "GMPVideoDecoderChild.h" #include "GMPVideoEncoderChild.h" #include "GMPAudioDecoderChild.h" -#include "GMPDecryptorChild.h" #include "GMPVideoHost.h" #include "nsDebugImpl.h" #include "nsIFile.h" @@ -164,13 +163,12 @@ GMPChild::RecvSetNodeId(const nsCString& aNodeId) GMPErr GMPChild::GetAPI(const char* aAPIName, void* aHostAPI, - void** aPluginAPI, - uint32_t aDecryptorId) + void** aPluginAPI) { if (!mGMPLoader) { return GMPGenericErr; } - return mGMPLoader->GetAPI(aAPIName, aHostAPI, aPluginAPI, aDecryptorId); + return mGMPLoader->GetAPI(aAPIName, aHostAPI, aPluginAPI); } bool diff --git a/dom/media/gmp/GMPChild.h b/dom/media/gmp/GMPChild.h index 722e4c7a91..a807564f72 100644 --- a/dom/media/gmp/GMPChild.h +++ b/dom/media/gmp/GMPChild.h @@ -69,7 +69,7 @@ private: void ActorDestroy(ActorDestroyReason aWhy) override; void ProcessingError(Result aCode, const char* aReason) override; - GMPErr GetAPI(const char* aAPIName, void* aHostAPI, void** aPluginAPI, uint32_t aDecryptorId = 0); + GMPErr GetAPI(const char* aAPIName, void* aHostAPI, void** aPluginAPI); nsTArray<UniquePtr<GMPContentChild>> mGMPContentChildren; diff --git a/dom/media/gmp/GMPContentChild.cpp b/dom/media/gmp/GMPContentChild.cpp index 415736e11a..9155d9bf4d 100644 --- a/dom/media/gmp/GMPContentChild.cpp +++ b/dom/media/gmp/GMPContentChild.cpp @@ -6,7 +6,6 @@ #include "GMPContentChild.h" #include "GMPChild.h" #include "GMPAudioDecoderChild.h" -#include "GMPDecryptorChild.h" #include "GMPVideoDecoderChild.h" #include "GMPVideoEncoderChild.h" #include "base/task.h" @@ -62,25 +61,8 @@ GMPContentChild::DeallocPGMPAudioDecoderChild(PGMPAudioDecoderChild* aActor) return true; } -PGMPDecryptorChild* -GMPContentChild::AllocPGMPDecryptorChild() -{ - GMPDecryptorChild* actor = new GMPDecryptorChild(this, - mGMPChild->mPluginVoucher, - mGMPChild->mSandboxVoucher); - actor->AddRef(); - return actor; -} - -bool -GMPContentChild::DeallocPGMPDecryptorChild(PGMPDecryptorChild* aActor) -{ - static_cast<GMPDecryptorChild*>(aActor)->Release(); - return true; -} - PGMPVideoDecoderChild* -GMPContentChild::AllocPGMPVideoDecoderChild(const uint32_t& aDecryptorId) +GMPContentChild::AllocPGMPVideoDecoderChild() { GMPVideoDecoderChild* actor = new GMPVideoDecoderChild(this); actor->AddRef(); @@ -109,124 +91,6 @@ GMPContentChild::DeallocPGMPVideoEncoderChild(PGMPVideoEncoderChild* aActor) return true; } -// Adapts GMPDecryptor7 to the current GMPDecryptor version. -class GMPDecryptor7BackwardsCompat : public GMPDecryptor { -public: - explicit GMPDecryptor7BackwardsCompat(GMPDecryptor7* aDecryptorV7) - : mDecryptorV7(aDecryptorV7) - { - } - - void Init(GMPDecryptorCallback* aCallback, - bool aDistinctiveIdentifierRequired, - bool aPersistentStateRequired) override - { - // Distinctive identifier and persistent state arguments not present - // in v7 interface. - mDecryptorV7->Init(aCallback); - } - - void CreateSession(uint32_t aCreateSessionToken, - uint32_t aPromiseId, - const char* aInitDataType, - uint32_t aInitDataTypeSize, - const uint8_t* aInitData, - uint32_t aInitDataSize, - GMPSessionType aSessionType) override - { - mDecryptorV7->CreateSession(aCreateSessionToken, - aPromiseId, - aInitDataType, - aInitDataTypeSize, - aInitData, - aInitDataSize, - aSessionType); - } - - void LoadSession(uint32_t aPromiseId, - const char* aSessionId, - uint32_t aSessionIdLength) override - { - mDecryptorV7->LoadSession(aPromiseId, aSessionId, aSessionIdLength); - } - - void UpdateSession(uint32_t aPromiseId, - const char* aSessionId, - uint32_t aSessionIdLength, - const uint8_t* aResponse, - uint32_t aResponseSize) override - { - mDecryptorV7->UpdateSession(aPromiseId, - aSessionId, - aSessionIdLength, - aResponse, - aResponseSize); - } - - void CloseSession(uint32_t aPromiseId, - const char* aSessionId, - uint32_t aSessionIdLength) override - { - mDecryptorV7->CloseSession(aPromiseId, aSessionId, aSessionIdLength); - } - - void RemoveSession(uint32_t aPromiseId, - const char* aSessionId, - uint32_t aSessionIdLength) override - { - mDecryptorV7->RemoveSession(aPromiseId, aSessionId, aSessionIdLength); - } - - void SetServerCertificate(uint32_t aPromiseId, - const uint8_t* aServerCert, - uint32_t aServerCertSize) override - { - mDecryptorV7->SetServerCertificate(aPromiseId, aServerCert, aServerCertSize); - } - - void Decrypt(GMPBuffer* aBuffer, - GMPEncryptedBufferMetadata* aMetadata) override - { - mDecryptorV7->Decrypt(aBuffer, aMetadata); - } - - void DecryptingComplete() override - { - mDecryptorV7->DecryptingComplete(); - delete this; - } -private: - GMPDecryptor7* mDecryptorV7; -}; - -bool -GMPContentChild::RecvPGMPDecryptorConstructor(PGMPDecryptorChild* aActor) -{ - GMPDecryptorChild* child = static_cast<GMPDecryptorChild*>(aActor); - GMPDecryptorHost* host = static_cast<GMPDecryptorHost*>(child); - - void* ptr = nullptr; - GMPErr err = mGMPChild->GetAPI(GMP_API_DECRYPTOR, host, &ptr, aActor->Id()); - GMPDecryptor* decryptor = nullptr; - if (GMP_SUCCEEDED(err) && ptr) { - decryptor = static_cast<GMPDecryptor*>(ptr); - } else if (err != GMPNoErr) { - // We Adapt the previous GMPDecryptor version to the current, so that - // Gecko thinks it's only talking to the current version. v7 differs - // from v9 in its Init() function arguments, and v9 has extra enumeration - // members at the end of the key status enumerations. - err = mGMPChild->GetAPI(GMP_API_DECRYPTOR_BACKWARDS_COMPAT, host, &ptr); - if (err != GMPNoErr || !ptr) { - return false; - } - decryptor = new GMPDecryptor7BackwardsCompat(static_cast<GMPDecryptor7*>(ptr)); - } - - child->Init(decryptor); - - return true; -} - bool GMPContentChild::RecvPGMPAudioDecoderConstructor(PGMPAudioDecoderChild* aActor) { @@ -244,13 +108,12 @@ GMPContentChild::RecvPGMPAudioDecoderConstructor(PGMPAudioDecoderChild* aActor) } bool -GMPContentChild::RecvPGMPVideoDecoderConstructor(PGMPVideoDecoderChild* aActor, - const uint32_t& aDecryptorId) +GMPContentChild::RecvPGMPVideoDecoderConstructor(PGMPVideoDecoderChild* aActor) { auto vdc = static_cast<GMPVideoDecoderChild*>(aActor); void* vd = nullptr; - GMPErr err = mGMPChild->GetAPI(GMP_API_VIDEO_DECODER, &vdc->Host(), &vd, aDecryptorId); + GMPErr err = mGMPChild->GetAPI(GMP_API_VIDEO_DECODER, &vdc->Host(), &vd); if (err != GMPNoErr || !vd) { NS_WARNING("GMPGetAPI call failed trying to construct decoder."); return false; @@ -288,12 +151,6 @@ GMPContentChild::CloseActive() iter.Get()->GetKey()->SendShutdown(); } - const ManagedContainer<PGMPDecryptorChild>& decryptors = - ManagedPGMPDecryptorChild(); - for (auto iter = decryptors.ConstIter(); !iter.Done(); iter.Next()) { - iter.Get()->GetKey()->SendShutdown(); - } - const ManagedContainer<PGMPVideoDecoderChild>& videoDecoders = ManagedPGMPVideoDecoderChild(); for (auto iter = videoDecoders.ConstIter(); !iter.Done(); iter.Next()) { @@ -311,7 +168,6 @@ bool GMPContentChild::IsUsed() { return !ManagedPGMPAudioDecoderChild().IsEmpty() || - !ManagedPGMPDecryptorChild().IsEmpty() || !ManagedPGMPVideoDecoderChild().IsEmpty() || !ManagedPGMPVideoEncoderChild().IsEmpty(); } diff --git a/dom/media/gmp/GMPContentChild.h b/dom/media/gmp/GMPContentChild.h index 7142076084..8cbcc90cd0 100644 --- a/dom/media/gmp/GMPContentChild.h +++ b/dom/media/gmp/GMPContentChild.h @@ -24,17 +24,13 @@ public: MessageLoop* GMPMessageLoop(); bool RecvPGMPAudioDecoderConstructor(PGMPAudioDecoderChild* aActor) override; - bool RecvPGMPDecryptorConstructor(PGMPDecryptorChild* aActor) override; - bool RecvPGMPVideoDecoderConstructor(PGMPVideoDecoderChild* aActor, const uint32_t& aDecryptorId) override; + bool RecvPGMPVideoDecoderConstructor(PGMPVideoDecoderChild* aActor) override; bool RecvPGMPVideoEncoderConstructor(PGMPVideoEncoderChild* aActor) override; PGMPAudioDecoderChild* AllocPGMPAudioDecoderChild() override; bool DeallocPGMPAudioDecoderChild(PGMPAudioDecoderChild* aActor) override; - PGMPDecryptorChild* AllocPGMPDecryptorChild() override; - bool DeallocPGMPDecryptorChild(PGMPDecryptorChild* aActor) override; - - PGMPVideoDecoderChild* AllocPGMPVideoDecoderChild(const uint32_t& aDecryptorId) override; + PGMPVideoDecoderChild* AllocPGMPVideoDecoderChild() override; bool DeallocPGMPVideoDecoderChild(PGMPVideoDecoderChild* aActor) override; PGMPVideoEncoderChild* AllocPGMPVideoEncoderChild() override; diff --git a/dom/media/gmp/GMPContentParent.cpp b/dom/media/gmp/GMPContentParent.cpp index 12f6f4c48b..efc21e19e7 100644 --- a/dom/media/gmp/GMPContentParent.cpp +++ b/dom/media/gmp/GMPContentParent.cpp @@ -5,7 +5,6 @@ #include "GMPContentParent.h" #include "GMPAudioDecoderParent.h" -#include "GMPDecryptorParent.h" #include "GMPParent.h" #include "GMPServiceChild.h" #include "GMPVideoDecoderParent.h" @@ -67,7 +66,6 @@ void GMPContentParent::ActorDestroy(ActorDestroyReason aWhy) { MOZ_ASSERT(mAudioDecoders.IsEmpty() && - mDecryptors.IsEmpty() && mVideoDecoders.IsEmpty() && mVideoEncoders.IsEmpty()); NS_DispatchToCurrentThread(new ReleaseGMPContentParent(this)); @@ -109,19 +107,9 @@ GMPContentParent::VideoEncoderDestroyed(GMPVideoEncoderParent* aEncoder) } void -GMPContentParent::DecryptorDestroyed(GMPDecryptorParent* aSession) -{ - MOZ_ASSERT(GMPThread() == NS_GetCurrentThread()); - - MOZ_ALWAYS_TRUE(mDecryptors.RemoveElement(aSession)); - CloseIfUnused(); -} - -void GMPContentParent::CloseIfUnused() { if (mAudioDecoders.IsEmpty() && - mDecryptors.IsEmpty() && mVideoDecoders.IsEmpty() && mVideoEncoders.IsEmpty()) { RefPtr<GMPContentParent> toClose; @@ -138,23 +126,6 @@ GMPContentParent::CloseIfUnused() } } -nsresult -GMPContentParent::GetGMPDecryptor(GMPDecryptorParent** aGMPDP) -{ - PGMPDecryptorParent* pdp = SendPGMPDecryptorConstructor(); - if (!pdp) { - return NS_ERROR_FAILURE; - } - GMPDecryptorParent* dp = static_cast<GMPDecryptorParent*>(pdp); - // This addref corresponds to the Proxy pointer the consumer is returned. - // It's dropped by calling Close() on the interface. - NS_ADDREF(dp); - mDecryptors.AppendElement(dp); - *aGMPDP = dp; - - return NS_OK; -} - nsIThread* GMPContentParent::GMPThread() { @@ -194,11 +165,10 @@ GMPContentParent::GetGMPAudioDecoder(GMPAudioDecoderParent** aGMPAD) } nsresult -GMPContentParent::GetGMPVideoDecoder(GMPVideoDecoderParent** aGMPVD, - uint32_t aDecryptorId) +GMPContentParent::GetGMPVideoDecoder(GMPVideoDecoderParent** aGMPVD) { // returned with one anonymous AddRef that locks it until Destroy - PGMPVideoDecoderParent* pvdp = SendPGMPVideoDecoderConstructor(aDecryptorId); + PGMPVideoDecoderParent* pvdp = SendPGMPVideoDecoderConstructor(); if (!pvdp) { return NS_ERROR_FAILURE; } @@ -231,7 +201,7 @@ GMPContentParent::GetGMPVideoEncoder(GMPVideoEncoderParent** aGMPVE) } PGMPVideoDecoderParent* -GMPContentParent::AllocPGMPVideoDecoderParent(const uint32_t& aDecryptorId) +GMPContentParent::AllocPGMPVideoDecoderParent() { GMPVideoDecoderParent* vdp = new GMPVideoDecoderParent(this); NS_ADDREF(vdp); @@ -262,22 +232,6 @@ GMPContentParent::DeallocPGMPVideoEncoderParent(PGMPVideoEncoderParent* aActor) return true; } -PGMPDecryptorParent* -GMPContentParent::AllocPGMPDecryptorParent() -{ - GMPDecryptorParent* ksp = new GMPDecryptorParent(this); - NS_ADDREF(ksp); - return ksp; -} - -bool -GMPContentParent::DeallocPGMPDecryptorParent(PGMPDecryptorParent* aActor) -{ - GMPDecryptorParent* ksp = static_cast<GMPDecryptorParent*>(aActor); - NS_RELEASE(ksp); - return true; -} - PGMPAudioDecoderParent* GMPContentParent::AllocPGMPAudioDecoderParent() { diff --git a/dom/media/gmp/GMPContentParent.h b/dom/media/gmp/GMPContentParent.h index 81f79bc73d..e53d811038 100644 --- a/dom/media/gmp/GMPContentParent.h +++ b/dom/media/gmp/GMPContentParent.h @@ -14,7 +14,6 @@ namespace mozilla { namespace gmp { class GMPAudioDecoderParent; -class GMPDecryptorParent; class GMPParent; class GMPVideoDecoderParent; class GMPVideoEncoderParent; @@ -27,16 +26,12 @@ public: explicit GMPContentParent(GMPParent* aParent = nullptr); - nsresult GetGMPVideoDecoder(GMPVideoDecoderParent** aGMPVD, - uint32_t aDecryptorId); + nsresult GetGMPVideoDecoder(GMPVideoDecoderParent** aGMPVD); void VideoDecoderDestroyed(GMPVideoDecoderParent* aDecoder); nsresult GetGMPVideoEncoder(GMPVideoEncoderParent** aGMPVE); void VideoEncoderDestroyed(GMPVideoEncoderParent* aEncoder); - nsresult GetGMPDecryptor(GMPDecryptorParent** aGMPKS); - void DecryptorDestroyed(GMPDecryptorParent* aSession); - nsresult GetGMPAudioDecoder(GMPAudioDecoderParent** aGMPAD); void AudioDecoderDestroyed(GMPAudioDecoderParent* aDecoder); @@ -67,15 +62,12 @@ private: void ActorDestroy(ActorDestroyReason aWhy) override; - PGMPVideoDecoderParent* AllocPGMPVideoDecoderParent(const uint32_t& aDecryptorId) override; + PGMPVideoDecoderParent* AllocPGMPVideoDecoderParent() override; bool DeallocPGMPVideoDecoderParent(PGMPVideoDecoderParent* aActor) override; PGMPVideoEncoderParent* AllocPGMPVideoEncoderParent() override; bool DeallocPGMPVideoEncoderParent(PGMPVideoEncoderParent* aActor) override; - PGMPDecryptorParent* AllocPGMPDecryptorParent() override; - bool DeallocPGMPDecryptorParent(PGMPDecryptorParent* aActor) override; - PGMPAudioDecoderParent* AllocPGMPAudioDecoderParent() override; bool DeallocPGMPAudioDecoderParent(PGMPAudioDecoderParent* aActor) override; @@ -89,7 +81,6 @@ private: nsTArray<RefPtr<GMPVideoDecoderParent>> mVideoDecoders; nsTArray<RefPtr<GMPVideoEncoderParent>> mVideoEncoders; - nsTArray<RefPtr<GMPDecryptorParent>> mDecryptors; nsTArray<RefPtr<GMPAudioDecoderParent>> mAudioDecoders; nsCOMPtr<nsIThread> mGMPThread; RefPtr<GMPParent> mParent; diff --git a/dom/media/gmp/GMPDecryptorChild.cpp b/dom/media/gmp/GMPDecryptorChild.cpp deleted file mode 100644 index a1b561ab59..0000000000 --- a/dom/media/gmp/GMPDecryptorChild.cpp +++ /dev/null @@ -1,398 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "GMPDecryptorChild.h" -#include "GMPContentChild.h" -#include "GMPChild.h" -#include "base/task.h" -#include "mozilla/TimeStamp.h" -#include "mozilla/Unused.h" -#include "runnable_utils.h" -#include <ctime> - -#define ON_GMP_THREAD() (mPlugin->GMPMessageLoop() == MessageLoop::current()) - -#define CALL_ON_GMP_THREAD(_func, ...) \ - CallOnGMPThread(&GMPDecryptorChild::_func, __VA_ARGS__) - -namespace mozilla { -namespace gmp { - -GMPDecryptorChild::GMPDecryptorChild(GMPContentChild* aPlugin, - const nsTArray<uint8_t>& aPluginVoucher, - const nsTArray<uint8_t>& aSandboxVoucher) - : mSession(nullptr) - , mPlugin(aPlugin) - , mPluginVoucher(aPluginVoucher) - , mSandboxVoucher(aSandboxVoucher) -{ - MOZ_ASSERT(mPlugin); -} - -GMPDecryptorChild::~GMPDecryptorChild() -{ -} - -template <typename MethodType, typename... ParamType> -void -GMPDecryptorChild::CallMethod(MethodType aMethod, ParamType&&... aParams) -{ - MOZ_ASSERT(ON_GMP_THREAD()); - // Don't send IPC messages after tear-down. - if (mSession) { - (this->*aMethod)(Forward<ParamType>(aParams)...); - } -} - -template<typename T> -struct AddConstReference { - typedef const typename RemoveReference<T>::Type& Type; -}; - -template<typename MethodType, typename... ParamType> -void -GMPDecryptorChild::CallOnGMPThread(MethodType aMethod, ParamType&&... aParams) -{ - if (ON_GMP_THREAD()) { - // Use forwarding reference when we can. - CallMethod(aMethod, Forward<ParamType>(aParams)...); - } else { - // Use const reference when we have to. - auto m = &GMPDecryptorChild::CallMethod< - decltype(aMethod), typename AddConstReference<ParamType>::Type...>; - RefPtr<mozilla::Runnable> t = - dont_add_new_uses_of_this::NewRunnableMethod(this, m, aMethod, Forward<ParamType>(aParams)...); - mPlugin->GMPMessageLoop()->PostTask(t.forget()); - } -} - -void -GMPDecryptorChild::Init(GMPDecryptor* aSession) -{ - MOZ_ASSERT(aSession); - mSession = aSession; -} - -void -GMPDecryptorChild::SetSessionId(uint32_t aCreateSessionToken, - const char* aSessionId, - uint32_t aSessionIdLength) -{ - CALL_ON_GMP_THREAD(SendSetSessionId, - aCreateSessionToken, nsCString(aSessionId, aSessionIdLength)); -} - -void -GMPDecryptorChild::ResolveLoadSessionPromise(uint32_t aPromiseId, - bool aSuccess) -{ - CALL_ON_GMP_THREAD(SendResolveLoadSessionPromise, aPromiseId, aSuccess); -} - -void -GMPDecryptorChild::ResolvePromise(uint32_t aPromiseId) -{ - CALL_ON_GMP_THREAD(SendResolvePromise, aPromiseId); -} - -void -GMPDecryptorChild::RejectPromise(uint32_t aPromiseId, - GMPDOMException aException, - const char* aMessage, - uint32_t aMessageLength) -{ - CALL_ON_GMP_THREAD(SendRejectPromise, - aPromiseId, aException, nsCString(aMessage, aMessageLength)); -} - -void -GMPDecryptorChild::SessionMessage(const char* aSessionId, - uint32_t aSessionIdLength, - GMPSessionMessageType aMessageType, - const uint8_t* aMessage, - uint32_t aMessageLength) -{ - nsTArray<uint8_t> msg; - msg.AppendElements(aMessage, aMessageLength); - CALL_ON_GMP_THREAD(SendSessionMessage, - nsCString(aSessionId, aSessionIdLength), - aMessageType, Move(msg)); -} - -void -GMPDecryptorChild::ExpirationChange(const char* aSessionId, - uint32_t aSessionIdLength, - GMPTimestamp aExpiryTime) -{ - CALL_ON_GMP_THREAD(SendExpirationChange, - nsCString(aSessionId, aSessionIdLength), aExpiryTime); -} - -void -GMPDecryptorChild::SessionClosed(const char* aSessionId, - uint32_t aSessionIdLength) -{ - CALL_ON_GMP_THREAD(SendSessionClosed, - nsCString(aSessionId, aSessionIdLength)); -} - -void -GMPDecryptorChild::SessionError(const char* aSessionId, - uint32_t aSessionIdLength, - GMPDOMException aException, - uint32_t aSystemCode, - const char* aMessage, - uint32_t aMessageLength) -{ - CALL_ON_GMP_THREAD(SendSessionError, - nsCString(aSessionId, aSessionIdLength), - aException, aSystemCode, - nsCString(aMessage, aMessageLength)); -} - -void -GMPDecryptorChild::KeyStatusChanged(const char* aSessionId, - uint32_t aSessionIdLength, - const uint8_t* aKeyId, - uint32_t aKeyIdLength, - GMPMediaKeyStatus aStatus) -{ - AutoTArray<uint8_t, 16> kid; - kid.AppendElements(aKeyId, aKeyIdLength); - - nsTArray<GMPKeyInformation> keyInfos; - keyInfos.AppendElement(GMPKeyInformation(kid, aStatus)); - CALL_ON_GMP_THREAD(SendBatchedKeyStatusChanged, - nsCString(aSessionId, aSessionIdLength), - keyInfos); -} - -void -GMPDecryptorChild::BatchedKeyStatusChanged(const char* aSessionId, - uint32_t aSessionIdLength, - const GMPMediaKeyInfo* aKeyInfos, - uint32_t aKeyInfosLength) -{ - nsTArray<GMPKeyInformation> keyInfos; - for (uint32_t i = 0; i < aKeyInfosLength; i++) { - nsTArray<uint8_t> keyId; - keyId.AppendElements(aKeyInfos[i].keyid, aKeyInfos[i].keyid_size); - keyInfos.AppendElement(GMPKeyInformation(keyId, aKeyInfos[i].status)); - } - CALL_ON_GMP_THREAD(SendBatchedKeyStatusChanged, - nsCString(aSessionId, aSessionIdLength), - keyInfos); -} - -void -GMPDecryptorChild::Decrypted(GMPBuffer* aBuffer, GMPErr aResult) -{ - if (!ON_GMP_THREAD()) { - // We should run this whole method on the GMP thread since the buffer needs - // to be deleted after the SendDecrypted call. - mPlugin->GMPMessageLoop()->PostTask(NewRunnableMethod - <GMPBuffer*, GMPErr>(this, - &GMPDecryptorChild::Decrypted, - aBuffer, aResult)); - return; - } - - if (!aBuffer) { - NS_WARNING("GMPDecryptorCallback passed bull GMPBuffer"); - return; - } - - auto buffer = static_cast<GMPBufferImpl*>(aBuffer); - if (mSession) { - SendDecrypted(buffer->mId, aResult, buffer->mData); - } - delete buffer; -} - -void -GMPDecryptorChild::SetCapabilities(uint64_t aCaps) -{ - // Deprecated. -} - -void -GMPDecryptorChild::GetSandboxVoucher(const uint8_t** aVoucher, - uint32_t* aVoucherLength) -{ - if (!aVoucher || !aVoucherLength) { - return; - } - *aVoucher = mSandboxVoucher.Elements(); - *aVoucherLength = mSandboxVoucher.Length(); -} - -void -GMPDecryptorChild::GetPluginVoucher(const uint8_t** aVoucher, - uint32_t* aVoucherLength) -{ - if (!aVoucher || !aVoucherLength) { - return; - } - *aVoucher = mPluginVoucher.Elements(); - *aVoucherLength = mPluginVoucher.Length(); -} - -bool -GMPDecryptorChild::RecvInit(const bool& aDistinctiveIdentifierRequired, - const bool& aPersistentStateRequired) -{ - if (!mSession) { - return false; - } - mSession->Init(this, aDistinctiveIdentifierRequired, aPersistentStateRequired); - return true; -} - -bool -GMPDecryptorChild::RecvCreateSession(const uint32_t& aCreateSessionToken, - const uint32_t& aPromiseId, - const nsCString& aInitDataType, - InfallibleTArray<uint8_t>&& aInitData, - const GMPSessionType& aSessionType) -{ - if (!mSession) { - return false; - } - - mSession->CreateSession(aCreateSessionToken, - aPromiseId, - aInitDataType.get(), - aInitDataType.Length(), - aInitData.Elements(), - aInitData.Length(), - aSessionType); - - return true; -} - -bool -GMPDecryptorChild::RecvLoadSession(const uint32_t& aPromiseId, - const nsCString& aSessionId) -{ - if (!mSession) { - return false; - } - - mSession->LoadSession(aPromiseId, - aSessionId.get(), - aSessionId.Length()); - - return true; -} - -bool -GMPDecryptorChild::RecvUpdateSession(const uint32_t& aPromiseId, - const nsCString& aSessionId, - InfallibleTArray<uint8_t>&& aResponse) -{ - if (!mSession) { - return false; - } - - mSession->UpdateSession(aPromiseId, - aSessionId.get(), - aSessionId.Length(), - aResponse.Elements(), - aResponse.Length()); - - return true; -} - -bool -GMPDecryptorChild::RecvCloseSession(const uint32_t& aPromiseId, - const nsCString& aSessionId) -{ - if (!mSession) { - return false; - } - - mSession->CloseSession(aPromiseId, - aSessionId.get(), - aSessionId.Length()); - - return true; -} - -bool -GMPDecryptorChild::RecvRemoveSession(const uint32_t& aPromiseId, - const nsCString& aSessionId) -{ - if (!mSession) { - return false; - } - - mSession->RemoveSession(aPromiseId, - aSessionId.get(), - aSessionId.Length()); - - return true; -} - -bool -GMPDecryptorChild::RecvSetServerCertificate(const uint32_t& aPromiseId, - InfallibleTArray<uint8_t>&& aServerCert) -{ - if (!mSession) { - return false; - } - - mSession->SetServerCertificate(aPromiseId, - aServerCert.Elements(), - aServerCert.Length()); - - return true; -} - -bool -GMPDecryptorChild::RecvDecrypt(const uint32_t& aId, - InfallibleTArray<uint8_t>&& aBuffer, - const GMPDecryptionData& aMetadata) -{ - if (!mSession) { - return false; - } - - // Note: the GMPBufferImpl created here is deleted when the GMP passes - // it back in the Decrypted() callback above. - GMPBufferImpl* buffer = new GMPBufferImpl(aId, aBuffer); - - // |metadata| lifetime is managed by |buffer|. - GMPEncryptedBufferDataImpl* metadata = new GMPEncryptedBufferDataImpl(aMetadata); - buffer->SetMetadata(metadata); - - mSession->Decrypt(buffer, metadata); - return true; -} - -bool -GMPDecryptorChild::RecvDecryptingComplete() -{ - // Reset |mSession| before calling DecryptingComplete(). We should not send - // any IPC messages during tear-down. - auto session = mSession; - mSession = nullptr; - - if (!session) { - return false; - } - - session->DecryptingComplete(); - - Unused << Send__delete__(this); - - return true; -} - -} // namespace gmp -} // namespace mozilla - -// avoid redefined macro in unified build -#undef ON_GMP_THREAD -#undef CALL_ON_GMP_THREAD diff --git a/dom/media/gmp/GMPDecryptorChild.h b/dom/media/gmp/GMPDecryptorChild.h deleted file mode 100644 index 434da774fa..0000000000 --- a/dom/media/gmp/GMPDecryptorChild.h +++ /dev/null @@ -1,142 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef GMPDecryptorChild_h_ -#define GMPDecryptorChild_h_ - -#include "mozilla/gmp/PGMPDecryptorChild.h" -#include "gmp-decryption.h" -#include "mozilla/gmp/GMPTypes.h" -#include "GMPEncryptedBufferDataImpl.h" -#include <string> - -namespace mozilla { -namespace gmp { - -class GMPContentChild; - -class GMPDecryptorChild : public GMPDecryptorCallback - , public GMPDecryptorHost - , public PGMPDecryptorChild -{ -public: - NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPDecryptorChild); - - explicit GMPDecryptorChild(GMPContentChild* aPlugin, - const nsTArray<uint8_t>& aPluginVoucher, - const nsTArray<uint8_t>& aSandboxVoucher); - - void Init(GMPDecryptor* aSession); - - // GMPDecryptorCallback - void SetSessionId(uint32_t aCreateSessionToken, - const char* aSessionId, - uint32_t aSessionIdLength) override; - void ResolveLoadSessionPromise(uint32_t aPromiseId, - bool aSuccess) override; - void ResolvePromise(uint32_t aPromiseId) override; - - void RejectPromise(uint32_t aPromiseId, - GMPDOMException aException, - const char* aMessage, - uint32_t aMessageLength) override; - - void SessionMessage(const char* aSessionId, - uint32_t aSessionIdLength, - GMPSessionMessageType aMessageType, - const uint8_t* aMessage, - uint32_t aMessageLength) override; - - void ExpirationChange(const char* aSessionId, - uint32_t aSessionIdLength, - GMPTimestamp aExpiryTime) override; - - void SessionClosed(const char* aSessionId, - uint32_t aSessionIdLength) override; - - void SessionError(const char* aSessionId, - uint32_t aSessionIdLength, - GMPDOMException aException, - uint32_t aSystemCode, - const char* aMessage, - uint32_t aMessageLength) override; - - void KeyStatusChanged(const char* aSessionId, - uint32_t aSessionIdLength, - const uint8_t* aKeyId, - uint32_t aKeyIdLength, - GMPMediaKeyStatus aStatus) override; - - void SetCapabilities(uint64_t aCaps) override; - - void Decrypted(GMPBuffer* aBuffer, GMPErr aResult) override; - - void BatchedKeyStatusChanged(const char* aSessionId, - uint32_t aSessionIdLength, - const GMPMediaKeyInfo* aKeyInfos, - uint32_t aKeyInfosLength) override; - - // GMPDecryptorHost - void GetSandboxVoucher(const uint8_t** aVoucher, - uint32_t* aVoucherLength) override; - - void GetPluginVoucher(const uint8_t** aVoucher, - uint32_t* aVoucherLength) override; -private: - ~GMPDecryptorChild(); - - // GMPDecryptorChild - bool RecvInit(const bool& aDistinctiveIdentifierRequired, - const bool& aPersistentStateRequired) override; - - bool RecvCreateSession(const uint32_t& aCreateSessionToken, - const uint32_t& aPromiseId, - const nsCString& aInitDataType, - InfallibleTArray<uint8_t>&& aInitData, - const GMPSessionType& aSessionType) override; - - bool RecvLoadSession(const uint32_t& aPromiseId, - const nsCString& aSessionId) override; - - bool RecvUpdateSession(const uint32_t& aPromiseId, - const nsCString& aSessionId, - InfallibleTArray<uint8_t>&& aResponse) override; - - bool RecvCloseSession(const uint32_t& aPromiseId, - const nsCString& aSessionId) override; - - bool RecvRemoveSession(const uint32_t& aPromiseId, - const nsCString& aSessionId) override; - - bool RecvDecrypt(const uint32_t& aId, - InfallibleTArray<uint8_t>&& aBuffer, - const GMPDecryptionData& aMetadata) override; - - // Resolve/reject promise on completion. - bool RecvSetServerCertificate(const uint32_t& aPromiseId, - InfallibleTArray<uint8_t>&& aServerCert) override; - - bool RecvDecryptingComplete() override; - - template <typename MethodType, typename... ParamType> - void CallMethod(MethodType, ParamType&&...); - - template<typename MethodType, typename... ParamType> - void CallOnGMPThread(MethodType, ParamType&&...); - - // GMP's GMPDecryptor implementation. - // Only call into this on the (GMP process) main thread. - GMPDecryptor* mSession; - GMPContentChild* mPlugin; - - // Reference to the vouchers owned by the GMPChild. - const nsTArray<uint8_t>& mPluginVoucher; - const nsTArray<uint8_t>& mSandboxVoucher; -}; - -} // namespace gmp -} // namespace mozilla - -#endif // GMPDecryptorChild_h_ diff --git a/dom/media/gmp/GMPDecryptorParent.cpp b/dom/media/gmp/GMPDecryptorParent.cpp deleted file mode 100644 index c41d5d18f5..0000000000 --- a/dom/media/gmp/GMPDecryptorParent.cpp +++ /dev/null @@ -1,524 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "GMPDecryptorParent.h" - -#include "GMPContentParent.h" -#include "GMPUtils.h" -#include "MediaData.h" -#include "mozilla/Unused.h" - -namespace mozilla { - -#ifdef LOG -#undef LOG -#endif - -extern LogModule* GetGMPLog(); - -#define LOGV(msg) MOZ_LOG(GetGMPLog(), mozilla::LogLevel::Verbose, msg) -#define LOGD(msg) MOZ_LOG(GetGMPLog(), mozilla::LogLevel::Debug, msg) -#define LOG(level, msg) MOZ_LOG(GetGMPLog(), (level), msg) - -namespace gmp { - -GMPDecryptorParent::GMPDecryptorParent(GMPContentParent* aPlugin) - : mIsOpen(false) - , mShuttingDown(false) - , mActorDestroyed(false) - , mPlugin(aPlugin) - , mPluginId(aPlugin->GetPluginId()) - , mCallback(nullptr) -#ifdef DEBUG - , mGMPThread(aPlugin->GMPThread()) -#endif -{ - MOZ_ASSERT(mPlugin && mGMPThread); -} - -GMPDecryptorParent::~GMPDecryptorParent() -{ -} - -nsresult -GMPDecryptorParent::Init(GMPDecryptorProxyCallback* aCallback, - bool aDistinctiveIdentifierRequired, - bool aPersistentStateRequired) -{ - LOGD(("GMPDecryptorParent[%p]::Init()", this)); - - if (mIsOpen) { - NS_WARNING("Trying to re-use an in-use GMP decrypter!"); - return NS_ERROR_FAILURE; - } - mCallback = aCallback; - if (!SendInit(aDistinctiveIdentifierRequired, aPersistentStateRequired)) { - return NS_ERROR_FAILURE; - } - mIsOpen = true; - return NS_OK; -} - -void -GMPDecryptorParent::CreateSession(uint32_t aCreateSessionToken, - uint32_t aPromiseId, - const nsCString& aInitDataType, - const nsTArray<uint8_t>& aInitData, - GMPSessionType aSessionType) -{ - LOGD(("GMPDecryptorParent[%p]::CreateSession(token=%u, promiseId=%u, aInitData='%s')", - this, aCreateSessionToken, aPromiseId, ToBase64(aInitData).get())); - - if (!mIsOpen) { - NS_WARNING("Trying to use a dead GMP decrypter!"); - return; - } - // Caller should ensure parameters passed in from JS are valid. - MOZ_ASSERT(!aInitDataType.IsEmpty() && !aInitData.IsEmpty()); - Unused << SendCreateSession(aCreateSessionToken, aPromiseId, aInitDataType, aInitData, aSessionType); -} - -void -GMPDecryptorParent::LoadSession(uint32_t aPromiseId, - const nsCString& aSessionId) -{ - LOGD(("GMPDecryptorParent[%p]::LoadSession(sessionId='%s', promiseId=%u)", - this, aSessionId.get(), aPromiseId)); - if (!mIsOpen) { - NS_WARNING("Trying to use a dead GMP decrypter!"); - return; - } - // Caller should ensure parameters passed in from JS are valid. - MOZ_ASSERT(!aSessionId.IsEmpty()); - Unused << SendLoadSession(aPromiseId, aSessionId); -} - -void -GMPDecryptorParent::UpdateSession(uint32_t aPromiseId, - const nsCString& aSessionId, - const nsTArray<uint8_t>& aResponse) -{ - LOGD(("GMPDecryptorParent[%p]::UpdateSession(sessionId='%s', promiseId=%u response='%s')", - this, aSessionId.get(), aPromiseId, ToBase64(aResponse).get())); - - if (!mIsOpen) { - NS_WARNING("Trying to use a dead GMP decrypter!"); - return; - } - // Caller should ensure parameters passed in from JS are valid. - MOZ_ASSERT(!aSessionId.IsEmpty() && !aResponse.IsEmpty()); - Unused << SendUpdateSession(aPromiseId, aSessionId, aResponse); -} - -void -GMPDecryptorParent::CloseSession(uint32_t aPromiseId, - const nsCString& aSessionId) -{ - LOGD(("GMPDecryptorParent[%p]::CloseSession(sessionId='%s', promiseId=%u)", - this, aSessionId.get(), aPromiseId)); - - if (!mIsOpen) { - NS_WARNING("Trying to use a dead GMP decrypter!"); - return; - } - // Caller should ensure parameters passed in from JS are valid. - MOZ_ASSERT(!aSessionId.IsEmpty()); - Unused << SendCloseSession(aPromiseId, aSessionId); -} - -void -GMPDecryptorParent::RemoveSession(uint32_t aPromiseId, - const nsCString& aSessionId) -{ - LOGD(("GMPDecryptorParent[%p]::RemoveSession(sessionId='%s', promiseId=%u)", - this, aSessionId.get(), aPromiseId)); - - if (!mIsOpen) { - NS_WARNING("Trying to use a dead GMP decrypter!"); - return; - } - // Caller should ensure parameters passed in from JS are valid. - MOZ_ASSERT(!aSessionId.IsEmpty()); - Unused << SendRemoveSession(aPromiseId, aSessionId); -} - -void -GMPDecryptorParent::SetServerCertificate(uint32_t aPromiseId, - const nsTArray<uint8_t>& aServerCert) -{ - LOGD(("GMPDecryptorParent[%p]::SetServerCertificate(promiseId=%u)", - this, aPromiseId)); - - if (!mIsOpen) { - NS_WARNING("Trying to use a dead GMP decrypter!"); - return; - } - // Caller should ensure parameters passed in from JS are valid. - MOZ_ASSERT(!aServerCert.IsEmpty()); - Unused << SendSetServerCertificate(aPromiseId, aServerCert); -} - -void -GMPDecryptorParent::Decrypt(uint32_t aId, - const CryptoSample& aCrypto, - const nsTArray<uint8_t>& aBuffer) -{ - LOGV(("GMPDecryptorParent[%p]::Decrypt(id=%d)", this, aId)); - - if (!mIsOpen) { - NS_WARNING("Trying to use a dead GMP decrypter!"); - return; - } - - // Caller should ensure parameters passed in are valid. - MOZ_ASSERT(!aBuffer.IsEmpty()); - - if (aCrypto.mValid) { - GMPDecryptionData data(aCrypto.mKeyId, - aCrypto.mIV, - aCrypto.mPlainSizes, - aCrypto.mEncryptedSizes, - aCrypto.mSessionIds); - - Unused << SendDecrypt(aId, aBuffer, data); - } else { - GMPDecryptionData data; - Unused << SendDecrypt(aId, aBuffer, data); - } -} - -bool -GMPDecryptorParent::RecvSetSessionId(const uint32_t& aCreateSessionId, - const nsCString& aSessionId) -{ -#ifdef MOZ_EME - LOGD(("GMPDecryptorParent[%p]::RecvSetSessionId(token=%u, sessionId='%s')", - this, aCreateSessionId, aSessionId.get())); - - if (!mIsOpen) { - NS_WARNING("Trying to use a dead GMP decrypter!"); - return false; - } - mCallback->SetSessionId(aCreateSessionId, aSessionId); -#endif - return true; -} - -bool -GMPDecryptorParent::RecvResolveLoadSessionPromise(const uint32_t& aPromiseId, - const bool& aSuccess) -{ -#ifdef MOZ_EME - LOGD(("GMPDecryptorParent[%p]::RecvResolveLoadSessionPromise(promiseId=%u)", - this, aPromiseId)); - - if (!mIsOpen) { - NS_WARNING("Trying to use a dead GMP decrypter!"); - return false; - } - mCallback->ResolveLoadSessionPromise(aPromiseId, aSuccess); -#endif - return true; -} - -bool -GMPDecryptorParent::RecvResolvePromise(const uint32_t& aPromiseId) -{ -#ifdef MOZ_EME - LOGD(("GMPDecryptorParent[%p]::RecvResolvePromise(promiseId=%u)", - this, aPromiseId)); - - if (!mIsOpen) { - NS_WARNING("Trying to use a dead GMP decrypter!"); - return false; - } - mCallback->ResolvePromise(aPromiseId); -#endif - return true; -} - -nsresult -GMPExToNsresult(GMPDOMException aDomException) { - switch (aDomException) { - case kGMPNoModificationAllowedError: return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR; - case kGMPNotFoundError: return NS_ERROR_DOM_NOT_FOUND_ERR; - case kGMPNotSupportedError: return NS_ERROR_DOM_NOT_SUPPORTED_ERR; - case kGMPInvalidStateError: return NS_ERROR_DOM_INVALID_STATE_ERR; - case kGMPSyntaxError: return NS_ERROR_DOM_SYNTAX_ERR; - case kGMPInvalidModificationError: return NS_ERROR_DOM_INVALID_MODIFICATION_ERR; - case kGMPInvalidAccessError: return NS_ERROR_DOM_INVALID_ACCESS_ERR; - case kGMPSecurityError: return NS_ERROR_DOM_SECURITY_ERR; - case kGMPAbortError: return NS_ERROR_DOM_ABORT_ERR; - case kGMPQuotaExceededError: return NS_ERROR_DOM_QUOTA_EXCEEDED_ERR; - case kGMPTimeoutError: return NS_ERROR_DOM_TIMEOUT_ERR; - case kGMPTypeError: return NS_ERROR_DOM_TYPE_ERR; - default: return NS_ERROR_DOM_UNKNOWN_ERR; - } -} - -bool -GMPDecryptorParent::RecvRejectPromise(const uint32_t& aPromiseId, - const GMPDOMException& aException, - const nsCString& aMessage) -{ -#ifdef MOZ_EME - LOGD(("GMPDecryptorParent[%p]::RecvRejectPromise(promiseId=%u, exception=%d, msg='%s')", - this, aPromiseId, aException, aMessage.get())); - - if (!mIsOpen) { - NS_WARNING("Trying to use a dead GMP decrypter!"); - return false; - } - mCallback->RejectPromise(aPromiseId, GMPExToNsresult(aException), aMessage); -#endif - return true; -} - -#ifdef MOZ_EME -static dom::MediaKeyMessageType -ToMediaKeyMessageType(GMPSessionMessageType aMessageType) { - switch (aMessageType) { - case kGMPLicenseRequest: return dom::MediaKeyMessageType::License_request; - case kGMPLicenseRenewal: return dom::MediaKeyMessageType::License_renewal; - case kGMPLicenseRelease: return dom::MediaKeyMessageType::License_release; - case kGMPIndividualizationRequest: return dom::MediaKeyMessageType::Individualization_request; - default: return dom::MediaKeyMessageType::License_request; - }; -}; -#endif - -bool -GMPDecryptorParent::RecvSessionMessage(const nsCString& aSessionId, - const GMPSessionMessageType& aMessageType, - nsTArray<uint8_t>&& aMessage) -{ -#ifdef MOZ_EME - LOGD(("GMPDecryptorParent[%p]::RecvSessionMessage(sessionId='%s', type=%d, msg='%s')", - this, aSessionId.get(), aMessageType, ToBase64(aMessage).get())); - - if (!mIsOpen) { - NS_WARNING("Trying to use a dead GMP decrypter!"); - return false; - } - mCallback->SessionMessage(aSessionId, ToMediaKeyMessageType(aMessageType), aMessage); -#endif - return true; -} - -bool -GMPDecryptorParent::RecvExpirationChange(const nsCString& aSessionId, - const double& aExpiryTime) -{ -#ifdef MOZ_EME - LOGD(("GMPDecryptorParent[%p]::RecvExpirationChange(sessionId='%s', expiry=%lf)", - this, aSessionId.get(), aExpiryTime)); - - if (!mIsOpen) { - NS_WARNING("Trying to use a dead GMP decrypter!"); - return false; - } - mCallback->ExpirationChange(aSessionId, aExpiryTime); -#endif - return true; -} - -bool -GMPDecryptorParent::RecvSessionClosed(const nsCString& aSessionId) -{ -#ifdef MOZ_EME - LOGD(("GMPDecryptorParent[%p]::RecvSessionClosed(sessionId='%s')", - this, aSessionId.get())); - - if (!mIsOpen) { - NS_WARNING("Trying to use a dead GMP decrypter!"); - return false; - } - mCallback->SessionClosed(aSessionId); -#endif - return true; -} - -bool -GMPDecryptorParent::RecvSessionError(const nsCString& aSessionId, - const GMPDOMException& aException, - const uint32_t& aSystemCode, - const nsCString& aMessage) -{ -#ifdef MOZ_EME - LOGD(("GMPDecryptorParent[%p]::RecvSessionError(sessionId='%s', exception=%d, sysCode=%d, msg='%s')", - this, aSessionId.get(), - aException, aSystemCode, aMessage.get())); - - if (!mIsOpen) { - NS_WARNING("Trying to use a dead GMP decrypter!"); - return false; - } - mCallback->SessionError(aSessionId, - GMPExToNsresult(aException), - aSystemCode, - aMessage); -#endif - return true; -} - -#ifdef MOZ_EME -static dom::MediaKeyStatus -ToMediaKeyStatus(GMPMediaKeyStatus aStatus) { - switch (aStatus) { - case kGMPUsable: return dom::MediaKeyStatus::Usable; - case kGMPExpired: return dom::MediaKeyStatus::Expired; - case kGMPOutputDownscaled: return dom::MediaKeyStatus::Output_downscaled; - case kGMPOutputRestricted: return dom::MediaKeyStatus::Output_restricted; - case kGMPInternalError: return dom::MediaKeyStatus::Internal_error; - case kGMPReleased: return dom::MediaKeyStatus::Released; - case kGMPStatusPending: return dom::MediaKeyStatus::Status_pending; - default: return dom::MediaKeyStatus::Internal_error; - } -} -#endif - -bool -GMPDecryptorParent::RecvBatchedKeyStatusChanged(const nsCString& aSessionId, - InfallibleTArray<GMPKeyInformation>&& aKeyInfos) -{ -#ifdef MOZ_EME - LOGD(("GMPDecryptorParent[%p]::RecvBatchedKeyStatusChanged(sessionId='%s', KeyInfos len='%d')", - this, aSessionId.get(), aKeyInfos.Length())); - - if (mIsOpen) { - nsTArray<CDMKeyInfo> cdmKeyInfos(aKeyInfos.Length()); - for (uint32_t i = 0; i < aKeyInfos.Length(); i++) { - LOGD(("GMPDecryptorParent[%p]::RecvBatchedKeyStatusChanged(keyId=%s, gmp-status=%d)", - this, ToBase64(aKeyInfos[i].keyId()).get(), aKeyInfos[i].status())); - // If the status is kGMPUnknown, we're going to forget(remove) that key info. - if (aKeyInfos[i].status() != kGMPUnknown) { - auto status = ToMediaKeyStatus(aKeyInfos[i].status()); - cdmKeyInfos.AppendElement(CDMKeyInfo(aKeyInfos[i].keyId(), - dom::Optional<dom::MediaKeyStatus>(status))); - } else { - cdmKeyInfos.AppendElement(CDMKeyInfo(aKeyInfos[i].keyId())); - } - } - mCallback->BatchedKeyStatusChanged(aSessionId, cdmKeyInfos); - } -#endif - return true; -} - -#ifdef MOZ_EME -DecryptStatus -ToDecryptStatus(GMPErr aError) -{ - switch (aError) { - case GMPNoErr: return Ok; - case GMPNoKeyErr: return NoKeyErr; - case GMPAbortedErr: return AbortedErr; - default: return GenericErr; - } -} -#endif - -bool -GMPDecryptorParent::RecvDecrypted(const uint32_t& aId, - const GMPErr& aErr, - InfallibleTArray<uint8_t>&& aBuffer) -{ -#ifdef MOZ_EME - LOGV(("GMPDecryptorParent[%p]::RecvDecrypted(id=%d, err=%d)", - this, aId, aErr)); - - if (!mIsOpen) { - NS_WARNING("Trying to use a dead GMP decrypter!"); - return false; - } - mCallback->Decrypted(aId, ToDecryptStatus(aErr), aBuffer); -#endif - return true; -} - -bool -GMPDecryptorParent::RecvShutdown() -{ - LOGD(("GMPDecryptorParent[%p]::RecvShutdown()", this)); - - Shutdown(); - return true; -} - -// Note: may be called via Terminated() -void -GMPDecryptorParent::Close() -{ - LOGD(("GMPDecryptorParent[%p]::Close()", this)); - MOZ_ASSERT(mGMPThread == NS_GetCurrentThread()); - - // Consumer is done with us; we can shut down. No more callbacks should - // be made to mCallback. Note: do this before Shutdown()! - mCallback = nullptr; - // Let Shutdown mark us as dead so it knows if we had been alive - - // In case this is the last reference - RefPtr<GMPDecryptorParent> kungfudeathgrip(this); - this->Release(); - Shutdown(); -} - -void -GMPDecryptorParent::Shutdown() -{ - LOGD(("GMPDecryptorParent[%p]::Shutdown()", this)); - MOZ_ASSERT(mGMPThread == NS_GetCurrentThread()); - - if (mShuttingDown) { - return; - } - mShuttingDown = true; - - // Notify client we're gone! Won't occur after Close() - if (mCallback) { - mCallback->Terminated(); - mCallback = nullptr; - } - - mIsOpen = false; - if (!mActorDestroyed) { - Unused << SendDecryptingComplete(); - } -} - -// Note: Keep this sync'd up with Shutdown -void -GMPDecryptorParent::ActorDestroy(ActorDestroyReason aWhy) -{ - LOGD(("GMPDecryptorParent[%p]::ActorDestroy(reason=%d)", this, aWhy)); - - mIsOpen = false; - mActorDestroyed = true; - if (mCallback) { - // May call Close() (and Shutdown()) immediately or with a delay - mCallback->Terminated(); - mCallback = nullptr; - } - if (mPlugin) { - mPlugin->DecryptorDestroyed(this); - mPlugin = nullptr; - } - MaybeDisconnect(aWhy == AbnormalShutdown); -} - -bool -GMPDecryptorParent::Recv__delete__() -{ - LOGD(("GMPDecryptorParent[%p]::Recv__delete__()", this)); - - if (mPlugin) { - mPlugin->DecryptorDestroyed(this); - mPlugin = nullptr; - } - return true; -} - -} // namespace gmp -} // namespace mozilla diff --git a/dom/media/gmp/GMPDecryptorParent.h b/dom/media/gmp/GMPDecryptorParent.h deleted file mode 100644 index 3acf7dbd96..0000000000 --- a/dom/media/gmp/GMPDecryptorParent.h +++ /dev/null @@ -1,127 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef GMPDecryptorParent_h_ -#define GMPDecryptorParent_h_ - -#include "mozilla/gmp/PGMPDecryptorParent.h" -#include "mozilla/RefPtr.h" -#include "gmp-decryption.h" -#include "GMPDecryptorProxy.h" -#include "GMPCrashHelperHolder.h" - -namespace mozilla { - -class CryptoSample; - -namespace gmp { - -class GMPContentParent; - -class GMPDecryptorParent final : public GMPDecryptorProxy - , public PGMPDecryptorParent - , public GMPCrashHelperHolder -{ -public: - NS_INLINE_DECL_REFCOUNTING(GMPDecryptorParent) - - explicit GMPDecryptorParent(GMPContentParent *aPlugin); - - // GMPDecryptorProxy - - uint32_t GetPluginId() const override { return mPluginId; } - - nsresult Init(GMPDecryptorProxyCallback* aCallback, - bool aDistinctiveIdentifierRequired, - bool aPersistentStateRequired) override; - - void CreateSession(uint32_t aCreateSessionToken, - uint32_t aPromiseId, - const nsCString& aInitDataType, - const nsTArray<uint8_t>& aInitData, - GMPSessionType aSessionType) override; - - void LoadSession(uint32_t aPromiseId, - const nsCString& aSessionId) override; - - void UpdateSession(uint32_t aPromiseId, - const nsCString& aSessionId, - const nsTArray<uint8_t>& aResponse) override; - - void CloseSession(uint32_t aPromiseId, - const nsCString& aSessionId) override; - - void RemoveSession(uint32_t aPromiseId, - const nsCString& aSessionId) override; - - void SetServerCertificate(uint32_t aPromiseId, - const nsTArray<uint8_t>& aServerCert) override; - - void Decrypt(uint32_t aId, - const CryptoSample& aCrypto, - const nsTArray<uint8_t>& aBuffer) override; - - void Close() override; - - void Shutdown(); - -private: - ~GMPDecryptorParent(); - - // PGMPDecryptorParent - - bool RecvSetSessionId(const uint32_t& aCreateSessionToken, - const nsCString& aSessionId) override; - - bool RecvResolveLoadSessionPromise(const uint32_t& aPromiseId, - const bool& aSuccess) override; - - bool RecvResolvePromise(const uint32_t& aPromiseId) override; - - bool RecvRejectPromise(const uint32_t& aPromiseId, - const GMPDOMException& aException, - const nsCString& aMessage) override; - - bool RecvSessionMessage(const nsCString& aSessionId, - const GMPSessionMessageType& aMessageType, - nsTArray<uint8_t>&& aMessage) override; - - bool RecvExpirationChange(const nsCString& aSessionId, - const double& aExpiryTime) override; - - bool RecvSessionClosed(const nsCString& aSessionId) override; - - bool RecvSessionError(const nsCString& aSessionId, - const GMPDOMException& aException, - const uint32_t& aSystemCode, - const nsCString& aMessage) override; - - bool RecvDecrypted(const uint32_t& aId, - const GMPErr& aErr, - InfallibleTArray<uint8_t>&& aBuffer) override; - - bool RecvBatchedKeyStatusChanged(const nsCString& aSessionId, - InfallibleTArray<GMPKeyInformation>&& aKeyInfos) override; - - bool RecvShutdown() override; - - void ActorDestroy(ActorDestroyReason aWhy) override; - bool Recv__delete__() override; - - bool mIsOpen; - bool mShuttingDown; - bool mActorDestroyed; - RefPtr<GMPContentParent> mPlugin; - uint32_t mPluginId; - GMPDecryptorProxyCallback* mCallback; -#ifdef DEBUG - nsIThread* const mGMPThread; -#endif -}; - -} // namespace gmp -} // namespace mozilla - -#endif // GMPDecryptorChild_h_ diff --git a/dom/media/gmp/GMPDecryptorProxy.h b/dom/media/gmp/GMPDecryptorProxy.h deleted file mode 100644 index f9e34a45fd..0000000000 --- a/dom/media/gmp/GMPDecryptorProxy.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef GMPDecryptorProxy_h_ -#define GMPDecryptorProxy_h_ - -#include "GMPCallbackBase.h" -#include "gmp-decryption.h" -#include "nsString.h" - -namespace mozilla { -class CryptoSample; -} // namespace mozilla - -class GMPDecryptorProxyCallback : public GMPCallbackBase { - -public: - virtual ~GMPDecryptorProxyCallback() {} -}; - -class GMPDecryptorProxy { -public: - ~GMPDecryptorProxy() {} - - virtual uint32_t GetPluginId() const = 0; - - virtual nsresult Init(GMPDecryptorProxyCallback* aCallback, - bool aDistinctiveIdentifierRequired, - bool aPersistentStateRequired) = 0; - - virtual void CreateSession(uint32_t aCreateSessionToken, - uint32_t aPromiseId, - const nsCString& aInitDataType, - const nsTArray<uint8_t>& aInitData, - GMPSessionType aSessionType) = 0; - - virtual void LoadSession(uint32_t aPromiseId, - const nsCString& aSessionId) = 0; - - virtual void UpdateSession(uint32_t aPromiseId, - const nsCString& aSessionId, - const nsTArray<uint8_t>& aResponse) = 0; - - virtual void CloseSession(uint32_t aPromiseId, - const nsCString& aSessionId) = 0; - - virtual void RemoveSession(uint32_t aPromiseId, - const nsCString& aSessionId) = 0; - - virtual void SetServerCertificate(uint32_t aPromiseId, - const nsTArray<uint8_t>& aServerCert) = 0; - - virtual void Decrypt(uint32_t aId, - const mozilla::CryptoSample& aCrypto, - const nsTArray<uint8_t>& aBuffer) = 0; - - virtual void Close() = 0; -}; - -#endif // GMPDecryptorProxy_h_ diff --git a/dom/media/gmp/GMPLoader.cpp b/dom/media/gmp/GMPLoader.cpp index f0437494fa..c84d71788f 100644 --- a/dom/media/gmp/GMPLoader.cpp +++ b/dom/media/gmp/GMPLoader.cpp @@ -38,8 +38,7 @@ public: GMPErr GetAPI(const char* aAPIName, void* aHostAPI, - void** aPluginAPI, - uint32_t aDecryptorId) override; + void** aPluginAPI) override; void Shutdown() override; @@ -78,8 +77,7 @@ public: GMPErr GMPGetAPI(const char* aAPIName, void* aHostAPI, - void** aPluginAPI, - uint32_t aDecryptorId) override + void** aPluginAPI) override { if (!mLib) { return GMPGenericErr; @@ -189,10 +187,9 @@ GMPLoaderImpl::Load(const char* aUTF8LibPath, GMPErr GMPLoaderImpl::GetAPI(const char* aAPIName, void* aHostAPI, - void** aPluginAPI, - uint32_t aDecryptorId) + void** aPluginAPI) { - return mAdapter->GMPGetAPI(aAPIName, aHostAPI, aPluginAPI, aDecryptorId); + return mAdapter->GMPGetAPI(aAPIName, aHostAPI, aPluginAPI); } void diff --git a/dom/media/gmp/GMPLoader.h b/dom/media/gmp/GMPLoader.h index 5b6030ad7c..91989f9c24 100644 --- a/dom/media/gmp/GMPLoader.h +++ b/dom/media/gmp/GMPLoader.h @@ -33,8 +33,7 @@ public: virtual GMPErr GMPInit(const GMPPlatformAPI* aPlatformAPI) = 0; virtual GMPErr GMPGetAPI(const char* aAPIName, void* aHostAPI, - void** aPluginAPI, - uint32_t aDecryptorId) = 0; + void** aPluginAPI) = 0; virtual void GMPShutdown() = 0; virtual void GMPSetNodeId(const char* aNodeId, uint32_t aLength) = 0; }; @@ -77,8 +76,7 @@ public: // Retrieves an interface pointer from the GMP. virtual GMPErr GetAPI(const char* aAPIName, void* aHostAPI, - void** aPluginAPI, - uint32_t aDecryptorId) = 0; + void** aPluginAPI) = 0; // Calls the GMPShutdown function exported by the GMP lib, and unloads the // plugin library. diff --git a/dom/media/gmp/GMPParent.h b/dom/media/gmp/GMPParent.h index dacd6feeba..39933765bc 100644 --- a/dom/media/gmp/GMPParent.h +++ b/dom/media/gmp/GMPParent.h @@ -9,7 +9,6 @@ #include "GMPProcessParent.h" #include "GMPServiceParent.h" #include "GMPAudioDecoderParent.h" -#include "GMPDecryptorParent.h" #include "GMPVideoDecoderParent.h" #include "GMPVideoEncoderParent.h" #include "GMPTimerParent.h" diff --git a/dom/media/gmp/GMPService.cpp b/dom/media/gmp/GMPService.cpp index 1901210da1..fc3422f1f0 100644 --- a/dom/media/gmp/GMPService.cpp +++ b/dom/media/gmp/GMPService.cpp @@ -20,7 +20,6 @@ #include "nsNativeCharsetUtils.h" #include "nsIConsoleService.h" #include "mozilla/Unused.h" -#include "GMPDecryptorParent.h" #include "GMPAudioDecoderParent.h" #include "nsComponentManagerUtils.h" #include "runnable_utils.h" @@ -346,11 +345,9 @@ class GetGMPContentParentForVideoDecoderDone : public GetGMPContentParentCallbac { public: explicit GetGMPContentParentForVideoDecoderDone(UniquePtr<GetGMPVideoDecoderCallback>&& aCallback, - GMPCrashHelper* aHelper, - uint32_t aDecryptorId) + GMPCrashHelper* aHelper) : mCallback(Move(aCallback)) , mHelper(aHelper) - , mDecryptorId(aDecryptorId) { } @@ -358,7 +355,7 @@ public: { GMPVideoDecoderParent* gmpVDP = nullptr; GMPVideoHostImpl* videoHost = nullptr; - if (aGMPParent && NS_SUCCEEDED(aGMPParent->GetGMPVideoDecoder(&gmpVDP, mDecryptorId))) { + if (aGMPParent && NS_SUCCEEDED(aGMPParent->GetGMPVideoDecoder(&gmpVDP))) { videoHost = &gmpVDP->Host(); gmpVDP->SetCrashHelper(mHelper); } @@ -368,15 +365,13 @@ public: private: UniquePtr<GetGMPVideoDecoderCallback> mCallback; RefPtr<GMPCrashHelper> mHelper; - const uint32_t mDecryptorId; }; NS_IMETHODIMP -GeckoMediaPluginService::GetDecryptingGMPVideoDecoder(GMPCrashHelper* aHelper, - nsTArray<nsCString>* aTags, - const nsACString& aNodeId, - UniquePtr<GetGMPVideoDecoderCallback>&& aCallback, - uint32_t aDecryptorId) +GeckoMediaPluginService::GetGMPVideoDecoder(GMPCrashHelper* aHelper, + nsTArray<nsCString>* aTags, + const nsACString& aNodeId, + UniquePtr<GetGMPVideoDecoderCallback>&& aCallback) { MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread); NS_ENSURE_ARG(aTags && aTags->Length() > 0); @@ -387,7 +382,7 @@ GeckoMediaPluginService::GetDecryptingGMPVideoDecoder(GMPCrashHelper* aHelper, } UniquePtr<GetGMPContentParentCallback> callback( - new GetGMPContentParentForVideoDecoderDone(Move(aCallback), aHelper, aDecryptorId)); + new GetGMPContentParentForVideoDecoderDone(Move(aCallback), aHelper)); if (!GetContentParentFrom(aHelper, aNodeId, NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER), @@ -452,57 +447,6 @@ GeckoMediaPluginService::GetGMPVideoEncoder(GMPCrashHelper* aHelper, return NS_OK; } -class GetGMPContentParentForDecryptorDone : public GetGMPContentParentCallback -{ -public: - explicit GetGMPContentParentForDecryptorDone(UniquePtr<GetGMPDecryptorCallback>&& aCallback, - GMPCrashHelper* aHelper) - : mCallback(Move(aCallback)) - , mHelper(aHelper) - { - } - - void Done(GMPContentParent* aGMPParent) override - { - GMPDecryptorParent* ksp = nullptr; - if (aGMPParent && NS_SUCCEEDED(aGMPParent->GetGMPDecryptor(&ksp))) { - ksp->SetCrashHelper(mHelper); - } - mCallback->Done(ksp); - } - -private: - UniquePtr<GetGMPDecryptorCallback> mCallback; - RefPtr<GMPCrashHelper> mHelper; -}; - -NS_IMETHODIMP -GeckoMediaPluginService::GetGMPDecryptor(GMPCrashHelper* aHelper, - nsTArray<nsCString>* aTags, - const nsACString& aNodeId, - UniquePtr<GetGMPDecryptorCallback>&& aCallback) -{ - MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread); - NS_ENSURE_ARG(aTags && aTags->Length() > 0); - NS_ENSURE_ARG(aCallback); - - if (mShuttingDownOnGMPThread) { - return NS_ERROR_FAILURE; - } - - UniquePtr<GetGMPContentParentCallback> callback( - new GetGMPContentParentForDecryptorDone(Move(aCallback), aHelper)); - if (!GetContentParentFrom(aHelper, - aNodeId, - NS_LITERAL_CSTRING(GMP_API_DECRYPTOR), - *aTags, - Move(callback))) { - return NS_ERROR_FAILURE; - } - - return NS_OK; -} - void GeckoMediaPluginService::ConnectCrashHelper(uint32_t aPluginId, GMPCrashHelper* aHelper) { diff --git a/dom/media/gmp/GMPService.h b/dom/media/gmp/GMPService.h index 7ed318a25f..42ec099ef1 100644 --- a/dom/media/gmp/GMPService.h +++ b/dom/media/gmp/GMPService.h @@ -69,37 +69,18 @@ public: // mozIGeckoMediaPluginService NS_IMETHOD GetThread(nsIThread** aThread) override; - NS_IMETHOD GetDecryptingGMPVideoDecoder(GMPCrashHelper* aHelper, - nsTArray<nsCString>* aTags, - const nsACString& aNodeId, - UniquePtr<GetGMPVideoDecoderCallback>&& aCallback, - uint32_t aDecryptorId) - override; + NS_IMETHOD GetGMPVideoDecoder(GMPCrashHelper* aHelper, + nsTArray<nsCString>* aTags, + const nsACString& aNodeId, + UniquePtr<GetGMPVideoDecoderCallback>&& aCallback) override; NS_IMETHOD GetGMPVideoEncoder(GMPCrashHelper* aHelper, nsTArray<nsCString>* aTags, const nsACString& aNodeId, - UniquePtr<GetGMPVideoEncoderCallback>&& aCallback) - override; + UniquePtr<GetGMPVideoEncoderCallback>&& aCallback) override; NS_IMETHOD GetGMPAudioDecoder(GMPCrashHelper* aHelper, nsTArray<nsCString>* aTags, const nsACString& aNodeId, - UniquePtr<GetGMPAudioDecoderCallback>&& aCallback) - override; - NS_IMETHOD GetGMPDecryptor(GMPCrashHelper* aHelper, - nsTArray<nsCString>* aTags, - const nsACString& aNodeId, - UniquePtr<GetGMPDecryptorCallback>&& aCallback) - override; - - // Helper for backwards compatibility with WebRTC/tests. - NS_IMETHOD - GetGMPVideoDecoder(GMPCrashHelper* aHelper, - nsTArray<nsCString>* aTags, - const nsACString& aNodeId, - UniquePtr<GetGMPVideoDecoderCallback>&& aCallback) override - { - return GetDecryptingGMPVideoDecoder(aHelper, aTags, aNodeId, Move(aCallback), 0); - } + UniquePtr<GetGMPAudioDecoderCallback>&& aCallback) override; int32_t AsyncShutdownTimeoutMs(); diff --git a/dom/media/gmp/GMPServiceParent.cpp b/dom/media/gmp/GMPServiceParent.cpp index a4afbdad44..07079536fd 100644 --- a/dom/media/gmp/GMPServiceParent.cpp +++ b/dom/media/gmp/GMPServiceParent.cpp @@ -22,7 +22,6 @@ #include "nsNativeCharsetUtils.h" #include "nsIConsoleService.h" #include "mozilla/Unused.h" -#include "GMPDecryptorParent.h" #include "GMPAudioDecoderParent.h" #include "nsComponentManagerUtils.h" #include "runnable_utils.h" diff --git a/dom/media/gmp/PGMPContent.ipdl b/dom/media/gmp/PGMPContent.ipdl index 00e16c02ff..b1ca2491b0 100644 --- a/dom/media/gmp/PGMPContent.ipdl +++ b/dom/media/gmp/PGMPContent.ipdl @@ -7,7 +7,6 @@ include protocol PGMP; include protocol PGMPService; include protocol PGMPVideoDecoder; include protocol PGMPVideoEncoder; -include protocol PGMPDecryptor; include protocol PGMPAudioDecoder; namespace mozilla { @@ -18,14 +17,12 @@ intr protocol PGMPContent bridges PGMPService, PGMP; manages PGMPAudioDecoder; - manages PGMPDecryptor; manages PGMPVideoDecoder; manages PGMPVideoEncoder; child: async PGMPAudioDecoder(); - async PGMPDecryptor(); - async PGMPVideoDecoder(uint32_t aDecryptorId); + async PGMPVideoDecoder(); async PGMPVideoEncoder(); }; diff --git a/dom/media/gmp/PGMPDecryptor.ipdl b/dom/media/gmp/PGMPDecryptor.ipdl deleted file mode 100644 index 207933e8a6..0000000000 --- a/dom/media/gmp/PGMPDecryptor.ipdl +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -include protocol PGMPContent; -include GMPTypes; - -using GMPSessionMessageType from "gmp-decryption.h"; -using GMPSessionType from "gmp-decryption.h"; -using GMPDOMException from "gmp-decryption.h"; -using GMPErr from "gmp-errors.h"; - -namespace mozilla { -namespace gmp { - -async protocol PGMPDecryptor -{ - manager PGMPContent; -child: - - async Init(bool aDistinctiveIdentifierRequired, - bool aPersistentStateRequired); - - async CreateSession(uint32_t aCreateSessionToken, - uint32_t aPromiseId, - nsCString aInitDataType, - uint8_t[] aInitData, - GMPSessionType aSessionType); - - async LoadSession(uint32_t aPromiseId, - nsCString aSessionId); - - async UpdateSession(uint32_t aPromiseId, - nsCString aSessionId, - uint8_t[] aResponse); - - async CloseSession(uint32_t aPromiseId, - nsCString aSessionId); - - async RemoveSession(uint32_t aPromiseId, - nsCString aSessionId); - - async SetServerCertificate(uint32_t aPromiseId, - uint8_t[] aServerCert); - - async Decrypt(uint32_t aId, - uint8_t[] aBuffer, - GMPDecryptionData aMetadata); - - async DecryptingComplete(); - -parent: - async __delete__(); - - async SetSessionId(uint32_t aCreateSessionToken, - nsCString aSessionId); - - async ResolveLoadSessionPromise(uint32_t aPromiseId, - bool aSuccess); - - async ResolvePromise(uint32_t aPromiseId); - - async RejectPromise(uint32_t aPromiseId, - GMPDOMException aDOMExceptionCode, - nsCString aMessage); - - async SessionMessage(nsCString aSessionId, - GMPSessionMessageType aMessageType, - uint8_t[] aMessage); - - async ExpirationChange(nsCString aSessionId, double aExpiryTime); - - async SessionClosed(nsCString aSessionId); - - async SessionError(nsCString aSessionId, - GMPDOMException aDOMExceptionCode, - uint32_t aSystemCode, - nsCString aMessage); - - async Decrypted(uint32_t aId, GMPErr aResult, uint8_t[] aBuffer); - - async Shutdown(); - - async BatchedKeyStatusChanged(nsCString aSessionId, - GMPKeyInformation[] aKeyInfos); -}; - -} // namespace gmp -} // namespace mozilla diff --git a/dom/media/gmp/moz.build b/dom/media/gmp/moz.build index 82d091168d..697edd7037 100644 --- a/dom/media/gmp/moz.build +++ b/dom/media/gmp/moz.build @@ -38,9 +38,6 @@ EXPORTS += [ 'GMPContentChild.h', 'GMPContentParent.h', 'GMPCrashHelperHolder.h', - 'GMPDecryptorChild.h', - 'GMPDecryptorParent.h', - 'GMPDecryptorProxy.h', 'GMPEncryptedBufferDataImpl.h', 'GMPLoader.h', 'GMPMessageUtils.h', @@ -77,8 +74,6 @@ UNIFIED_SOURCES += [ 'GMPChild.cpp', 'GMPContentChild.cpp', 'GMPContentParent.cpp', - 'GMPDecryptorChild.cpp', - 'GMPDecryptorParent.cpp', 'GMPDiskStorage.cpp', 'GMPEncryptedBufferDataImpl.cpp', 'GMPMemoryStorage.cpp', @@ -112,7 +107,6 @@ IPDL_SOURCES += [ 'PGMP.ipdl', 'PGMPAudioDecoder.ipdl', 'PGMPContent.ipdl', - 'PGMPDecryptor.ipdl', 'PGMPService.ipdl', 'PGMPStorage.ipdl', 'PGMPTimer.ipdl', diff --git a/dom/media/gmp/mozIGeckoMediaPluginService.idl b/dom/media/gmp/mozIGeckoMediaPluginService.idl index 388c581425..cf65541a92 100644 --- a/dom/media/gmp/mozIGeckoMediaPluginService.idl +++ b/dom/media/gmp/mozIGeckoMediaPluginService.idl @@ -11,7 +11,6 @@ #include "nsTArray.h" #include "nsStringGlue.h" class GMPAudioDecoderProxy; -class GMPDecryptorProxy; class GMPVideoDecoderProxy; class GMPVideoEncoderProxy; class GMPVideoHost; @@ -33,7 +32,6 @@ public: virtual ~GMPVideoGetterCallback() { MOZ_COUNT_DTOR(GMPVideoGetterCallback<T>); } virtual void Done(T*, GMPVideoHost*) = 0; }; -typedef GMPGetterCallback<GMPDecryptorProxy> GetGMPDecryptorCallback; typedef GMPGetterCallback<GMPAudioDecoderProxy> GetGMPAudioDecoderCallback; typedef GMPVideoGetterCallback<GMPVideoDecoderProxy> GetGMPVideoDecoderCallback; typedef GMPVideoGetterCallback<GMPVideoEncoderProxy> GetGMPVideoEncoderCallback; @@ -47,7 +45,6 @@ public: %} [ptr] native TagArray(nsTArray<nsCString>); -native GetGMPDecryptorCallback(mozilla::UniquePtr<GetGMPDecryptorCallback>&&); native GetGMPAudioDecoderCallback(mozilla::UniquePtr<GetGMPAudioDecoderCallback>&&); native GetGMPVideoDecoderCallback(mozilla::UniquePtr<GetGMPVideoDecoderCallback>&&); native GetGMPVideoEncoderCallback(mozilla::UniquePtr<GetGMPVideoEncoderCallback>&&); @@ -94,19 +91,6 @@ interface mozIGeckoMediaPluginService : nsISupports in GetGMPVideoDecoderCallback callback); /** - * Gets a video decoder as per getGMPVideoDecoder, except it is linked to - * with a corresponding GMPDecryptor via the decryptor's ID. - * This is a temporary measure, until we can implement a Chromium CDM - * GMP protocol which does both decryption and decoding. - */ - [noscript] - void getDecryptingGMPVideoDecoder(in GMPCrashHelperPtr helper, - in TagArray tags, - in ACString nodeId, - in GetGMPVideoDecoderCallback callback, - in uint32_t decryptorId); - - /** * Get a video encoder that supports the specified tags. * The array of tags should at least contain a codec tag, and optionally * other tags. @@ -141,23 +125,6 @@ interface mozIGeckoMediaPluginService : nsISupports in GetGMPAudioDecoderCallback callback); /** - * Returns a decryption session manager that supports the specified tags. - * The array of tags should at least contain a key system tag, and optionally - * other tags. - * Callable only on GMP thread. - * This is an asynchronous operation, the Done method of the callback object - * will be called on the GMP thread with the result (which might be null in - * the case of failure). This method always takes ownership of the callback - * object, but if this method returns an error then the Done method of the - * callback object will not be called at all. - */ - [noscript] - void getGMPDecryptor(in GMPCrashHelperPtr helper, - in TagArray tags, - in ACString nodeId, - in GetGMPDecryptorCallback callback); - - /** * Gets the NodeId for a (origin, urlbarOrigin, isInprivateBrowsing) tuple. */ [noscript] diff --git a/dom/media/platforms/agnostic/gmp/GMPVideoDecoder.cpp b/dom/media/platforms/agnostic/gmp/GMPVideoDecoder.cpp index 48929a6a9e..b641003b44 100644 --- a/dom/media/platforms/agnostic/gmp/GMPVideoDecoder.cpp +++ b/dom/media/platforms/agnostic/gmp/GMPVideoDecoder.cpp @@ -311,11 +311,10 @@ GMPVideoDecoder::Init() nsTArray<nsCString> tags; InitTags(tags); UniquePtr<GetGMPVideoDecoderCallback> callback(new GMPInitDoneCallback(this)); - if (NS_FAILED(mMPS->GetDecryptingGMPVideoDecoder(mCrashHelper, - &tags, - GetNodeId(), - Move(callback), - DecryptorId()))) { + if (NS_FAILED(mMPS->GetGMPVideoDecoder(mCrashHelper, + &tags, + GetNodeId(), + Move(callback)))) { mInitPromise.Reject(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__); } diff --git a/dom/media/platforms/agnostic/gmp/GMPVideoDecoder.h b/dom/media/platforms/agnostic/gmp/GMPVideoDecoder.h index 290f02a867..7d9b8ebe2e 100644 --- a/dom/media/platforms/agnostic/gmp/GMPVideoDecoder.h +++ b/dom/media/platforms/agnostic/gmp/GMPVideoDecoder.h @@ -81,7 +81,6 @@ public: protected: virtual void InitTags(nsTArray<nsCString>& aTags); virtual nsCString GetNodeId(); - virtual uint32_t DecryptorId() const { return 0; } virtual GMPUniquePtr<GMPVideoEncodedFrame> CreateFrame(MediaRawData* aSample); virtual const VideoInfo& GetConfig() const; diff --git a/gfx/angle/src/compiler/preprocessor/Tokenizer.cpp b/gfx/angle/src/compiler/preprocessor/Tokenizer.cpp index eb6156f475..4b50adc059 100755 --- a/gfx/angle/src/compiler/preprocessor/Tokenizer.cpp +++ b/gfx/angle/src/compiler/preprocessor/Tokenizer.cpp @@ -823,9 +823,9 @@ extern int pplex \ */ YY_DECL { - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yylval = yylval_param; @@ -878,7 +878,7 @@ YY_DECL yy_match: do { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; if ( yy_accept[yy_current_state] ) { yyg->yy_last_accepting_state = yy_current_state; @@ -1336,9 +1336,9 @@ ECHO; static int yy_get_next_buffer (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = yyg->yytext_ptr; - register int number_to_move, i; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = yyg->yytext_ptr; + int number_to_move, i; int ret_val; if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) @@ -1470,15 +1470,15 @@ static int yy_get_next_buffer (yyscan_t yyscanner) static yy_state_type yy_get_previous_state (yyscan_t yyscanner) { - register yy_state_type yy_current_state; - register char *yy_cp; + yy_state_type yy_current_state; + char *yy_cp; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yy_current_state = yyg->yy_start; for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { yyg->yy_last_accepting_state = yy_current_state; @@ -1503,11 +1503,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner) */ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) { - register int yy_is_jam; + int yy_is_jam; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ - register char *yy_cp = yyg->yy_c_buf_p; + char *yy_cp = yyg->yy_c_buf_p; - register YY_CHAR yy_c = 1; + YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { yyg->yy_last_accepting_state = yy_current_state; diff --git a/gfx/angle/src/compiler/translator/glslang_lex.cpp b/gfx/angle/src/compiler/translator/glslang_lex.cpp index 8ad7b1464d..4bda42eb9a 100755 --- a/gfx/angle/src/compiler/translator/glslang_lex.cpp +++ b/gfx/angle/src/compiler/translator/glslang_lex.cpp @@ -1286,9 +1286,9 @@ extern int yylex \ */ YY_DECL { - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yylval = yylval_param; @@ -1341,7 +1341,7 @@ YY_DECL yy_match: do { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; if ( yy_accept[yy_current_state] ) { yyg->yy_last_accepting_state = yy_current_state; @@ -2237,9 +2237,9 @@ ECHO; static int yy_get_next_buffer (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = yyg->yytext_ptr; - register int number_to_move, i; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = yyg->yytext_ptr; + int number_to_move, i; int ret_val; if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) @@ -2371,15 +2371,15 @@ static int yy_get_next_buffer (yyscan_t yyscanner) static yy_state_type yy_get_previous_state (yyscan_t yyscanner) { - register yy_state_type yy_current_state; - register char *yy_cp; + yy_state_type yy_current_state; + char *yy_cp; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yy_current_state = yyg->yy_start; for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { yyg->yy_last_accepting_state = yy_current_state; @@ -2404,11 +2404,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner) */ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) { - register int yy_is_jam; + int yy_is_jam; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ - register char *yy_cp = yyg->yy_c_buf_p; + char *yy_cp = yyg->yy_c_buf_p; - register YY_CHAR yy_c = 1; + YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { yyg->yy_last_accepting_state = yy_current_state; diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 951b612502..19a0b805d2 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -5570,10 +5570,17 @@ class JS_PUBLIC_API(JSErrorNotes) // Create a deep copy of notes. js::UniquePtr<JSErrorNotes> copy(JSContext* cx); - class iterator : public std::iterator<std::input_iterator_tag, js::UniquePtr<Note>> - { + class iterator + {
+ private: js::UniquePtr<Note>* note_; - public: + public:
+ using iterator_category = std::input_iterator_tag;
+ using value_type = js::UniquePtr<Note>;
+ using difference_type = ptrdiff_t;
+ using pointer = value_type*;
+ using reference = value_type&;
+ explicit iterator(js::UniquePtr<Note>* note = nullptr) : note_(note) {} diff --git a/js/src/vm/TypedArrayObject.cpp b/js/src/vm/TypedArrayObject.cpp index de7ce028eb..e6144c0ac4 100644 --- a/js/src/vm/TypedArrayObject.cpp +++ b/js/src/vm/TypedArrayObject.cpp @@ -372,7 +372,7 @@ class TypedArrayObjectTemplate : public TypedArrayObject public: typedef NativeType ElementType; - static constexpr Scalar::Type ArrayTypeID() { return TypeIDOfType<NativeType>::id; } + static const Scalar::Type ArrayTypeID() { return TypeIDOfType<NativeType>::id; } static bool ArrayTypeIsUnsigned() { return TypeIsUnsigned<NativeType>(); } static bool ArrayTypeIsFloatingPoint() { return TypeIsFloatingPoint<NativeType>(); } diff --git a/media/webrtc/trunk/testing/gtest/include/gtest/gtest-printers.h b/media/webrtc/trunk/testing/gtest/include/gtest/gtest-printers.h index 0639d9f586..686e85f106 100644 --- a/media/webrtc/trunk/testing/gtest/include/gtest/gtest-printers.h +++ b/media/webrtc/trunk/testing/gtest/include/gtest/gtest-printers.h @@ -1,4 +1,5 @@ // Copyright 2007, Google Inc. +// Copyright 2023, Moonchild Productions // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -494,60 +495,60 @@ void PrintTupleTo(const T& t, ::std::ostream* os); // regardless of whether tr1::tuple is implemented using the // non-standard variadic template feature or not. -inline void PrintTo(const ::std::tr1::tuple<>& t, ::std::ostream* os) { +inline void PrintTo(const ::std::tuple<>& t, ::std::ostream* os) { PrintTupleTo(t, os); } template <typename T1> -void PrintTo(const ::std::tr1::tuple<T1>& t, ::std::ostream* os) { +void PrintTo(const ::std::tuple<T1>& t, ::std::ostream* os) { PrintTupleTo(t, os); } template <typename T1, typename T2> -void PrintTo(const ::std::tr1::tuple<T1, T2>& t, ::std::ostream* os) { +void PrintTo(const ::std::tuple<T1, T2>& t, ::std::ostream* os) { PrintTupleTo(t, os); } template <typename T1, typename T2, typename T3> -void PrintTo(const ::std::tr1::tuple<T1, T2, T3>& t, ::std::ostream* os) { +void PrintTo(const ::std::tuple<T1, T2, T3>& t, ::std::ostream* os) { PrintTupleTo(t, os); } template <typename T1, typename T2, typename T3, typename T4> -void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4>& t, ::std::ostream* os) { +void PrintTo(const ::std::tuple<T1, T2, T3, T4>& t, ::std::ostream* os) { PrintTupleTo(t, os); } template <typename T1, typename T2, typename T3, typename T4, typename T5> -void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5>& t, +void PrintTo(const ::std::tuple<T1, T2, T3, T4, T5>& t, ::std::ostream* os) { PrintTupleTo(t, os); } template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> -void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6>& t, +void PrintTo(const ::std::tuple<T1, T2, T3, T4, T5, T6>& t, ::std::ostream* os) { PrintTupleTo(t, os); } template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> -void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7>& t, +void PrintTo(const ::std::tuple<T1, T2, T3, T4, T5, T6, T7>& t, ::std::ostream* os) { PrintTupleTo(t, os); } template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> -void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8>& t, +void PrintTo(const ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8>& t, ::std::ostream* os) { PrintTupleTo(t, os); } template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9> -void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>& t, +void PrintTo(const ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>& t, ::std::ostream* os) { PrintTupleTo(t, os); } @@ -555,7 +556,7 @@ void PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>& t, template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10> void PrintTo( - const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& t, + const ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& t, ::std::ostream* os) { PrintTupleTo(t, os); } @@ -774,8 +775,8 @@ struct TuplePrefixPrinter { static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) { TuplePrefixPrinter<N - 1>::PrintPrefixTo(t, os); *os << ", "; - UniversalPrinter<typename ::std::tr1::tuple_element<N - 1, Tuple>::type> - ::Print(::std::tr1::get<N - 1>(t), os); + UniversalPrinter<typename ::std::tuple_element<N - 1, Tuple>::type> + ::Print(::std::get<N - 1>(t), os); } // Tersely prints the first N fields of a tuple to a string vector, @@ -784,7 +785,7 @@ struct TuplePrefixPrinter { static void TersePrintPrefixToStrings(const Tuple& t, Strings* strings) { TuplePrefixPrinter<N - 1>::TersePrintPrefixToStrings(t, strings); ::std::stringstream ss; - UniversalTersePrint(::std::tr1::get<N - 1>(t), &ss); + UniversalTersePrint(::std::get<N - 1>(t), &ss); strings->push_back(ss.str()); } }; @@ -807,14 +808,14 @@ template <> struct TuplePrefixPrinter<1> { template <typename Tuple> static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) { - UniversalPrinter<typename ::std::tr1::tuple_element<0, Tuple>::type>:: - Print(::std::tr1::get<0>(t), os); + UniversalPrinter<typename ::std::tuple_element<0, Tuple>::type>:: + Print(::std::get<0>(t), os); } template <typename Tuple> static void TersePrintPrefixToStrings(const Tuple& t, Strings* strings) { ::std::stringstream ss; - UniversalTersePrint(::std::tr1::get<0>(t), &ss); + UniversalTersePrint(::std::get<0>(t), &ss); strings->push_back(ss.str()); } }; @@ -824,7 +825,7 @@ struct TuplePrefixPrinter<1> { template <typename T> void PrintTupleTo(const T& t, ::std::ostream* os) { *os << "("; - TuplePrefixPrinter< ::std::tr1::tuple_size<T>::value>:: + TuplePrefixPrinter< ::std::tuple_size<T>::value>:: PrintPrefixTo(t, os); *os << ")"; } @@ -835,7 +836,7 @@ void PrintTupleTo(const T& t, ::std::ostream* os) { template <typename Tuple> Strings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) { Strings result; - TuplePrefixPrinter< ::std::tr1::tuple_size<Tuple>::value>:: + TuplePrefixPrinter< ::std::tuple_size<Tuple>::value>:: TersePrintPrefixToStrings(value, &result); return result; } diff --git a/media/webrtc/trunk/testing/gtest/include/gtest/internal/gtest-param-util-generated.h b/media/webrtc/trunk/testing/gtest/include/gtest/internal/gtest-param-util-generated.h index e80548592c..fa8f6f0c3b 100644 --- a/media/webrtc/trunk/testing/gtest/include/gtest/internal/gtest-param-util-generated.h +++ b/media/webrtc/trunk/testing/gtest/include/gtest/internal/gtest-param-util-generated.h @@ -2,7 +2,8 @@ // pump.py gtest-param-util-generated.h.pump // DO NOT EDIT BY HAND!!! -// Copyright 2008 Google Inc. +// Copyright 2008, Google Inc. +// Copyright 2023, Moonchild Productions // All Rights Reserved. // // Redistribution and use in source and binary forms, with or without @@ -3157,9 +3158,9 @@ class ValueArray50 { // template <typename T1, typename T2> class CartesianProductGenerator2 - : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2> > { + : public ParamGeneratorInterface< ::std::tuple<T1, T2> > { public: - typedef ::std::tr1::tuple<T1, T2> ParamType; + typedef ::std::tuple<T1, T2> ParamType; CartesianProductGenerator2(const ParamGenerator<T1>& g1, const ParamGenerator<T2>& g2) @@ -3272,9 +3273,9 @@ class CartesianProductGenerator2 template <typename T1, typename T2, typename T3> class CartesianProductGenerator3 - : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3> > { + : public ParamGeneratorInterface< ::std::tuple<T1, T2, T3> > { public: - typedef ::std::tr1::tuple<T1, T2, T3> ParamType; + typedef ::std::tuple<T1, T2, T3> ParamType; CartesianProductGenerator3(const ParamGenerator<T1>& g1, const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3) @@ -3404,9 +3405,9 @@ class CartesianProductGenerator3 template <typename T1, typename T2, typename T3, typename T4> class CartesianProductGenerator4 - : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4> > { + : public ParamGeneratorInterface< ::std::tuple<T1, T2, T3, T4> > { public: - typedef ::std::tr1::tuple<T1, T2, T3, T4> ParamType; + typedef ::std::tuple<T1, T2, T3, T4> ParamType; CartesianProductGenerator4(const ParamGenerator<T1>& g1, const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3, @@ -3555,9 +3556,9 @@ class CartesianProductGenerator4 template <typename T1, typename T2, typename T3, typename T4, typename T5> class CartesianProductGenerator5 - : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5> > { + : public ParamGeneratorInterface< ::std::tuple<T1, T2, T3, T4, T5> > { public: - typedef ::std::tr1::tuple<T1, T2, T3, T4, T5> ParamType; + typedef ::std::tuple<T1, T2, T3, T4, T5> ParamType; CartesianProductGenerator5(const ParamGenerator<T1>& g1, const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3, @@ -3723,10 +3724,10 @@ class CartesianProductGenerator5 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> class CartesianProductGenerator6 - : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, + : public ParamGeneratorInterface< ::std::tuple<T1, T2, T3, T4, T5, T6> > { public: - typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6> ParamType; + typedef ::std::tuple<T1, T2, T3, T4, T5, T6> ParamType; CartesianProductGenerator6(const ParamGenerator<T1>& g1, const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3, @@ -3909,10 +3910,10 @@ class CartesianProductGenerator6 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> class CartesianProductGenerator7 - : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, + : public ParamGeneratorInterface< ::std::tuple<T1, T2, T3, T4, T5, T6, T7> > { public: - typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7> ParamType; + typedef ::std::tuple<T1, T2, T3, T4, T5, T6, T7> ParamType; CartesianProductGenerator7(const ParamGenerator<T1>& g1, const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3, @@ -4112,10 +4113,10 @@ class CartesianProductGenerator7 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> class CartesianProductGenerator8 - : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, + : public ParamGeneratorInterface< ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8> > { public: - typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8> ParamType; + typedef ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8> ParamType; CartesianProductGenerator8(const ParamGenerator<T1>& g1, const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3, @@ -4334,10 +4335,10 @@ class CartesianProductGenerator8 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9> class CartesianProductGenerator9 - : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, + : public ParamGeneratorInterface< ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> > { public: - typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> ParamType; + typedef ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> ParamType; CartesianProductGenerator9(const ParamGenerator<T1>& g1, const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3, @@ -4573,10 +4574,10 @@ class CartesianProductGenerator9 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10> class CartesianProductGenerator10 - : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, + : public ParamGeneratorInterface< ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> > { public: - typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ParamType; + typedef ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ParamType; CartesianProductGenerator10(const ParamGenerator<T1>& g1, const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3, @@ -4838,8 +4839,8 @@ class CartesianProductHolder2 { CartesianProductHolder2(const Generator1& g1, const Generator2& g2) : g1_(g1), g2_(g2) {} template <typename T1, typename T2> - operator ParamGenerator< ::std::tr1::tuple<T1, T2> >() const { - return ParamGenerator< ::std::tr1::tuple<T1, T2> >( + operator ParamGenerator< ::std::tuple<T1, T2> >() const { + return ParamGenerator< ::std::tuple<T1, T2> >( new CartesianProductGenerator2<T1, T2>( static_cast<ParamGenerator<T1> >(g1_), static_cast<ParamGenerator<T2> >(g2_))); @@ -4860,8 +4861,8 @@ CartesianProductHolder3(const Generator1& g1, const Generator2& g2, const Generator3& g3) : g1_(g1), g2_(g2), g3_(g3) {} template <typename T1, typename T2, typename T3> - operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3> >() const { - return ParamGenerator< ::std::tr1::tuple<T1, T2, T3> >( + operator ParamGenerator< ::std::tuple<T1, T2, T3> >() const { + return ParamGenerator< ::std::tuple<T1, T2, T3> >( new CartesianProductGenerator3<T1, T2, T3>( static_cast<ParamGenerator<T1> >(g1_), static_cast<ParamGenerator<T2> >(g2_), @@ -4885,8 +4886,8 @@ CartesianProductHolder4(const Generator1& g1, const Generator2& g2, const Generator3& g3, const Generator4& g4) : g1_(g1), g2_(g2), g3_(g3), g4_(g4) {} template <typename T1, typename T2, typename T3, typename T4> - operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4> >() const { - return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4> >( + operator ParamGenerator< ::std::tuple<T1, T2, T3, T4> >() const { + return ParamGenerator< ::std::tuple<T1, T2, T3, T4> >( new CartesianProductGenerator4<T1, T2, T3, T4>( static_cast<ParamGenerator<T1> >(g1_), static_cast<ParamGenerator<T2> >(g2_), @@ -4912,8 +4913,8 @@ CartesianProductHolder5(const Generator1& g1, const Generator2& g2, const Generator3& g3, const Generator4& g4, const Generator5& g5) : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5) {} template <typename T1, typename T2, typename T3, typename T4, typename T5> - operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5> >() const { - return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5> >( + operator ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5> >() const { + return ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5> >( new CartesianProductGenerator5<T1, T2, T3, T4, T5>( static_cast<ParamGenerator<T1> >(g1_), static_cast<ParamGenerator<T2> >(g2_), @@ -4943,8 +4944,8 @@ CartesianProductHolder6(const Generator1& g1, const Generator2& g2, : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6) {} template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> - operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6> >() const { - return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6> >( + operator ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6> >() const { + return ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6> >( new CartesianProductGenerator6<T1, T2, T3, T4, T5, T6>( static_cast<ParamGenerator<T1> >(g1_), static_cast<ParamGenerator<T2> >(g2_), @@ -4976,9 +4977,9 @@ CartesianProductHolder7(const Generator1& g1, const Generator2& g2, : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7) {} template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7> - operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, + operator ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6, T7> >() const { - return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7> >( + return ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6, T7> >( new CartesianProductGenerator7<T1, T2, T3, T4, T5, T6, T7>( static_cast<ParamGenerator<T1> >(g1_), static_cast<ParamGenerator<T2> >(g2_), @@ -5014,9 +5015,9 @@ CartesianProductHolder8(const Generator1& g1, const Generator2& g2, g8_(g8) {} template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> - operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, + operator ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8> >() const { - return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8> >( + return ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8> >( new CartesianProductGenerator8<T1, T2, T3, T4, T5, T6, T7, T8>( static_cast<ParamGenerator<T1> >(g1_), static_cast<ParamGenerator<T2> >(g2_), @@ -5055,9 +5056,9 @@ CartesianProductHolder9(const Generator1& g1, const Generator2& g2, g9_(g9) {} template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9> - operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, + operator ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> >() const { - return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, + return ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> >( new CartesianProductGenerator9<T1, T2, T3, T4, T5, T6, T7, T8, T9>( static_cast<ParamGenerator<T1> >(g1_), @@ -5099,9 +5100,9 @@ CartesianProductHolder10(const Generator1& g1, const Generator2& g2, g9_(g9), g10_(g10) {} template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10> - operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, + operator ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> >() const { - return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, + return ParamGenerator< ::std::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> >( new CartesianProductGenerator10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>( diff --git a/media/webrtc/trunk/testing/gtest/include/gtest/internal/gtest-param-util-generated.h.pump b/media/webrtc/trunk/testing/gtest/include/gtest/internal/gtest-param-util-generated.h.pump index 009206fd31..864fbee16b 100644 --- a/media/webrtc/trunk/testing/gtest/include/gtest/internal/gtest-param-util-generated.h.pump +++ b/media/webrtc/trunk/testing/gtest/include/gtest/internal/gtest-param-util-generated.h.pump @@ -1,7 +1,8 @@ $$ -*- mode: c++; -*- $var n = 50 $$ Maximum length of Values arguments we want to support. $var maxtuple = 10 $$ Maximum number of Combine arguments we want to support. -// Copyright 2008 Google Inc. +// Copyright 2008, Google Inc. +// Copyright 2023, Moonchild Productions // All Rights Reserved. // // Redistribution and use in source and binary forms, with or without @@ -128,9 +129,9 @@ $range k 2..i template <$for j, [[typename T$j]]> class CartesianProductGenerator$i - : public ParamGeneratorInterface< ::std::tr1::tuple<$for j, [[T$j]]> > { + : public ParamGeneratorInterface< ::std::tuple<$for j, [[T$j]]> > { public: - typedef ::std::tr1::tuple<$for j, [[T$j]]> ParamType; + typedef ::std::tuple<$for j, [[T$j]]> ParamType; CartesianProductGenerator$i($for j, [[const ParamGenerator<T$j>& g$j]]) : $for j, [[g$(j)_(g$j)]] {} @@ -269,8 +270,8 @@ class CartesianProductHolder$i { CartesianProductHolder$i($for j, [[const Generator$j& g$j]]) : $for j, [[g$(j)_(g$j)]] {} template <$for j, [[typename T$j]]> - operator ParamGenerator< ::std::tr1::tuple<$for j, [[T$j]]> >() const { - return ParamGenerator< ::std::tr1::tuple<$for j, [[T$j]]> >( + operator ParamGenerator< ::std::tuple<$for j, [[T$j]]> >() const { + return ParamGenerator< ::std::tuple<$for j, [[T$j]]> >( new CartesianProductGenerator$i<$for j, [[T$j]]>( $for j,[[ diff --git a/memory/mozalloc/mozalloc.h b/memory/mozalloc/mozalloc.h index de8c549b31..8c224472c4 100644 --- a/memory/mozalloc/mozalloc.h +++ b/memory/mozalloc/mozalloc.h @@ -152,14 +152,11 @@ MFBT_API void* moz_xvalloc(size_t size) #if defined(_MSC_VER) /* - * Suppress build warning spam (bug 578546). + * Suppress build warning spam (issue #2281). */ -#define MOZALLOC_THROW_IF_HAS_EXCEPTIONS -#define MOZALLOC_THROW_BAD_ALLOC_IF_HAS_EXCEPTIONS +#define MOZALLOC_THROW_IF_HAS_EXCEPTIONS noexcept(true) +#define MOZALLOC_THROW_BAD_ALLOC_IF_HAS_EXCEPTIONS noexcept(false) #elif __cplusplus >= 201103 -/* - * C++11 has deprecated exception-specifications in favour of |noexcept|. - */ #define MOZALLOC_THROW_IF_HAS_EXCEPTIONS noexcept(true) #define MOZALLOC_THROW_BAD_ALLOC_IF_HAS_EXCEPTIONS noexcept(false) #else diff --git a/memory/mozalloc/throw_gcc.h b/memory/mozalloc/throw_gcc.h index c51794573e..3c61939eba 100644 --- a/memory/mozalloc/throw_gcc.h +++ b/memory/mozalloc/throw_gcc.h @@ -6,6 +6,9 @@ #ifndef mozilla_throw_gcc_h #define mozilla_throw_gcc_h +// Wrapping shouldn't be needed on libcpp 14+ +#if !defined(_LIBCPP_VERSION) || _LIBCPP_VERSION < 14000 + #include "mozilla/Attributes.h" #include <stdio.h> // snprintf @@ -140,4 +143,6 @@ __throw_system_error(int err) #undef MOZ_THROW_NORETURN +#endif // !_LIBCPP_VERSION || _LIBCPP_VERSION < 14000 + #endif // mozilla_throw_gcc_h diff --git a/mfbt/Compression.cpp b/mfbt/Compression.cpp index 6147d0d611..8dc2ec3d86 100644 --- a/mfbt/Compression.cpp +++ b/mfbt/Compression.cpp @@ -11,17 +11,9 @@ // corecrt_memory.h. #include <string> -using namespace mozilla::Compression; - -namespace { - -extern "C" { - -#include "lz4.c" +#include "lz4.h" -} - -}/* anonymous namespace */ +using namespace mozilla::Compression; /* Our wrappers */ diff --git a/mfbt/Span.h b/mfbt/Span.h index e71e068c60..fe679aa8bf 100644 --- a/mfbt/Span.h +++ b/mfbt/Span.h @@ -810,6 +810,15 @@ private: storage_type<span_details::extent_type<Extent>> storage_; }; +template <typename T, size_t Extent> +Span(T (&aArr)[Extent]) -> Span<T, Extent>; + +template <class Container> +Span(Container&) -> Span<typename Container::value_type>; + +template <class Container> +Span(const Container&) -> Span<const typename Container::value_type>; + // [Span.comparison], Span comparison operators template<class ElementType, size_t FirstExtent, size_t SecondExtent> inline bool diff --git a/mfbt/moz.build b/mfbt/moz.build index 54b13f21b9..e4b294292d 100644 --- a/mfbt/moz.build +++ b/mfbt/moz.build @@ -124,20 +124,11 @@ SOURCES += mfbt_nonunified_src_cppsrcs DISABLE_STL_WRAPPING = True -# Suppress warnings in third-party LZ4 code. -# TODO: Remove these suppressions after bug 993267 is fixed. - -if CONFIG['GNU_CXX']: - SOURCES['/mfbt/Compression.cpp'].flags += ['-Wno-unused-function'] - CXXFLAGS += ['-Wno-error=shadow'] - if CONFIG['CLANG_CXX']: # Suppress warnings from third-party V8 Decimal code. SOURCES['/mfbt/decimal/Decimal.cpp'].flags += ['-Wno-implicit-fallthrough'] -if CONFIG['_MSC_VER']: - # Error 4804 is "'>' : unsafe use of type 'bool' in operation" - SOURCES['/mfbt/Compression.cpp'].flags += ['-wd4804'] - if CONFIG['MOZ_NEEDS_LIBATOMIC']: OS_LIBS += ['atomic'] + +DEFINES['LZ4LIB_VISIBILITY'] = '' diff --git a/mfbt/objs.mozbuild b/mfbt/objs.mozbuild index 8aed3d179f..e8fd522d79 100644 --- a/mfbt/objs.mozbuild +++ b/mfbt/objs.mozbuild @@ -28,9 +28,11 @@ mfbt_src_cppsrcs = [ # Compression.cpp cannot be built in unified mode because it pulls in Windows system headers. # Decimal.cpp doesn't build in unified mode with gcc. +# We build lz4 in C mode mfbt_nonunified_src_lcppsrcs = [ 'Compression.cpp', 'decimal/Decimal.cpp', + 'lz4.c', ] mfbt_nonunified_src_cppsrcs = [ diff --git a/old-configure.in b/old-configure.in index 3d1921b9c7..8785bc9467 100644 --- a/old-configure.in +++ b/old-configure.in @@ -5235,7 +5235,7 @@ ac_configure_args="$_SUBDIR_CONFIG_ARGS" # --with-system-nspr will have been converted into the relevant $NSPR_CFLAGS # and $NSPR_LIBS. -ac_configure_args="`echo $ac_configure_args | sed -e 's/--with-system-nspr\S* *//'`" +ac_configure_args="`echo $ac_configure_args | sed -e 's/--with-system-nspr[^[:space:]]* *//'`" if test -n "$NSPR_CFLAGS" -o -n "$NSPR_LIBS"; then ac_configure_args="$ac_configure_args --with-nspr-cflags='$NSPR_CFLAGS'" diff --git a/toolkit/components/protobuf/src/google/protobuf/repeated_field.h b/toolkit/components/protobuf/src/google/protobuf/repeated_field.h index 50051831d6..29fe823360 100644 --- a/toolkit/components/protobuf/src/google/protobuf/repeated_field.h +++ b/toolkit/components/protobuf/src/google/protobuf/repeated_field.h @@ -1250,23 +1250,14 @@ namespace internal { // This code based on net/proto/proto-array-internal.h by Jeffrey Yasskin // (jyasskin@google.com). template<typename Element> -class RepeatedPtrIterator - : public std::iterator< - std::random_access_iterator_tag, Element> { +class RepeatedPtrIterator { public: typedef RepeatedPtrIterator<Element> iterator; - typedef std::iterator< - std::random_access_iterator_tag, Element> superclass; - - // Shadow the value_type in std::iterator<> because const_iterator::value_type - // needs to be T, not const T. - typedef typename remove_const<Element>::type value_type; - - // Let the compiler know that these are type names, so we don't have to - // write "typename" in front of them everywhere. - typedef typename superclass::reference reference; - typedef typename superclass::pointer pointer; - typedef typename superclass::difference_type difference_type; + typedef std::random_access_iterator_tag iterator_category; + typedef Element value_type; + typedef std::ptrdiff_t difference_type; + typedef Element* pointer; + typedef Element& reference; RepeatedPtrIterator() : it_(NULL) {} explicit RepeatedPtrIterator(void* const* it) : it_(it) {} @@ -1346,22 +1337,14 @@ class RepeatedPtrIterator // referenced by the iterator. It should either be "void *" for a mutable // iterator, or "const void *" for a constant iterator. template<typename Element, typename VoidPtr> -class RepeatedPtrOverPtrsIterator - : public std::iterator<std::random_access_iterator_tag, Element*> { +class RepeatedPtrOverPtrsIterator { public: typedef RepeatedPtrOverPtrsIterator<Element, VoidPtr> iterator; - typedef std::iterator< - std::random_access_iterator_tag, Element*> superclass; - - // Shadow the value_type in std::iterator<> because const_iterator::value_type - // needs to be T, not const T. - typedef typename remove_const<Element*>::type value_type; - - // Let the compiler know that these are type names, so we don't have to - // write "typename" in front of them everywhere. - typedef typename superclass::reference reference; - typedef typename superclass::pointer pointer; - typedef typename superclass::difference_type difference_type; + typedef std::random_access_iterator_tag iterator_category; + typedef Element value_type; + typedef std::ptrdiff_t difference_type; + typedef Element* pointer; + typedef Element& reference; RepeatedPtrOverPtrsIterator() : it_(NULL) {} explicit RepeatedPtrOverPtrsIterator(VoidPtr* it) : it_(it) {} diff --git a/xpcom/glue/nsTArray.h b/xpcom/glue/nsTArray.h index 03913a3765..47635de318 100644 --- a/xpcom/glue/nsTArray.h +++ b/xpcom/glue/nsTArray.h @@ -2466,6 +2466,12 @@ MakeSpan(const nsTArray_Impl<ElementType, TArrayAlloc>& aTArray) return aTArray; } +template <typename E, class Alloc> +Span(nsTArray_Impl<E, Alloc>&) -> Span<E>; + +template <typename E, class Alloc> +Span(const nsTArray_Impl<E, Alloc>&) -> Span<const E>; + } // namespace mozilla // Assert that AutoTArray doesn't have any extra padding inside. |