content/media/webaudio/ScriptProcessorNode.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: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
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 ScriptProcessorNode_h_
michael@0 8 #define ScriptProcessorNode_h_
michael@0 9
michael@0 10 #include "AudioNode.h"
michael@0 11 #include "nsAutoPtr.h"
michael@0 12
michael@0 13 namespace mozilla {
michael@0 14 namespace dom {
michael@0 15
michael@0 16 class AudioContext;
michael@0 17 class SharedBuffers;
michael@0 18
michael@0 19 class ScriptProcessorNode : public AudioNode
michael@0 20 {
michael@0 21 public:
michael@0 22 ScriptProcessorNode(AudioContext* aContext,
michael@0 23 uint32_t aBufferSize,
michael@0 24 uint32_t aNumberOfInputChannels,
michael@0 25 uint32_t aNumberOfOutputChannels);
michael@0 26 virtual ~ScriptProcessorNode();
michael@0 27
michael@0 28 NS_DECL_ISUPPORTS_INHERITED
michael@0 29
michael@0 30 IMPL_EVENT_HANDLER(audioprocess)
michael@0 31
michael@0 32 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
michael@0 33
michael@0 34 virtual void Connect(AudioNode& aDestination, uint32_t aOutput,
michael@0 35 uint32_t aInput, ErrorResult& aRv) MOZ_OVERRIDE
michael@0 36 {
michael@0 37 AudioNode::Connect(aDestination, aOutput, aInput, aRv);
michael@0 38 if (!aRv.Failed()) {
michael@0 39 MarkActive();
michael@0 40 }
michael@0 41 }
michael@0 42
michael@0 43 virtual void Connect(AudioParam& aDestination, uint32_t aOutput,
michael@0 44 ErrorResult& aRv) MOZ_OVERRIDE
michael@0 45 {
michael@0 46 AudioNode::Connect(aDestination, aOutput, aRv);
michael@0 47 if (!aRv.Failed()) {
michael@0 48 MarkActive();
michael@0 49 }
michael@0 50 }
michael@0 51
michael@0 52 virtual void Disconnect(uint32_t aOutput, ErrorResult& aRv) MOZ_OVERRIDE
michael@0 53 {
michael@0 54 AudioNode::Disconnect(aOutput, aRv);
michael@0 55 if (!aRv.Failed() && OutputNodes().IsEmpty() && OutputParams().IsEmpty()) {
michael@0 56 MarkInactive();
michael@0 57 }
michael@0 58 }
michael@0 59
michael@0 60 virtual void SetChannelCount(uint32_t aChannelCount, ErrorResult& aRv) MOZ_OVERRIDE
michael@0 61 {
michael@0 62 if (aChannelCount != ChannelCount()) {
michael@0 63 aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
michael@0 64 }
michael@0 65 return;
michael@0 66 }
michael@0 67 virtual void SetChannelCountModeValue(ChannelCountMode aMode, ErrorResult& aRv) MOZ_OVERRIDE
michael@0 68 {
michael@0 69 if (aMode != ChannelCountMode::Explicit) {
michael@0 70 aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
michael@0 71 }
michael@0 72 return;
michael@0 73 }
michael@0 74
michael@0 75 uint32_t BufferSize() const
michael@0 76 {
michael@0 77 return mBufferSize;
michael@0 78 }
michael@0 79
michael@0 80 SharedBuffers* GetSharedBuffers() const
michael@0 81 {
michael@0 82 return mSharedBuffers;
michael@0 83 }
michael@0 84
michael@0 85 uint32_t NumberOfOutputChannels() const
michael@0 86 {
michael@0 87 return mNumberOfOutputChannels;
michael@0 88 }
michael@0 89
michael@0 90 using DOMEventTargetHelper::DispatchTrustedEvent;
michael@0 91
michael@0 92 virtual const char* NodeType() const
michael@0 93 {
michael@0 94 return "ScriptProcessorNode";
michael@0 95 }
michael@0 96
michael@0 97 virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
michael@0 98 virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
michael@0 99
michael@0 100 private:
michael@0 101 nsAutoPtr<SharedBuffers> mSharedBuffers;
michael@0 102 const uint32_t mBufferSize;
michael@0 103 const uint32_t mNumberOfOutputChannels;
michael@0 104 };
michael@0 105
michael@0 106 }
michael@0 107 }
michael@0 108
michael@0 109 #endif
michael@0 110

mercurial