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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 3 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #include "SpeechSynthesisChild.h" |
michael@0 | 6 | #include "nsSynthVoiceRegistry.h" |
michael@0 | 7 | |
michael@0 | 8 | namespace mozilla { |
michael@0 | 9 | namespace dom { |
michael@0 | 10 | |
michael@0 | 11 | SpeechSynthesisChild::SpeechSynthesisChild() |
michael@0 | 12 | { |
michael@0 | 13 | MOZ_COUNT_CTOR(SpeechSynthesisChild); |
michael@0 | 14 | } |
michael@0 | 15 | |
michael@0 | 16 | SpeechSynthesisChild::~SpeechSynthesisChild() |
michael@0 | 17 | { |
michael@0 | 18 | MOZ_COUNT_DTOR(SpeechSynthesisChild); |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | bool |
michael@0 | 22 | SpeechSynthesisChild::RecvVoiceAdded(const RemoteVoice& aVoice) |
michael@0 | 23 | { |
michael@0 | 24 | nsSynthVoiceRegistry::RecvAddVoice(aVoice); |
michael@0 | 25 | return true; |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | bool |
michael@0 | 29 | SpeechSynthesisChild::RecvVoiceRemoved(const nsString& aUri) |
michael@0 | 30 | { |
michael@0 | 31 | nsSynthVoiceRegistry::RecvRemoveVoice(aUri); |
michael@0 | 32 | return true; |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | bool |
michael@0 | 36 | SpeechSynthesisChild::RecvSetDefaultVoice(const nsString& aUri, |
michael@0 | 37 | const bool& aIsDefault) |
michael@0 | 38 | { |
michael@0 | 39 | nsSynthVoiceRegistry::RecvSetDefaultVoice(aUri, aIsDefault); |
michael@0 | 40 | return true; |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | PSpeechSynthesisRequestChild* |
michael@0 | 44 | SpeechSynthesisChild::AllocPSpeechSynthesisRequestChild(const nsString& aText, |
michael@0 | 45 | const nsString& aLang, |
michael@0 | 46 | const nsString& aUri, |
michael@0 | 47 | const float& aVolume, |
michael@0 | 48 | const float& aRate, |
michael@0 | 49 | const float& aPitch) |
michael@0 | 50 | { |
michael@0 | 51 | MOZ_CRASH("Caller is supposed to manually construct a request!"); |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | bool |
michael@0 | 55 | SpeechSynthesisChild::DeallocPSpeechSynthesisRequestChild(PSpeechSynthesisRequestChild* aActor) |
michael@0 | 56 | { |
michael@0 | 57 | delete aActor; |
michael@0 | 58 | return true; |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | // SpeechSynthesisRequestChild |
michael@0 | 62 | |
michael@0 | 63 | SpeechSynthesisRequestChild::SpeechSynthesisRequestChild(SpeechTaskChild* aTask) |
michael@0 | 64 | : mTask(aTask) |
michael@0 | 65 | { |
michael@0 | 66 | mTask->mActor = this; |
michael@0 | 67 | MOZ_COUNT_CTOR(SpeechSynthesisRequestChild); |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | SpeechSynthesisRequestChild::~SpeechSynthesisRequestChild() |
michael@0 | 71 | { |
michael@0 | 72 | MOZ_COUNT_DTOR(SpeechSynthesisRequestChild); |
michael@0 | 73 | } |
michael@0 | 74 | |
michael@0 | 75 | bool |
michael@0 | 76 | SpeechSynthesisRequestChild::RecvOnStart() |
michael@0 | 77 | { |
michael@0 | 78 | mTask->DispatchStartImpl(); |
michael@0 | 79 | return true; |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | bool |
michael@0 | 83 | SpeechSynthesisRequestChild::Recv__delete__(const bool& aIsError, |
michael@0 | 84 | const float& aElapsedTime, |
michael@0 | 85 | const uint32_t& aCharIndex) |
michael@0 | 86 | { |
michael@0 | 87 | mTask->mActor = nullptr; |
michael@0 | 88 | |
michael@0 | 89 | if (aIsError) { |
michael@0 | 90 | mTask->DispatchErrorImpl(aElapsedTime, aCharIndex); |
michael@0 | 91 | } else { |
michael@0 | 92 | mTask->DispatchEndImpl(aElapsedTime, aCharIndex); |
michael@0 | 93 | } |
michael@0 | 94 | |
michael@0 | 95 | return true; |
michael@0 | 96 | } |
michael@0 | 97 | |
michael@0 | 98 | bool |
michael@0 | 99 | SpeechSynthesisRequestChild::RecvOnPause(const float& aElapsedTime, |
michael@0 | 100 | const uint32_t& aCharIndex) |
michael@0 | 101 | { |
michael@0 | 102 | mTask->DispatchPauseImpl(aElapsedTime, aCharIndex); |
michael@0 | 103 | return true; |
michael@0 | 104 | } |
michael@0 | 105 | |
michael@0 | 106 | bool |
michael@0 | 107 | SpeechSynthesisRequestChild::RecvOnResume(const float& aElapsedTime, |
michael@0 | 108 | const uint32_t& aCharIndex) |
michael@0 | 109 | { |
michael@0 | 110 | mTask->DispatchResumeImpl(aElapsedTime, aCharIndex); |
michael@0 | 111 | return true; |
michael@0 | 112 | } |
michael@0 | 113 | |
michael@0 | 114 | bool |
michael@0 | 115 | SpeechSynthesisRequestChild::RecvOnBoundary(const nsString& aName, |
michael@0 | 116 | const float& aElapsedTime, |
michael@0 | 117 | const uint32_t& aCharIndex) |
michael@0 | 118 | { |
michael@0 | 119 | mTask->DispatchBoundaryImpl(aName, aElapsedTime, aCharIndex); |
michael@0 | 120 | return true; |
michael@0 | 121 | } |
michael@0 | 122 | |
michael@0 | 123 | bool |
michael@0 | 124 | SpeechSynthesisRequestChild::RecvOnMark(const nsString& aName, |
michael@0 | 125 | const float& aElapsedTime, |
michael@0 | 126 | const uint32_t& aCharIndex) |
michael@0 | 127 | { |
michael@0 | 128 | mTask->DispatchMarkImpl(aName, aElapsedTime, aCharIndex); |
michael@0 | 129 | return true; |
michael@0 | 130 | } |
michael@0 | 131 | |
michael@0 | 132 | // SpeechTaskChild |
michael@0 | 133 | |
michael@0 | 134 | SpeechTaskChild::SpeechTaskChild(SpeechSynthesisUtterance* aUtterance) |
michael@0 | 135 | : nsSpeechTask(aUtterance) |
michael@0 | 136 | { |
michael@0 | 137 | } |
michael@0 | 138 | |
michael@0 | 139 | NS_IMETHODIMP |
michael@0 | 140 | SpeechTaskChild::Setup(nsISpeechTaskCallback* aCallback, |
michael@0 | 141 | uint32_t aChannels, uint32_t aRate, uint8_t argc) |
michael@0 | 142 | { |
michael@0 | 143 | MOZ_CRASH("Should never be called from child"); |
michael@0 | 144 | } |
michael@0 | 145 | |
michael@0 | 146 | NS_IMETHODIMP |
michael@0 | 147 | SpeechTaskChild::SendAudio(JS::Handle<JS::Value> aData, JS::Handle<JS::Value> aLandmarks, |
michael@0 | 148 | JSContext* aCx) |
michael@0 | 149 | { |
michael@0 | 150 | MOZ_CRASH("Should never be called from child"); |
michael@0 | 151 | } |
michael@0 | 152 | |
michael@0 | 153 | NS_IMETHODIMP |
michael@0 | 154 | SpeechTaskChild::SendAudioNative(int16_t* aData, uint32_t aDataLen) |
michael@0 | 155 | { |
michael@0 | 156 | MOZ_CRASH("Should never be called from child"); |
michael@0 | 157 | } |
michael@0 | 158 | |
michael@0 | 159 | void |
michael@0 | 160 | SpeechTaskChild::Pause() |
michael@0 | 161 | { |
michael@0 | 162 | MOZ_ASSERT(mActor); |
michael@0 | 163 | mActor->SendPause(); |
michael@0 | 164 | } |
michael@0 | 165 | |
michael@0 | 166 | void |
michael@0 | 167 | SpeechTaskChild::Resume() |
michael@0 | 168 | { |
michael@0 | 169 | MOZ_ASSERT(mActor); |
michael@0 | 170 | mActor->SendResume(); |
michael@0 | 171 | } |
michael@0 | 172 | |
michael@0 | 173 | void |
michael@0 | 174 | SpeechTaskChild::Cancel() |
michael@0 | 175 | { |
michael@0 | 176 | MOZ_ASSERT(mActor); |
michael@0 | 177 | mActor->SendCancel(); |
michael@0 | 178 | } |
michael@0 | 179 | |
michael@0 | 180 | } // namespace dom |
michael@0 | 181 | } // namespace mozilla |