LCOV - code coverage report
Current view: top level - js/ipc - JavaScriptChild.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 14 42 33.3 %
Date: 2017-07-14 16:53:18 Functions: 3 12 25.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
       2             :  * vim: set ts=4 sw=4 et tw=80:
       3             :  *
       4             :  * This Source Code Form is subject to the terms of the Mozilla Public
       5             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       6             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       7             : 
       8             : #include "JavaScriptChild.h"
       9             : #include "mozilla/dom/ContentChild.h"
      10             : #include "mozilla/dom/BindingUtils.h"
      11             : #include "mozilla/ipc/MessageChannel.h"
      12             : #include "nsContentUtils.h"
      13             : #include "xpcprivate.h"
      14             : #include "jsfriendapi.h"
      15             : #include "AccessCheck.h"
      16             : 
      17             : using namespace JS;
      18             : using namespace mozilla;
      19             : using namespace mozilla::jsipc;
      20             : 
      21             : using mozilla::AutoSafeJSContext;
      22             : 
      23             : static void
      24           0 : UpdateChildWeakPointersBeforeSweepingZoneGroup(JSContext* cx, void* data)
      25             : {
      26           0 :     static_cast<JavaScriptChild*>(data)->updateWeakPointers();
      27           0 : }
      28             : 
      29             : static void
      30           0 : TraceChild(JSTracer* trc, void* data)
      31             : {
      32           0 :     static_cast<JavaScriptChild*>(data)->trace(trc);
      33           0 : }
      34             : 
      35           0 : JavaScriptChild::~JavaScriptChild()
      36             : {
      37           0 :     JSContext* cx = dom::danger::GetJSContext();
      38           0 :     JS_RemoveWeakPointerZonesCallback(cx, UpdateChildWeakPointersBeforeSweepingZoneGroup);
      39           0 :     JS_RemoveExtraGCRootsTracer(cx, TraceChild, this);
      40           0 : }
      41             : 
      42             : bool
      43           2 : JavaScriptChild::init()
      44             : {
      45           2 :     if (!WrapperOwner::init())
      46           0 :         return false;
      47           2 :     if (!WrapperAnswer::init())
      48           0 :         return false;
      49             : 
      50           2 :     JSContext* cx = dom::danger::GetJSContext();
      51           2 :     JS_AddWeakPointerZonesCallback(cx, UpdateChildWeakPointersBeforeSweepingZoneGroup, this);
      52           2 :     JS_AddExtraGCRootsTracer(cx, TraceChild, this);
      53           2 :     return true;
      54             : }
      55             : 
      56             : void
      57           0 : JavaScriptChild::trace(JSTracer* trc)
      58             : {
      59           0 :     objects_.trace(trc, strongReferenceObjIdMinimum_);
      60           0 : }
      61             : 
      62             : void
      63           0 : JavaScriptChild::updateWeakPointers()
      64             : {
      65           0 :     objects_.sweep();
      66           0 :     unwaivedObjectIds_.sweep();
      67           0 :     waivedObjectIds_.sweep();
      68           0 : }
      69             : 
      70             : JSObject*
      71           0 : JavaScriptChild::scopeForTargetObjects()
      72             : {
      73             :     // CPOWs from the parent need to point into the child's privileged junk
      74             :     // scope so that they can benefit from XrayWrappers in the child.
      75           0 :     return xpc::PrivilegedJunkScope();
      76             : }
      77             : 
      78             : mozilla::ipc::IPCResult
      79           3 : JavaScriptChild::RecvDropTemporaryStrongReferences(const uint64_t& upToObjId)
      80             : {
      81           3 :     strongReferenceObjIdMinimum_ = upToObjId + 1;
      82           3 :     return IPC_OK();
      83             : }
      84             : 
      85             : PJavaScriptChild*
      86           2 : mozilla::jsipc::NewJavaScriptChild()
      87             : {
      88           2 :     JavaScriptChild* child = new JavaScriptChild();
      89           2 :     if (!child->init()) {
      90           0 :         delete child;
      91           0 :         return nullptr;
      92             :     }
      93           2 :     return child;
      94             : }
      95             : 
      96             : void
      97           0 : mozilla::jsipc::ReleaseJavaScriptChild(PJavaScriptChild* child)
      98             : {
      99           0 :     static_cast<JavaScriptChild*>(child)->decref();
     100           0 : }

Generated by: LCOV version 1.13