Bug 1181262 - Disabling more code under --disable-webrtc, r=dholbert,bwc
authorMartin Thomson <martin.thomson@gmail.com>
Wed, 08 Jul 2015 12:27:45 -0700
changeset 285278 0e8193deffea7398e18582afa0349f984fd7e8e0
parent 285277 0e66ab5ef1fa4df364c9f21fa7330c3bd9fd0015
child 285279 14c4e4aded9f739bb95260022dcbc92faecc7326
push id934
push userraliiev@mozilla.com
push dateMon, 26 Oct 2015 12:58:05 +0000
treeherdermozilla-release@05704e35c1d0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert, bwc
bugs1181262
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1181262 - Disabling more code under --disable-webrtc, r=dholbert,bwc
dom/base/nsJSEnvironment.cpp
dom/media/RTCIdentityProviderRegistrar.cpp
dom/media/RTCIdentityProviderRegistrar.h
dom/media/moz.build
dom/media/webrtc/RTCIdentityProviderRegistrar.cpp
dom/media/webrtc/RTCIdentityProviderRegistrar.h
dom/media/webrtc/moz.build
dom/webidl/moz.build
js/xpconnect/src/Sandbox.cpp
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -55,18 +55,20 @@
 #include "mozilla/AutoRestore.h"
 #include "mozilla/dom/CryptoKey.h"
 #include "mozilla/dom/ErrorEvent.h"
 #include "mozilla/dom/ImageDataBinding.h"
 #include "mozilla/dom/ImageData.h"
 #ifdef MOZ_NFC
 #include "mozilla/dom/MozNDEFRecord.h"
 #endif // MOZ_NFC
+#ifdef MOZ_WEBRTC
 #include "mozilla/dom/RTCCertificate.h"
 #include "mozilla/dom/RTCCertificateBinding.h"
+#endif
 #include "mozilla/dom/StructuredClone.h"
 #include "mozilla/dom/SubtleCryptoBinding.h"
 #include "mozilla/ipc/BackgroundUtils.h"
 #include "mozilla/ipc/PBackgroundSharedTypes.h"
 #include "nsAXPCNativeCallContext.h"
 #include "mozilla/CycleCollectedJSRuntime.h"
 
 #include "nsJSPrincipals.h"
@@ -2544,32 +2546,36 @@ NS_DOMReadStructuredClone(JSContext* cx,
     }
     return result;
 #else
     return nullptr;
 #endif
   }
 
   if (tag == SCTAG_DOM_RTC_CERTIFICATE) {
+#ifdef MOZ_WEBRTC
     nsIGlobalObject *global = xpc::NativeGlobal(JS::CurrentGlobalOrNull(cx));
     if (!global) {
       return nullptr;
     }
 
     // Prevent the return value from being trashed by a GC during ~nsRefPtr.
     JS::Rooted<JSObject*> result(cx);
     {
       nsRefPtr<RTCCertificate> cert = new RTCCertificate(global);
       if (!cert->ReadStructuredClone(reader)) {
         result = nullptr;
       } else {
         result = cert->WrapObject(cx, nullptr);
       }
     }
     return result;
+#else
+    return nullptr;
+#endif
   }
 
   // Don't know what this is. Bail.
   xpc::Throw(cx, NS_ERROR_DOM_DATA_CLONE_ERR);
   return nullptr;
 }
 
 bool
