dom/camera/DOMCameraDetectedFace.cpp

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.

     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 #include "DOMCameraDetectedFace.h"
     6 #include "Navigator.h"
     8 using namespace mozilla;
     9 using namespace mozilla::dom;
    11 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(DOMCameraPoint, mParent)
    13 NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMCameraPoint)
    14 NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMCameraPoint)
    15 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMCameraPoint)
    16   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
    17   NS_INTERFACE_MAP_ENTRY(nsISupports)
    18 NS_INTERFACE_MAP_END
    20 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_5(DOMCameraDetectedFace, mParent,
    21                                         mBounds, mLeftEye, mRightEye, mMouth)
    23 NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMCameraDetectedFace)
    24 NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMCameraDetectedFace)
    25 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMCameraDetectedFace)
    26   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
    27   NS_INTERFACE_MAP_ENTRY(nsISupports)
    28 NS_INTERFACE_MAP_END
    30 /* static */
    31 bool
    32 DOMCameraPoint::HasSupport(JSContext* aCx, JSObject* aGlobal)
    33 {
    34   return Navigator::HasCameraSupport(aCx, aGlobal);
    35 }
    37 /* static */
    38 bool
    39 DOMCameraDetectedFace::HasSupport(JSContext* aCx, JSObject* aGlobal)
    40 {
    41   return Navigator::HasCameraSupport(aCx, aGlobal);
    42 }
    44 JSObject*
    45 DOMCameraPoint::WrapObject(JSContext* aCx)
    46 {
    47   return CameraPointBinding::Wrap(aCx, this);
    48 }
    50 JSObject*
    51 DOMCameraDetectedFace::WrapObject(JSContext* aCx)
    52 {
    53   return CameraDetectedFaceBinding::Wrap(aCx, this);
    54 }
    56 DOMCameraDetectedFace::DOMCameraDetectedFace(nsISupports* aParent,
    57                                              const ICameraControl::Face& aFace)
    58   : mParent(aParent)
    59   , mId(aFace.id)
    60   , mScore(aFace.score)
    61   , mBounds(new DOMRect(MOZ_THIS_IN_INITIALIZER_LIST()))
    62 {
    63   mBounds->SetRect(aFace.bound.left,
    64                    aFace.bound.top,
    65                    aFace.bound.right - aFace.bound.left,
    66                    aFace.bound.bottom - aFace.bound.top);
    68   if (aFace.hasLeftEye) {
    69     mLeftEye = new DOMCameraPoint(this, aFace.leftEye);
    70   }
    71   if (aFace.hasRightEye) {
    72     mRightEye = new DOMCameraPoint(this, aFace.rightEye);
    73   }
    74   if (aFace.hasMouth) {
    75     mMouth = new DOMCameraPoint(this, aFace.mouth);
    76   }
    78   SetIsDOMBinding();
    79 }

mercurial