KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17
System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64
User : nobody ( 99)
PHP Version : 5.2.17
Disable Function : NONE
Directory :  /proc/21573/root/usr/include/xulrunner-17.0.10/mozilla/jsipc/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/21573/root/usr/include/xulrunner-17.0.10/mozilla/jsipc/ContextWrapperParent.h
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 * vim: set ts=8 sw=4 et tw=80:
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef mozilla_jsipc_ContextWrapperParent_h__
#define mozilla_jsipc_ContextWrapperParent_h__

#include "mozilla/jsipc/PContextWrapperParent.h"
#include "mozilla/jsipc/ObjectWrapperParent.h"
#include "mozilla/jsipc/CPOWTypes.h"

#include "mozilla/dom/ContentParent.h"

#include "jsapi.h"
#include "nsAutoJSValHolder.h"

namespace mozilla {
namespace jsipc {

using mozilla::dom::ContentParent;
    
class ContextWrapperParent
    : public PContextWrapperParent
{
public:

    ContextWrapperParent(ContentParent* cpp)
        : mContent(cpp)
        , mGlobal(NULL)
    {}

    JSBool GetGlobalJSObject(JSContext* cx, JSObject** globalp) {
        if (!mGlobal)
            return JS_FALSE;
        mGlobalHolder.Hold(cx);
        mGlobalHolder = *globalp = mGlobal->GetJSObject(cx);
        return JS_TRUE;
    }

    ObjectWrapperParent* GetGlobalObjectWrapper() const {
        return mGlobal;
    }

    bool RequestRunToCompletion() {
        return mContent->RequestRunToCompletion();
    }

private:

    ContentParent* mContent;
    ObjectWrapperParent* mGlobal;
    nsAutoJSValHolder mGlobalHolder;

    PObjectWrapperParent* AllocPObjectWrapper(const bool&) {
        return new ObjectWrapperParent();
    }

    bool RecvPObjectWrapperConstructor(PObjectWrapperParent* actor,
                                       const bool& makeGlobal)
    {
        if (makeGlobal) {
            mGlobalHolder.Release();
            mGlobal = static_cast<ObjectWrapperParent*>(actor);
        }
        return true;
    }

    bool DeallocPObjectWrapper(PObjectWrapperParent* actor)
    {
        if (mGlobal &&
            mGlobal == static_cast<ObjectWrapperParent*>(actor)) {
            mGlobalHolder.Release();
            mGlobal = NULL;
        }
        delete actor;
        return true;
    }

};

}}

#endif

Anon7 - 2021