content/media/mediasource/MediaSource.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef mozilla_dom_MediaSource_h_
michael@0 8 #define mozilla_dom_MediaSource_h_
michael@0 9
michael@0 10 #include "MediaSourceDecoder.h"
michael@0 11 #include "js/RootingAPI.h"
michael@0 12 #include "mozilla/Assertions.h"
michael@0 13 #include "mozilla/Attributes.h"
michael@0 14 #include "mozilla/DOMEventTargetHelper.h"
michael@0 15 #include "mozilla/dom/MediaSourceBinding.h"
michael@0 16 #include "nsAutoPtr.h"
michael@0 17 #include "nsCOMPtr.h"
michael@0 18 #include "nsCycleCollectionNoteChild.h"
michael@0 19 #include "nsCycleCollectionParticipant.h"
michael@0 20 #include "nsID.h"
michael@0 21 #include "nsISupports.h"
michael@0 22 #include "nscore.h"
michael@0 23
michael@0 24 struct JSContext;
michael@0 25 class JSObject;
michael@0 26 class nsPIDOMWindow;
michael@0 27
michael@0 28 namespace mozilla {
michael@0 29
michael@0 30 class ErrorResult;
michael@0 31 template <typename T> class AsyncEventRunner;
michael@0 32
michael@0 33 namespace dom {
michael@0 34
michael@0 35 class GlobalObject;
michael@0 36 class SourceBuffer;
michael@0 37 class SourceBufferList;
michael@0 38 template <typename T> class Optional;
michael@0 39
michael@0 40 #define MOZILLA_DOM_MEDIASOURCE_IMPLEMENTATION_IID \
michael@0 41 { 0x3839d699, 0x22c5, 0x439f, \
michael@0 42 { 0x94, 0xca, 0x0e, 0x0b, 0x26, 0xf9, 0xca, 0xbf } }
michael@0 43
michael@0 44 class MediaSource MOZ_FINAL : public DOMEventTargetHelper
michael@0 45 {
michael@0 46 public:
michael@0 47 /** WebIDL Methods. */
michael@0 48 static already_AddRefed<MediaSource>
michael@0 49 Constructor(const GlobalObject& aGlobal,
michael@0 50 ErrorResult& aRv);
michael@0 51
michael@0 52 SourceBufferList* SourceBuffers();
michael@0 53 SourceBufferList* ActiveSourceBuffers();
michael@0 54 MediaSourceReadyState ReadyState();
michael@0 55
michael@0 56 double Duration();
michael@0 57 void SetDuration(double aDuration, ErrorResult& aRv);
michael@0 58
michael@0 59 already_AddRefed<SourceBuffer> AddSourceBuffer(const nsAString& aType, ErrorResult& aRv);
michael@0 60 void RemoveSourceBuffer(SourceBuffer& aSourceBuffer, ErrorResult& aRv);
michael@0 61
michael@0 62 void EndOfStream(const Optional<MediaSourceEndOfStreamError>& aError, ErrorResult& aRv);
michael@0 63 static bool IsTypeSupported(const GlobalObject&, const nsAString& aType);
michael@0 64 /** End WebIDL Methods. */
michael@0 65
michael@0 66 NS_DECL_ISUPPORTS_INHERITED
michael@0 67 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MediaSource, DOMEventTargetHelper)
michael@0 68 NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_DOM_MEDIASOURCE_IMPLEMENTATION_IID)
michael@0 69
michael@0 70 nsPIDOMWindow* GetParentObject() const;
michael@0 71
michael@0 72 JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
michael@0 73
michael@0 74 // Attach this MediaSource to Decoder aDecoder. Returns false if already attached.
michael@0 75 bool Attach(MediaSourceDecoder* aDecoder);
michael@0 76 void Detach();
michael@0 77
michael@0 78 // Set mReadyState to aState and fire the required events at the MediaSource.
michael@0 79 void SetReadyState(MediaSourceReadyState aState);
michael@0 80
michael@0 81 // Used by SourceBuffer to call CreateSubDecoder.
michael@0 82 MediaSourceDecoder* GetDecoder()
michael@0 83 {
michael@0 84 return mDecoder;
michael@0 85 }
michael@0 86
michael@0 87 // Called by SourceBuffers to notify this MediaSource that data has
michael@0 88 // been evicted from the buffered data. The start and end times
michael@0 89 // that were evicted are provided.
michael@0 90 void NotifyEvicted(double aStart, double aEnd);
michael@0 91
michael@0 92 private:
michael@0 93 explicit MediaSource(nsPIDOMWindow* aWindow);
michael@0 94
michael@0 95 friend class AsyncEventRunner<MediaSource>;
michael@0 96 void DispatchSimpleEvent(const char* aName);
michael@0 97 void QueueAsyncSimpleEvent(const char* aName);
michael@0 98
michael@0 99 void DurationChange(double aNewDuration, ErrorResult& aRv);
michael@0 100
michael@0 101 double mDuration;
michael@0 102
michael@0 103 nsRefPtr<SourceBufferList> mSourceBuffers;
michael@0 104 nsRefPtr<SourceBufferList> mActiveSourceBuffers;
michael@0 105
michael@0 106 nsRefPtr<MediaSourceDecoder> mDecoder;
michael@0 107
michael@0 108 MediaSourceReadyState mReadyState;
michael@0 109 };
michael@0 110
michael@0 111 NS_DEFINE_STATIC_IID_ACCESSOR(MediaSource, MOZILLA_DOM_MEDIASOURCE_IMPLEMENTATION_IID)
michael@0 112
michael@0 113 } // namespace dom
michael@0 114
michael@0 115 } // namespace mozilla
michael@0 116 #endif /* mozilla_dom_MediaSource_h_ */

mercurial