diff options
author | Moonchild <moonchild@palemoon.org> | 2021-12-07 16:22:47 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2021-12-07 16:22:47 +0000 |
commit | 70e12f56d10360843374c5003c163e04e4039740 (patch) | |
tree | bf98d5af7bfb12a7bb95e12b8e4066f2f4b6f924 /dom | |
parent | 31022b58f3c139e48636a8cf8cb2c36812c72114 (diff) | |
download | aura-central-70e12f56d10360843374c5003c163e04e4039740.tar.gz |
Issue %1314 - Part 13: Remove PeerIdentity
Diffstat (limited to 'dom')
-rw-r--r-- | dom/media/MediaManager.cpp | 38 | ||||
-rw-r--r-- | dom/media/webrtc/PeerIdentity.cpp | 86 | ||||
-rw-r--r-- | dom/media/webrtc/PeerIdentity.h | 83 | ||||
-rw-r--r-- | dom/media/webrtc/moz.build | 7 | ||||
-rw-r--r-- | dom/webidl/MediaStream.webidl | 1 |
5 files changed, 10 insertions, 205 deletions
diff --git a/dom/media/MediaManager.cpp b/dom/media/MediaManager.cpp index eb80c434e..1b7a05d38 100644 --- a/dom/media/MediaManager.cpp +++ b/dom/media/MediaManager.cpp @@ -32,7 +32,6 @@ #include "nsIInputStream.h" #include "nsILineInputStream.h" #include "mozilla/Types.h" -#include "mozilla/PeerIdentity.h" #include "mozilla/dom/ContentChild.h" #include "mozilla/dom/File.h" #include "mozilla/dom/MediaStreamBinding.h" @@ -976,15 +975,13 @@ public: const nsCString& aOrigin, const MediaStreamConstraints& aConstraints, AudioDevice* aAudioDevice, - VideoDevice* aVideoDevice, - PeerIdentity* aPeerIdentity) + VideoDevice* aVideoDevice) : mConstraints(aConstraints) , mAudioDevice(aAudioDevice) , mVideoDevice(aVideoDevice) , mWindowID(aWindowID) , mListener(aListener) , mOrigin(aOrigin) - , mPeerIdentity(aPeerIdentity) , mManager(MediaManager::GetInstance()) { mOnSuccess.swap(aOnSuccess); @@ -1080,21 +1077,17 @@ public: const nsString& aLabel, GetUserMediaCallbackMediaStreamListener* aListener, const MediaSourceEnum aSource, - const TrackID aTrackID, - const PeerIdentity* aPeerIdentity) - : MediaStreamTrackSource(aPrincipal, aLabel), mListener(aListener), - mSource(aSource), mTrackID(aTrackID), mPeerIdentity(aPeerIdentity) {} + const TrackID aTrackID) + : MediaStreamTrackSource(aPrincipal, aLabel) + , mListener(aListener) + , mSource(aSource) + , mTrackID(aTrackID) {} MediaSourceEnum GetMediaSource() const override { return mSource; } - const PeerIdentity* GetPeerIdentity() const override - { - return mPeerIdentity; - } - already_AddRefed<PledgeVoid> ApplyConstraints(nsPIDOMWindowInner* aWindow, const MediaTrackConstraints& aConstraints) override @@ -1131,15 +1124,10 @@ public: RefPtr<GetUserMediaCallbackMediaStreamListener> mListener; const MediaSourceEnum mSource; const TrackID mTrackID; - const RefPtr<const PeerIdentity> mPeerIdentity; }; nsCOMPtr<nsIPrincipal> principal; - if (mPeerIdentity) { - principal = nsNullPrincipal::CreateWithInheritedAttributes(window->GetExtantDoc()->NodePrincipal()); - } else { - principal = window->GetExtantDoc()->NodePrincipal(); - } + principal = window->GetExtantDoc()->NodePrincipal(); // Normal case, connect the source stream to the track union stream to // avoid us blocking. Pass a simple TrackSourceGetter for potential @@ -1155,7 +1143,7 @@ public: mAudioDevice->GetSource()->GetMediaSource(); RefPtr<MediaStreamTrackSource> audioSource = new LocalTrackSource(principal, audioDeviceName, mListener, source, - kAudioTrack, mPeerIdentity); + kAudioTrack); MOZ_ASSERT(IsOn(mConstraints.mAudio)); RefPtr<MediaStreamTrack> track = domStream->CreateDOMTrack(kAudioTrack, MediaSegment::AUDIO, audioSource, @@ -1169,7 +1157,7 @@ public: mVideoDevice->GetSource()->GetMediaSource(); RefPtr<MediaStreamTrackSource> videoSource = new LocalTrackSource(principal, videoDeviceName, mListener, source, - kVideoTrack, mPeerIdentity); + kVideoTrack); MOZ_ASSERT(IsOn(mConstraints.mVideo)); RefPtr<MediaStreamTrack> track = domStream->CreateDOMTrack(kVideoTrack, MediaSegment::VIDEO, videoSource, @@ -1234,7 +1222,6 @@ private: uint64_t mWindowID; RefPtr<GetUserMediaCallbackMediaStreamListener> mListener; nsCString mOrigin; - RefPtr<PeerIdentity> mPeerIdentity; RefPtr<MediaManager> mManager; // get ref to this when creating the runnable }; @@ -1461,16 +1448,11 @@ public: } return NS_OK; } - PeerIdentity* peerIdentity = nullptr; - if (!mConstraints.mPeerIdentity.IsEmpty()) { - peerIdentity = new PeerIdentity(mConstraints.mPeerIdentity); - } NS_DispatchToMainThread(do_AddRef( new GetUserMediaStreamRunnable(mOnSuccess, mOnFailure, mWindowID, mListener, mOrigin, - mConstraints, mAudioDevice, mVideoDevice, - peerIdentity))); + mConstraints, mAudioDevice, mVideoDevice))); MOZ_ASSERT(!mOnSuccess); MOZ_ASSERT(!mOnFailure); return NS_OK; diff --git a/dom/media/webrtc/PeerIdentity.cpp b/dom/media/webrtc/PeerIdentity.cpp deleted file mode 100644 index 4b4abea3b..000000000 --- a/dom/media/webrtc/PeerIdentity.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * vim: sw=2 ts=2 sts=2 expandtab - * 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 "PeerIdentity.h" - -#include "mozilla/DebugOnly.h" -#include "nsCOMPtr.h" -#include "nsIIDNService.h" -#include "nsNetCID.h" -#include "nsServiceManagerUtils.h" - -namespace mozilla { - -bool -PeerIdentity::Equals(const PeerIdentity& aOther) const -{ - return Equals(aOther.mPeerIdentity); -} - -bool -PeerIdentity::Equals(const nsAString& aOtherString) const -{ - nsString user; - GetUser(mPeerIdentity, user); - nsString otherUser; - GetUser(aOtherString, otherUser); - if (user != otherUser) { - return false; - } - - nsString host; - GetHost(mPeerIdentity, host); - nsString otherHost; - GetHost(aOtherString, otherHost); - - nsresult rv; - nsCOMPtr<nsIIDNService> idnService - = do_GetService("@mozilla.org/network/idn-service;1", &rv); - if (NS_WARN_IF(NS_FAILED(rv))) { - return host == otherHost; - } - - nsCString normHost; - GetNormalizedHost(idnService, host, normHost); - nsCString normOtherHost; - GetNormalizedHost(idnService, otherHost, normOtherHost); - return normHost == normOtherHost; -} - -/* static */ void -PeerIdentity::GetUser(const nsAString& aPeerIdentity, nsAString& aUser) -{ - int32_t at = aPeerIdentity.FindChar('@'); - if (at >= 0) { - aUser = Substring(aPeerIdentity, 0, at); - } else { - aUser.Truncate(); - } -} - -/* static */ void -PeerIdentity::GetHost(const nsAString& aPeerIdentity, nsAString& aHost) -{ - int32_t at = aPeerIdentity.FindChar('@'); - if (at >= 0) { - aHost = Substring(aPeerIdentity, at + 1); - } else { - aHost = aPeerIdentity; - } -} - -/* static */ void -PeerIdentity::GetNormalizedHost(const nsCOMPtr<nsIIDNService>& aIdnService, - const nsAString& aHost, - nsACString& aNormalizedHost) -{ - const nsCString chost = NS_ConvertUTF16toUTF8(aHost); - DebugOnly<nsresult> rv = aIdnService->ConvertUTF8toACE(chost, aNormalizedHost); - NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), - "Failed to convert UTF-8 host to ASCII"); -} - -} /* namespace mozilla */ diff --git a/dom/media/webrtc/PeerIdentity.h b/dom/media/webrtc/PeerIdentity.h deleted file mode 100644 index 1f3413bf6..000000000 --- a/dom/media/webrtc/PeerIdentity.h +++ /dev/null @@ -1,83 +0,0 @@ - /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * vim: sw=2 ts=2 sts=2 expandtab - * 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 PeerIdentity_h -#define PeerIdentity_h - -#ifdef MOZILLA_INTERNAL_API -#include "nsString.h" -#else -#include "nsStringAPI.h" -#endif - -#include "mozilla/RefCounted.h" - -template <class T> class nsCOMPtr; -class nsIIDNService; - -namespace mozilla { - -/** - * This class implements the identifier used in WebRTC identity. Peers are - * identified using a string in the form [<user>@]<domain>, for instance, - * "user@example.com'. The (optional) user portion is a site-controlled string - * containing any character other than '@'. The domain portion is a valid IDN - * domain name and is compared accordingly. - * - * See: http://tools.ietf.org/html/draft-ietf-rtcweb-security-arch-09#section-5.6.5.3.3.1 - */ -class PeerIdentity final : public RefCounted<PeerIdentity> -{ -public: - MOZ_DECLARE_REFCOUNTED_TYPENAME(PeerIdentity) - - explicit PeerIdentity(const nsAString& aPeerIdentity) - : mPeerIdentity(aPeerIdentity) {} - ~PeerIdentity() {} - - bool Equals(const PeerIdentity& aOther) const; - bool Equals(const nsAString& aOtherString) const; - const nsString& ToString() const { return mPeerIdentity; } - -private: - static void GetUser(const nsAString& aPeerIdentity, nsAString& aUser); - static void GetHost(const nsAString& aPeerIdentity, nsAString& aHost); - - static void GetNormalizedHost(const nsCOMPtr<nsIIDNService>& aIdnService, - const nsAString& aHost, - nsACString& aNormalizedHost); - - nsString mPeerIdentity; -}; - -inline bool -operator==(const PeerIdentity& aOne, const PeerIdentity& aTwo) -{ - return aOne.Equals(aTwo); -} - -inline bool -operator==(const PeerIdentity& aOne, const nsAString& aString) -{ - return aOne.Equals(aString); -} - -inline bool -operator!=(const PeerIdentity& aOne, const PeerIdentity& aTwo) -{ - return !aOne.Equals(aTwo); -} - -inline bool -operator!=(const PeerIdentity& aOne, const nsAString& aString) -{ - return !aOne.Equals(aString); -} - - -} /* namespace mozilla */ - -#endif /* PeerIdentity_h */ diff --git a/dom/media/webrtc/moz.build b/dom/media/webrtc/moz.build index 12cc7ac1c..bdc3f0256 100644 --- a/dom/media/webrtc/moz.build +++ b/dom/media/webrtc/moz.build @@ -6,9 +6,6 @@ with Files('*'): BUG_COMPONENT = ('Core', 'WebRTC: Audio/Video') -with Files('PeerIdentity.*'): - BUG_COMPONENT = ('Core', 'WebRTC: Signaling') - XPIDL_MODULE = 'content_webrtc' EXPORTS += [ @@ -27,12 +24,8 @@ UNIFIED_SOURCES += [ ] SOURCES += [ 'MediaEngineDefault.cpp', - 'PeerIdentity.cpp', ] -EXPORTS.mozilla += [ - 'PeerIdentity.h', -] EXPORTS.mozilla.dom += [ 'RTCCertificate.h', ] diff --git a/dom/webidl/MediaStream.webidl b/dom/webidl/MediaStream.webidl index 3d0347f8b..c61dbff98 100644 --- a/dom/webidl/MediaStream.webidl +++ b/dom/webidl/MediaStream.webidl @@ -20,7 +20,6 @@ dictionary MediaStreamConstraints { boolean fake; // For testing purpose. Generates frames of solid // colors if video is enabled, and sound of 1Khz sine // wave if audio is enabled. - DOMString? peerIdentity = null; }; [Exposed=Window, |