Bug 1208371 - Add CORSMode methods to MediaStreamTrack. r?mt
MozReview-Commit-ID: 5vYHjdDHDSn
--- a/dom/media/MediaStreamTrack.h
+++ b/dom/media/MediaStreamTrack.h
@@ -6,16 +6,17 @@
#ifndef MEDIASTREAMTRACK_H_
#define MEDIASTREAMTRACK_H_
#include "mozilla/DOMEventTargetHelper.h"
#include "nsError.h"
#include "nsID.h"
#include "StreamBuffer.h"
#include "MediaTrackConstraints.h"
+#include "mozilla/CORSMode.h"
#include "PrincipalChangeObserver.h"
namespace mozilla {
class DOMMediaStream;
class MediaEnginePhotoCallback;
class MediaStream;
class MediaStreamGraph;
@@ -62,16 +63,23 @@ public:
virtual MediaSourceEnum GetMediaSource() const = 0;
/**
* Get this TrackSource's principal.
*/
nsIPrincipal* GetPrincipal() const { return mPrincipal; }
/**
+ * Get the source's current CORSMode. If not applicable CORS_NONE is returned.
+ * The sink will be notified of changes to our CORSMode through
+ * NotifyPrincipalChanged().
+ */
+ virtual CORSMode GetCORSMode() const { return CORS_NONE; }
+
+ /**
* Indicates whether the track is remote or not per the MediaCapture and
* Streams spec.
*/
virtual bool IsRemote() const { return mIsRemote; }
/**
* Forwards a photo request to backends that support it. Other backends return
* NS_ERROR_NOT_IMPLEMENTED to indicate that a MediaStreamGraph-based fallback
@@ -221,16 +229,21 @@ public:
// Notifications from the MediaStreamGraph
void NotifyEnded() { mEnded = true; }
/**
* Get this track's principal.
*/
nsIPrincipal* GetPrincipal() const { return GetSource().GetPrincipal(); }
+ /**
+ * Get this track's CORS mode.
+ */
+ CORSMode GetCORSMode() const { return GetSource().GetCORSMode(); }
+
MediaStreamGraph* Graph();
MediaStreamTrackSource& GetSource() const
{
MOZ_RELEASE_ASSERT(mSource, "The track source is only removed on destruction");
return *mSource;
}