media/webrtc/signaling/test/FakePCObserver.h

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
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 #ifndef TEST_PCOBSERVER_H_
michael@0 6 #define TEST_PCOBSERVER_H_
michael@0 7
michael@0 8 #include "nsNetCID.h"
michael@0 9 #include "nsITimer.h"
michael@0 10 #include "nsComponentManagerUtils.h"
michael@0 11 #include "nsIComponentManager.h"
michael@0 12 #include "nsIComponentRegistrar.h"
michael@0 13
michael@0 14 #include "mozilla/Mutex.h"
michael@0 15 #include "AudioSegment.h"
michael@0 16 #include "MediaSegment.h"
michael@0 17 #include "StreamBuffer.h"
michael@0 18 #include "nsTArray.h"
michael@0 19 #include "nsIRunnable.h"
michael@0 20 #include "nsISupportsImpl.h"
michael@0 21 #include "nsIDOMMediaStream.h"
michael@0 22 #include "mozilla/dom/PeerConnectionObserverEnumsBinding.h"
michael@0 23 #include "PeerConnectionImpl.h"
michael@0 24 #include "nsWeakReference.h"
michael@0 25
michael@0 26 namespace sipcc {
michael@0 27 class PeerConnectionImpl;
michael@0 28 }
michael@0 29
michael@0 30 class nsIDOMWindow;
michael@0 31 class nsIDOMDataChannel;
michael@0 32
michael@0 33 namespace test {
michael@0 34
michael@0 35 class AFakePCObserver : public nsSupportsWeakReference
michael@0 36 {
michael@0 37 protected:
michael@0 38 typedef mozilla::ErrorResult ER;
michael@0 39 public:
michael@0 40 enum Action {
michael@0 41 OFFER,
michael@0 42 ANSWER
michael@0 43 };
michael@0 44
michael@0 45 enum ResponseState {
michael@0 46 stateNoResponse,
michael@0 47 stateSuccess,
michael@0 48 stateError
michael@0 49 };
michael@0 50
michael@0 51 AFakePCObserver(sipcc::PeerConnectionImpl *peerConnection,
michael@0 52 const std::string &aName) :
michael@0 53 state(stateNoResponse), addIceSuccessCount(0),
michael@0 54 onAddStreamCalled(false),
michael@0 55 name(aName),
michael@0 56 pc(peerConnection) {
michael@0 57 }
michael@0 58
michael@0 59 virtual ~AFakePCObserver() {}
michael@0 60
michael@0 61 std::vector<mozilla::DOMMediaStream *> GetStreams() { return streams; }
michael@0 62
michael@0 63 ResponseState state;
michael@0 64 char *lastString;
michael@0 65 sipcc::PeerConnectionImpl::Error lastStatusCode;
michael@0 66 mozilla::dom::PCObserverStateType lastStateType;
michael@0 67 int addIceSuccessCount;
michael@0 68 bool onAddStreamCalled;
michael@0 69 std::string name;
michael@0 70 std::vector<std::string> candidates;
michael@0 71
michael@0 72 virtual NS_IMETHODIMP OnCreateOfferSuccess(const char* offer, ER&) = 0;
michael@0 73 virtual NS_IMETHODIMP OnCreateOfferError(uint32_t code, const char *msg, ER&) = 0;
michael@0 74 virtual NS_IMETHODIMP OnCreateAnswerSuccess(const char* answer, ER&) = 0;
michael@0 75 virtual NS_IMETHODIMP OnCreateAnswerError(uint32_t code, const char *msg, ER&) = 0;
michael@0 76 virtual NS_IMETHODIMP OnSetLocalDescriptionSuccess(ER&) = 0;
michael@0 77 virtual NS_IMETHODIMP OnSetRemoteDescriptionSuccess(ER&) = 0;
michael@0 78 virtual NS_IMETHODIMP OnSetLocalDescriptionError(uint32_t code, const char *msg, ER&) = 0;
michael@0 79 virtual NS_IMETHODIMP OnSetRemoteDescriptionError(uint32_t code, const char *msg, ER&) = 0;
michael@0 80 virtual NS_IMETHODIMP NotifyConnection(ER&) = 0;
michael@0 81 virtual NS_IMETHODIMP NotifyClosedConnection(ER&) = 0;
michael@0 82 virtual NS_IMETHODIMP NotifyDataChannel(nsIDOMDataChannel *channel, ER&) = 0;
michael@0 83 virtual NS_IMETHODIMP OnStateChange(mozilla::dom::PCObserverStateType state_type, ER&,
michael@0 84 void* = nullptr) = 0;
michael@0 85 virtual NS_IMETHODIMP OnAddStream(nsIDOMMediaStream *stream, ER&) = 0;
michael@0 86 virtual NS_IMETHODIMP OnRemoveStream(ER&) = 0;
michael@0 87 virtual NS_IMETHODIMP OnAddTrack(ER&) = 0;
michael@0 88 virtual NS_IMETHODIMP OnRemoveTrack(ER&) = 0;
michael@0 89 virtual NS_IMETHODIMP OnAddIceCandidateSuccess(ER&) = 0;
michael@0 90 virtual NS_IMETHODIMP OnAddIceCandidateError(uint32_t code, const char *msg, ER&) = 0;
michael@0 91 virtual NS_IMETHODIMP OnIceCandidate(uint16_t level, const char *mid,
michael@0 92 const char *candidate, ER&) = 0;
michael@0 93 protected:
michael@0 94 sipcc::PeerConnectionImpl *pc;
michael@0 95 std::vector<mozilla::DOMMediaStream *> streams;
michael@0 96 };
michael@0 97 }
michael@0 98
michael@0 99 namespace mozilla {
michael@0 100 namespace dom {
michael@0 101 typedef test::AFakePCObserver PeerConnectionObserver;
michael@0 102 }
michael@0 103 }
michael@0 104
michael@0 105 #endif

mercurial