Home | History | Annotate | Download | only in v8
      1 /*
      2  * Copyright (C) 2003, 2006 Apple Computer, Inc.  All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions
      6  * are met:
      7  * 1. Redistributions of source code must retain the above copyright
      8  *    notice, this list of conditions and the following disclaimer.
      9  * 2. Redistributions in binary form must reproduce the above copyright
     10  *    notice, this list of conditions and the following disclaimer in the
     11  *    documentation and/or other materials provided with the distribution.
     12  *
     13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
     14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
     17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
     21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     24  */
     25 
     26 #ifndef npruntime_priv_h
     27 #define npruntime_priv_h
     28 
     29 #if PLATFORM(CHROMIUM)
     30 #include <bindings/npruntime.h>
     31 #else
     32 #include "npruntime.h"
     33 #endif
     34 
     35 #ifdef __cplusplus
     36 extern "C" {
     37 #endif
     38 
     39 /*
     40     _NPN_InitializeVariantWithStringCopy() will copy string data.  The string data
     41     will be deallocated by calls to NPReleaseVariantValue().
     42 */
     43 void _NPN_InitializeVariantWithStringCopy(NPVariant*, const NPString*);
     44 void _NPN_DeallocateObject(NPObject*);
     45 
     46 // The following routines allow the browser to aggressively cleanup NPObjects
     47 // on a per plugin basis.  All NPObjects used through the NPRuntime API should
     48 // be "registered" while they are alive.  After an object has been
     49 // deleted, it is possible for Javascript to have a reference to that object
     50 // which has not yet been garbage collected.  Javascript access to NPObjects
     51 // will reference this registry to determine if the object is accessible or
     52 // not.
     53 
     54 // Windows introduces an additional complication for objects created by the
     55 // plugin.  Plugins load inside of a DLL.  Each DLL has it's own heap.  If
     56 // the browser unloads the plugin DLL, all objects created within the DLL's
     57 // heap instantly become invalid.  Normally, when WebKit drops the reference
     58 // on the top-level plugin object, it tells the plugin manager that the
     59 // plugin can be destroyed, which can unload the DLL.  So, we must eliminate
     60 // all pointers to any object ever created by the plugin.
     61 
     62 // We generally associate NPObjects with an owner.  The owner of an NPObject
     63 // is an NPObject which, when destroyed, also destroys all objects it owns.
     64 // For example, if an NPAPI plugin creates 10 sub-NPObjects, all 11 objects
     65 // (the NPAPI plugin + its 10 sub-objects) should become inaccessible
     66 // simultaneously.
     67 
     68 // The ownership hierarchy is flat, and not a tree.  Imagine the following
     69 // object creation:
     70 //     PluginObject
     71 //          |
     72 //          +-- Creates -----> Object1
     73 //                                |
     74 //                                +-- Creates -----> Object2
     75 //
     76 // PluginObject will be the "owner" for both Object1 and Object2.
     77 
     78 // Register an NPObject with the runtime.  If the owner is NULL, the
     79 // object is treated as an owning object.  If owner is not NULL,
     80 // this object will be registered as owned by owner's top-level owner.
     81 void _NPN_RegisterObject(NPObject*, NPObject* owner);
     82 
     83 // Unregister an NPObject with the runtime.  If obj is an owning
     84 // object, this call will also unregister all of the owned objects.
     85 void _NPN_UnregisterObject(NPObject*);
     86 
     87 // Check to see if an object is registered with the runtime.
     88 // Return true if registered, false otherwise.
     89 bool _NPN_IsAlive(NPObject*);
     90 
     91 #ifdef __cplusplus
     92 }  /* end extern "C" */
     93 #endif
     94 
     95 #endif // npruntime_priv_h
     96