Bug 1112761 part 1. Replace Pref="media.mediasource.enabled" annotations in IDL with calls to a function which will end up doing something a bit more interesting. r=kinetik a=mse
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 08 Jan 2015 11:57:10 -0500
changeset 242771 038ee1a68a543b359a2528a38f83a0a7cd6dfd85
parent 242770 2dbc61faf188c9eb55b08f87e32f3c0560a3e025
child 242772 f989781e9a2387d3c3fe752c27f380198a21f356
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik, mse
bugs1112761
milestone36.0a2
Bug 1112761 part 1. Replace Pref="media.mediasource.enabled" annotations in IDL with calls to a function which will end up doing something a bit more interesting. r=kinetik a=mse
dom/media/mediasource/MediaSource.cpp
dom/media/mediasource/MediaSource.h
dom/webidl/HTMLVideoElement.webidl
dom/webidl/MediaSource.webidl
dom/webidl/SourceBuffer.webidl
dom/webidl/SourceBufferList.webidl
dom/webidl/VideoPlaybackQuality.webidl
--- a/dom/media/mediasource/MediaSource.cpp
+++ b/dom/media/mediasource/MediaSource.cpp
@@ -301,16 +301,22 @@ MediaSource::IsTypeSupported(const Globa
 {
   MOZ_ASSERT(NS_IsMainThread());
   nsresult rv = mozilla::IsTypeSupported(aType);
   MSE_API("MediaSource::IsTypeSupported(aType=%s)%s",
           NS_ConvertUTF16toUTF8(aType).get(), rv == NS_OK ? "" : " [not supported]");
   return NS_SUCCEEDED(rv);
 }
 
+/* static */ bool
+MediaSource::Enabled(JSContext* cx, JSObject* aGlobal)
+{
+  return Preferences::GetBool("media.mediasource.enabled");
+}
+
 bool
 MediaSource::Attach(MediaSourceDecoder* aDecoder)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MSE_DEBUG("MediaSource(%p)::Attach(aDecoder=%p) owner=%p", this, aDecoder, aDecoder->GetOwner());
   MOZ_ASSERT(aDecoder);
   MOZ_ASSERT(aDecoder->GetOwner());
   if (mReadyState != MediaSourceReadyState::Closed) {
--- a/dom/media/mediasource/MediaSource.h
+++ b/dom/media/mediasource/MediaSource.h
@@ -55,16 +55,18 @@ public:
   double Duration();
   void SetDuration(double aDuration, ErrorResult& aRv);
 
   already_AddRefed<SourceBuffer> AddSourceBuffer(const nsAString& aType, ErrorResult& aRv);
   void RemoveSourceBuffer(SourceBuffer& aSourceBuffer, ErrorResult& aRv);
 
   void EndOfStream(const Optional<MediaSourceEndOfStreamError>& aError, ErrorResult& aRv);
   static bool IsTypeSupported(const GlobalObject&, const nsAString& aType);
+
+  static bool Enabled(JSContext* cx, JSObject* aGlobal);
   /** End WebIDL Methods. */
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MediaSource, DOMEventTargetHelper)
   NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_DOM_MEDIASOURCE_IMPLEMENTATION_IID)
 
   nsPIDOMWindow* GetParentObject() const;
 
--- a/dom/webidl/HTMLVideoElement.webidl
+++ b/dom/webidl/HTMLVideoElement.webidl
@@ -43,11 +43,11 @@ partial interface HTMLVideoElement {
   readonly attribute double mozFrameDelay;
 
   // True if the video has an audio track available.
   readonly attribute boolean mozHasAudio;
 };
 
 // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#idl-def-HTMLVideoElement
 partial interface HTMLVideoElement {
-  [Pref="media.mediasource.enabled", NewObject]
+  [Func="mozilla::dom::MediaSource::Enabled", NewObject]
   VideoPlaybackQuality getVideoPlaybackQuality();
 };
--- a/dom/webidl/MediaSource.webidl
+++ b/dom/webidl/MediaSource.webidl
@@ -16,17 +16,17 @@ enum MediaSourceReadyState {
   "ended"
 };
 
 enum MediaSourceEndOfStreamError {
   "network",
   "decode"
 };
 
-[Constructor, Pref="media.mediasource.enabled"]
+[Constructor, Func="mozilla::dom::MediaSource::Enabled"]
 interface MediaSource : EventTarget {
   readonly attribute SourceBufferList sourceBuffers;
   readonly attribute SourceBufferList activeSourceBuffers;
   readonly attribute MediaSourceReadyState readyState;
   [SetterThrows]
   attribute unrestricted double duration;
   [NewObject, Throws]
   SourceBuffer addSourceBuffer(DOMString type);
--- a/dom/webidl/SourceBuffer.webidl
+++ b/dom/webidl/SourceBuffer.webidl
@@ -10,17 +10,17 @@
  * liability, trademark and document use rules apply.
  */
 
 enum SourceBufferAppendMode {
     "segments",
     "sequence"
 };
 
-[Pref="media.mediasource.enabled"]
+[Func="mozilla::dom::MediaSource::Enabled"]
 interface SourceBuffer : EventTarget {
   [SetterThrows]
   attribute SourceBufferAppendMode mode;
   readonly attribute boolean updating;
   [NewObject, Throws]
   readonly attribute TimeRanges buffered;
   [SetterThrows]
   attribute double timestampOffset;
--- a/dom/webidl/SourceBufferList.webidl
+++ b/dom/webidl/SourceBufferList.webidl
@@ -5,13 +5,13 @@
  *
  * The origin of this IDL file is
  * http://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
-[Pref="media.mediasource.enabled"]
+[Func="mozilla::dom::MediaSource::Enabled"]
 interface SourceBufferList : EventTarget {
   readonly attribute unsigned long length;
   getter SourceBuffer (unsigned long index);
 };
--- a/dom/webidl/VideoPlaybackQuality.webidl
+++ b/dom/webidl/VideoPlaybackQuality.webidl
@@ -5,17 +5,17 @@
  *
  * The origin of this IDL file is
  * http://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
-[Pref="media.mediasource.enabled"]
+[Func="mozilla::dom::MediaSource::Enabled"]
 interface VideoPlaybackQuality {
   readonly attribute DOMHighResTimeStamp creationTime;
   readonly attribute unsigned long totalVideoFrames;
   readonly attribute unsigned long droppedVideoFrames;
   readonly attribute unsigned long corruptedVideoFrames;
 // At Risk: readonly attribute double totalFrameDelay;
 };