@@ -2586,22 +2592,24 @@ NS_DOMWriteStructuredClone(JSContext* cx
 
   // Handle Key cloning
   CryptoKey* key;
   if (NS_SUCCEEDED(UNWRAP_OBJECT(CryptoKey, obj, key))) {
     return JS_WriteUint32Pair(writer, SCTAG_DOM_WEBCRYPTO_KEY, 0) &&
            key->WriteStructuredClone(writer);
   }
 
+#ifdef MOZ_WEBRTC
   // Handle WebRTC Certificate cloning
   RTCCertificate* cert;
   if (NS_SUCCEEDED(UNWRAP_OBJECT(RTCCertificate, obj, cert))) {
     return JS_WriteUint32Pair(writer, SCTAG_DOM_RTC_CERTIFICATE, 0) &&
            cert->WriteStructuredClone(writer);
   }
+#endif
 
   if (xpc::IsReflector(obj)) {
     nsCOMPtr<nsISupports> base = xpc::UnwrapReflectorToISupports(obj);
     nsCOMPtr<nsIPrincipal> principal = do_QueryInterface(base);
     if (principal) {
       mozilla::ipc::PrincipalInfo info;
       if (NS_WARN_IF(NS_FAILED(PrincipalToPrincipalInfo(principal, &info)))) {
         xpc::Throw(cx, NS_ERROR_DOM_DATA_CLONE_ERR);
--- a/dom/media/moz.build
+++ b/dom/media/moz.build
@@ -177,17 +177,16 @@ EXPORTS.mozilla.dom += [
     'AudioTrack.h',
     'AudioTrackList.h',
     'CanvasCaptureMediaStream.h',
     'GetUserMediaRequest.h',
     'MediaDeviceInfo.h',
     'MediaDevices.h',
     'MediaStreamError.h',
     'MediaStreamTrack.h',
-    'RTCIdentityProviderRegistrar.h',
     'TextTrack.h',
     'TextTrackCue.h',
     'TextTrackCueList.h',
     'TextTrackList.h',
     'TextTrackRegion.h',
     'VideoPlaybackQuality.h',
     'VideoStreamTrack.h',
     'VideoTrack.h',
@@ -230,17 +229,16 @@ UNIFIED_SOURCES += [
     'MediaStreamTrack.cpp',
     'MediaTaskQueue.cpp',
     'MediaTimer.cpp',
     'MediaTrack.cpp',
     'MediaTrackList.cpp',
     'MP3Decoder.cpp',
     'MP3Demuxer.cpp',
     'MP3FrameParser.cpp',
-    'RTCIdentityProviderRegistrar.cpp',
     'RtspMediaResource.cpp',
     'SharedThreadPool.cpp',
     'StreamBuffer.cpp',
     'TextTrack.cpp',
     'TextTrackCue.cpp',
     'TextTrackCueList.cpp',
     'TextTrackList.cpp',
     'TextTrackRegion.cpp',
rename from dom/media/RTCIdentityProviderRegistrar.cpp
rename to dom/media/webrtc/RTCIdentityProviderRegistrar.cpp
rename from dom/media/RTCIdentityProviderRegistrar.h
rename to dom/media/webrtc/RTCIdentityProviderRegistrar.h
--- a/dom/media/webrtc/moz.build
+++ b/dom/media/webrtc/moz.build
@@ -17,22 +17,25 @@ EXPORTS += [
     'MediaEngineCameraVideoSource.h',
     'MediaEngineDefault.h',
     'MediaTrackConstraints.h',
 ]
 
 if CONFIG['MOZ_WEBRTC']:
     EXPORTS += ['AudioOutputObserver.h',
                 'MediaEngineWebRTC.h']
+    EXPORTS.mozilla.dom += [ 'RTCIdentityProviderRegistrar.h' ]
     UNIFIED_SOURCES += [
         'MediaEngineCameraVideoSource.cpp',
         'MediaEngineTabVideoSource.cpp',
         'MediaEngineWebRTCAudio.cpp',
         'MediaEngineWebRTCVideo.cpp',
         'MediaTrackConstraints.cpp',
+        'RTCCertificate.cpp',
+        'RTCIdentityProviderRegistrar.cpp',
     ]
     # MediaEngineWebRTC.cpp needs to be built separately.
     SOURCES += [
         'MediaEngineWebRTC.cpp',
     ]
     LOCAL_INCLUDES += [
         '/dom/base',
         '/dom/camera',
@@ -54,17 +57,16 @@ if CONFIG['MOZ_WEBRTC']:
 
 XPIDL_SOURCES += [
     'nsITabSource.idl'
 ]
 
 UNIFIED_SOURCES += [
     'MediaEngineDefault.cpp',
     'PeerIdentity.cpp',
-    'RTCCertificate.cpp',
 ]
 
 EXPORTS.mozilla += [
     'PeerIdentity.h',
 ]
 EXPORTS.mozilla.dom += [
     'RTCCertificate.h',
 ]
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -369,26 +369,16 @@ WEBIDL_FILES = [
     'Rect.webidl',
     'Request.webidl',
     'RequestSyncManager.webidl',
     'RequestSyncScheduler.webidl',
     'ResourceStats.webidl',
     'ResourceStatsManager.webidl',
     'Response.webidl',
     'RGBColor.webidl',
-    'RTCCertificate.webidl',
-    'RTCConfiguration.webidl',
-    'RTCIceCandidate.webidl',
-    'RTCIdentityAssertion.webidl',
-    'RTCIdentityProvider.webidl',
-    'RTCPeerConnection.webidl',
-    'RTCPeerConnectionStatic.webidl',
-    'RTCRtpReceiver.webidl',
-    'RTCRtpSender.webidl',
-    'RTCSessionDescription.webidl',
     'RTCStatsReport.webidl',
     'Screen.webidl',
     'ScriptProcessorNode.webidl',
     'ScrollAreaEvent.webidl',
     'ScrollBoxObject.webidl',
     'Selection.webidl',
     'ServiceWorker.webidl',
     'ServiceWorkerContainer.webidl',
@@ -597,16 +587,26 @@ if CONFIG['MOZ_AUDIO_CHANNEL_MANAGER']:
 if CONFIG['MOZ_WEBRTC']:
     WEBIDL_FILES += [
         'DataChannel.webidl',
         'MediaStreamList.webidl',
         'PeerConnectionImpl.webidl',
         'PeerConnectionImplEnums.webidl',
         'PeerConnectionObserver.webidl',
         'PeerConnectionObserverEnums.webidl',
+        'RTCCertificate.webidl',
+        'RTCConfiguration.webidl',
+        'RTCIceCandidate.webidl',
+        'RTCIdentityAssertion.webidl',
+        'RTCIdentityProvider.webidl',
+        'RTCPeerConnection.webidl',
+        'RTCPeerConnectionStatic.webidl',
+        'RTCRtpReceiver.webidl',
+        'RTCRtpSender.webidl',
+        'RTCSessionDescription.webidl',
         'WebrtcGlobalInformation.webidl',
     ]
 
 if CONFIG['MOZ_WEBSPEECH']:
     WEBIDL_FILES += [
         'SpeechGrammar.webidl',
         'SpeechGrammarList.webidl',
         'SpeechRecognition.webidl',
@@ -749,17 +749,16 @@ GENERATED_EVENTS_WEBIDL_FILES = [
     'DOMTransactionEvent.webidl',
     'DownloadEvent.webidl',
     'ErrorEvent.webidl',
     'ExternalAppEvent.webidl',
     'HashChangeEvent.webidl',
     'IccChangeEvent.webidl',
     'ImageCaptureErrorEvent.webidl',
     'MediaStreamEvent.webidl',
-    'MediaStreamTrackEvent.webidl',
     'MozApplicationEvent.webidl',
     'MozCellBroadcastEvent.webidl',
     'MozClirModeEvent.webidl',
     'MozContactChangeEvent.webidl',
     'MozEmergencyCbModeEvent.webidl',
     'MozInterAppMessageEvent.webidl',
     'MozMessageDeletedEvent.webidl',
     'MozMmsEvent.webidl',
@@ -770,33 +769,38 @@ GENERATED_EVENTS_WEBIDL_FILES = [
     'MozStkCommandEvent.webidl',
     'MozVoicemailEvent.webidl',
     'PageTransitionEvent.webidl',
     'PluginCrashedEvent.webidl',
     'PopStateEvent.webidl',
     'PopupBlockedEvent.webidl',
     'ProgressEvent.webidl',
     'RecordErrorEvent.webidl',
-    'RTCDataChannelEvent.webidl',
-    'RTCPeerConnectionIceEvent.webidl',
     'ScrollViewChangeEvent.webidl',
     'SelectionStateChangedEvent.webidl',
     'StyleRuleChangeEvent.webidl',
     'StyleSheetApplicableStateChangeEvent.webidl',
     'StyleSheetChangeEvent.webidl',
     'TrackEvent.webidl',
     'TVCurrentChannelChangedEvent.webidl',
     'TVCurrentSourceChangedEvent.webidl',
     'TVEITBroadcastedEvent.webidl',
     'TVScanningStateChangedEvent.webidl',
     'UDPMessageEvent.webidl',
     'UserProximityEvent.webidl',
     'USSDReceivedEvent.webidl',
 ]
 
+if CONFIG['MOZ_WEBRTC']:
+    GENERATED_EVENTS_WEBIDL_FILES += [
+        'MediaStreamTrackEvent.webidl',
+        'RTCDataChannelEvent.webidl',
+        'RTCPeerConnectionIceEvent.webidl',
+    ]
+
 if CONFIG['MOZ_WEBSPEECH']:
     GENERATED_EVENTS_WEBIDL_FILES += [
         'SpeechRecognitionEvent.webidl',
         'SpeechSynthesisErrorEvent.webidl',
         'SpeechSynthesisEvent.webidl',
     ]
 
 if CONFIG['MOZ_GAMEPAD']:
--- a/js/xpconnect/src/Sandbox.cpp
+++ b/js/xpconnect/src/Sandbox.cpp
@@ -32,17 +32,19 @@
 #include "mozilla/dom/BlobBinding.h"
 #include "mozilla/dom/CSSBinding.h"
 #include "mozilla/dom/indexedDB/IndexedDatabaseManager.h"
 #include "mozilla/dom/Fetch.h"
 #include "mozilla/dom/FileBinding.h"
 #include "mozilla/dom/PromiseBinding.h"
 #include "mozilla/dom/RequestBinding.h"
 #include "mozilla/dom/ResponseBinding.h"
+#ifdef MOZ_WEBRTC
 #include "mozilla/dom/RTCIdentityProviderRegistrar.h"
+#endif
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/dom/TextDecoderBinding.h"
 #include "mozilla/dom/TextEncoderBinding.h"
 #include "mozilla/dom/UnionConversions.h"
 #include "mozilla/dom/URLBinding.h"
 #include "mozilla/dom/URLSearchParamsBinding.h"
 
 using namespace mozilla;
@@ -221,29 +223,31 @@ SandboxCreateCrypto(JSContext* cx, JS::H
     MOZ_ASSERT(native);
 
     dom::Crypto* crypto = new dom::Crypto();
     crypto->Init(native);
     JS::RootedObject wrapped(cx, crypto->WrapObject(cx, nullptr));
     return JS_DefineProperty(cx, obj, "crypto", wrapped, JSPROP_ENUMERATE);
 }
 
+#ifdef MOZ_WEBRTC
 static bool
 SandboxCreateRTCIdentityProvider(JSContext* cx, JS::HandleObject obj)
 {
     MOZ_ASSERT(JS_IsGlobalObject(obj));
 
     nsCOMPtr<nsIGlobalObject> nativeGlobal = xpc::NativeGlobal(obj);
     MOZ_ASSERT(nativeGlobal);
 
     dom::RTCIdentityProviderRegistrar* registrar =
             new dom::RTCIdentityProviderRegistrar(nativeGlobal);
     JS::RootedObject wrapped(cx, registrar->WrapObject(cx, nullptr));
     return JS_DefineProperty(cx, obj, "rtcIdentityProvider", wrapped, JSPROP_ENUMERATE);
 }
+#endif
 
 static bool
 SetFetchRequestFromValue(JSContext *cx, RequestOrUSVString& request,
                          const MutableHandleValue& requestOrUrl)
 {
     RequestOrUSVStringArgument requestHolder(request);
     bool noMatch = true;
     if (requestOrUrl.isObject() &&
@@ -893,18 +897,20 @@ xpc::GlobalProperties::Parse(JSContext* 
         } else if (!strcmp(name.ptr(), "btoa")) {
             btoa = true;
         } else if (!strcmp(name.ptr(), "Blob")) {
             Blob = true;
         } else if (!strcmp(name.ptr(), "File")) {
             File = true;
         } else if (!strcmp(name.ptr(), "crypto")) {
             crypto = true;
+#ifdef MOZ_WEBRTC
         } else if (!strcmp(name.ptr(), "rtcIdentityProvider")) {
             rtcIdentityProvider = true;
+#endif
         } else if (!strcmp(name.ptr(), "fetch")) {
             fetch = true;
         } else {
             JS_ReportError(cx, "Unknown property name: %s", name.ptr());
             return false;
         }
     }
     return true;
@@ -954,18 +960,20 @@ xpc::GlobalProperties::Define(JSContext*
 
     if (File &&
         !dom::FileBinding::GetConstructorObject(cx, obj))
         return false;
 
     if (crypto && !SandboxCreateCrypto(cx, obj))
         return false;
 
+#ifdef MOZ_WEBRTC
     if (rtcIdentityProvider && !SandboxCreateRTCIdentityProvider(cx, obj))
         return false;
+#endif
 
     if (fetch && !SandboxCreateFetch(cx, obj))
         return false;
 
     return true;
 }
 
 nsresult