Tue, 06 Jan 2015 21:39:09 +0100
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_SourceBufferList_h_ |
michael@0 | 8 | #define mozilla_dom_SourceBufferList_h_ |
michael@0 | 9 | |
michael@0 | 10 | #include "SourceBuffer.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 "nsAutoPtr.h" |
michael@0 | 16 | #include "nsCycleCollectionNoteChild.h" |
michael@0 | 17 | #include "nsCycleCollectionParticipant.h" |
michael@0 | 18 | #include "nsISupports.h" |
michael@0 | 19 | #include "nsTArray.h" |
michael@0 | 20 | |
michael@0 | 21 | struct JSContext; |
michael@0 | 22 | class JSObject; |
michael@0 | 23 | |
michael@0 | 24 | namespace mozilla { |
michael@0 | 25 | |
michael@0 | 26 | class ErrorResult; |
michael@0 | 27 | template <typename T> class AsyncEventRunner; |
michael@0 | 28 | |
michael@0 | 29 | namespace dom { |
michael@0 | 30 | |
michael@0 | 31 | class MediaSource; |
michael@0 | 32 | |
michael@0 | 33 | class SourceBufferList MOZ_FINAL : public DOMEventTargetHelper |
michael@0 | 34 | { |
michael@0 | 35 | public: |
michael@0 | 36 | /** WebIDL Methods. */ |
michael@0 | 37 | SourceBuffer* IndexedGetter(uint32_t aIndex, bool& aFound); |
michael@0 | 38 | |
michael@0 | 39 | uint32_t Length(); |
michael@0 | 40 | /** End WebIDL methods. */ |
michael@0 | 41 | |
michael@0 | 42 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 43 | NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SourceBufferList, |
michael@0 | 44 | DOMEventTargetHelper) |
michael@0 | 45 | |
michael@0 | 46 | explicit SourceBufferList(MediaSource* aMediaSource); |
michael@0 | 47 | |
michael@0 | 48 | MediaSource* GetParentObject() const; |
michael@0 | 49 | |
michael@0 | 50 | JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
michael@0 | 51 | |
michael@0 | 52 | // Append a SourceBuffer and fire "addsourcebuffer" at the list. |
michael@0 | 53 | void Append(SourceBuffer* aSourceBuffer); |
michael@0 | 54 | |
michael@0 | 55 | // Remove a SourceBuffer and fire "removesourcebuffer" at the list. |
michael@0 | 56 | void Remove(SourceBuffer* aSourceBuffer); |
michael@0 | 57 | |
michael@0 | 58 | // Returns true if aSourceBuffer is present in the list. |
michael@0 | 59 | bool Contains(SourceBuffer* aSourceBuffer); |
michael@0 | 60 | |
michael@0 | 61 | // Remove all SourceBuffers and fire a single "removesourcebuffer" at the list. |
michael@0 | 62 | void Clear(); |
michael@0 | 63 | |
michael@0 | 64 | // True if list has zero entries. |
michael@0 | 65 | bool IsEmpty(); |
michael@0 | 66 | |
michael@0 | 67 | // Returns true if updating is true on any SourceBuffers in the list. |
michael@0 | 68 | bool AnyUpdating(); |
michael@0 | 69 | |
michael@0 | 70 | // Calls Remove(aStart, aEnd) on each SourceBuffer in the list. Aborts on |
michael@0 | 71 | // first error, with result returned in aRv. |
michael@0 | 72 | void Remove(double aStart, double aEnd, ErrorResult& aRv); |
michael@0 | 73 | |
michael@0 | 74 | // Mark all SourceBuffers input buffers as ended. |
michael@0 | 75 | void Ended(); |
michael@0 | 76 | |
michael@0 | 77 | // Evicts data for the given time range from each SourceBuffer in the list. |
michael@0 | 78 | void Evict(double aStart, double aEnd); |
michael@0 | 79 | |
michael@0 | 80 | // Returns true if all SourceBuffers in the list contain data for the given time. |
michael@0 | 81 | bool AllContainsTime(double aTime); |
michael@0 | 82 | |
michael@0 | 83 | private: |
michael@0 | 84 | friend class AsyncEventRunner<SourceBufferList>; |
michael@0 | 85 | void DispatchSimpleEvent(const char* aName); |
michael@0 | 86 | void QueueAsyncSimpleEvent(const char* aName); |
michael@0 | 87 | |
michael@0 | 88 | nsRefPtr<MediaSource> mMediaSource; |
michael@0 | 89 | nsTArray<nsRefPtr<SourceBuffer> > mSourceBuffers; |
michael@0 | 90 | }; |
michael@0 | 91 | |
michael@0 | 92 | } // namespace dom |
michael@0 | 93 | |
michael@0 | 94 | } // namespace mozilla |
michael@0 | 95 | #endif /* mozilla_dom_SourceBufferList_h_ */ |