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.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     3  * You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #ifndef TEST_PCOBSERVER_H_
     6 #define TEST_PCOBSERVER_H_
     8 #include "nsNetCID.h"
     9 #include "nsITimer.h"
    10 #include "nsComponentManagerUtils.h"
    11 #include "nsIComponentManager.h"
    12 #include "nsIComponentRegistrar.h"
    14 #include "mozilla/Mutex.h"
    15 #include "AudioSegment.h"
    16 #include "MediaSegment.h"
    17 #include "StreamBuffer.h"
    18 #include "nsTArray.h"
    19 #include "nsIRunnable.h"
    20 #include "nsISupportsImpl.h"
    21 #include "nsIDOMMediaStream.h"
    22 #include "mozilla/dom/PeerConnectionObserverEnumsBinding.h"
    23 #include "PeerConnectionImpl.h"
    24 #include "nsWeakReference.h"
    26 namespace sipcc {
    27 class PeerConnectionImpl;
    28 }
    30 class nsIDOMWindow;
    31 class nsIDOMDataChannel;
    33 namespace test {
    35 class AFakePCObserver : public nsSupportsWeakReference
    36 {
    37 protected:
    38   typedef mozilla::ErrorResult ER;
    39 public:
    40   enum Action {
    41     OFFER,
    42     ANSWER
    43   };
    45   enum ResponseState {
    46     stateNoResponse,
    47     stateSuccess,
    48     stateError
    49   };
    51   AFakePCObserver(sipcc::PeerConnectionImpl *peerConnection,
    52                   const std::string &aName) :
    53     state(stateNoResponse), addIceSuccessCount(0),
    54     onAddStreamCalled(false),
    55     name(aName),
    56     pc(peerConnection) {
    57   }
    59   virtual ~AFakePCObserver() {}
    61   std::vector<mozilla::DOMMediaStream *> GetStreams() { return streams; }
    63   ResponseState state;
    64   char *lastString;
    65   sipcc::PeerConnectionImpl::Error lastStatusCode;
    66   mozilla::dom::PCObserverStateType lastStateType;
    67   int addIceSuccessCount;
    68   bool onAddStreamCalled;
    69   std::string name;
    70   std::vector<std::string> candidates;
    72   virtual NS_IMETHODIMP OnCreateOfferSuccess(const char* offer, ER&) = 0;
    73   virtual NS_IMETHODIMP OnCreateOfferError(uint32_t code, const char *msg, ER&) = 0;
    74   virtual NS_IMETHODIMP OnCreateAnswerSuccess(const char* answer, ER&) = 0;
    75   virtual NS_IMETHODIMP OnCreateAnswerError(uint32_t code, const char *msg, ER&) = 0;
    76   virtual NS_IMETHODIMP OnSetLocalDescriptionSuccess(ER&) = 0;
    77   virtual NS_IMETHODIMP OnSetRemoteDescriptionSuccess(ER&) = 0;
    78   virtual NS_IMETHODIMP OnSetLocalDescriptionError(uint32_t code, const char *msg, ER&) = 0;
    79   virtual NS_IMETHODIMP OnSetRemoteDescriptionError(uint32_t code, const char *msg, ER&) = 0;
    80   virtual NS_IMETHODIMP NotifyConnection(ER&) = 0;
    81   virtual NS_IMETHODIMP NotifyClosedConnection(ER&) = 0;
    82   virtual NS_IMETHODIMP NotifyDataChannel(nsIDOMDataChannel *channel, ER&) = 0;
    83   virtual NS_IMETHODIMP OnStateChange(mozilla::dom::PCObserverStateType state_type, ER&,
    84                                       void* = nullptr) = 0;
    85   virtual NS_IMETHODIMP OnAddStream(nsIDOMMediaStream *stream, ER&) = 0;
    86   virtual NS_IMETHODIMP OnRemoveStream(ER&) = 0;
    87   virtual NS_IMETHODIMP OnAddTrack(ER&) = 0;
    88   virtual NS_IMETHODIMP OnRemoveTrack(ER&) = 0;
    89   virtual NS_IMETHODIMP OnAddIceCandidateSuccess(ER&) = 0;
    90   virtual NS_IMETHODIMP OnAddIceCandidateError(uint32_t code, const char *msg, ER&) = 0;
    91   virtual NS_IMETHODIMP OnIceCandidate(uint16_t level, const char *mid,
    92                                        const char *candidate, ER&) = 0;
    93 protected:
    94   sipcc::PeerConnectionImpl *pc;
    95   std::vector<mozilla::DOMMediaStream *> streams;
    96 };
    97 }
    99 namespace mozilla {
   100 namespace dom {
   101 typedef test::AFakePCObserver PeerConnectionObserver;
   102 }
   103 }
   105 #endif

mercurial