LCOV - code coverage report
Current view: directory - js/xpconnect/src - XPCRuntimeService.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 52 31 59.6 %
Date: 2012-06-02 Functions: 12 7 58.3 %

       1                 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
       2                 :  *
       3                 :  * ***** BEGIN LICENSE BLOCK *****
       4                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       5                 :  *
       6                 :  * The contents of this file are subject to the Mozilla Public License Version
       7                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       8                 :  * the License. You may obtain a copy of the License at
       9                 :  * http://www.mozilla.org/MPL/
      10                 :  *
      11                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      12                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      13                 :  * for the specific language governing rights and limitations under the
      14                 :  * License.
      15                 :  *
      16                 :  * The Original Code is Mozilla Communicator client code, released
      17                 :  * March 31, 1998.
      18                 :  *
      19                 :  * The Initial Developer of the Original Code is
      20                 :  * Netscape Communications Corporation.
      21                 :  * Portions created by the Initial Developer are Copyright (C) 1999
      22                 :  * the Initial Developer. All Rights Reserved.
      23                 :  *
      24                 :  * Contributor(s):
      25                 :  *   Mike Shaver <shaver@mozilla.org>
      26                 :  *   John Bandhauer <jband@netscape.com>
      27                 :  *
      28                 :  * Alternatively, the contents of this file may be used under the terms of
      29                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      30                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      31                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      32                 :  * of those above. If you wish to allow use of your version of this file only
      33                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      34                 :  * use your version of this file under the terms of the MPL, indicate your
      35                 :  * decision by deleting the provisions above and replace them with the notice
      36                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      37                 :  * the provisions above, a recipient may use your version of this file under
      38                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      39                 :  *
      40                 :  * ***** END LICENSE BLOCK ***** */
      41                 : 
      42                 : #include "xpcprivate.h"
      43                 : 
      44                 : #include "mozilla/dom/workers/Workers.h"
      45                 : using mozilla::dom::workers::ResolveWorkerClasses;
      46                 : 
      47         3974114 : NS_INTERFACE_MAP_BEGIN(BackstagePass)
      48         3974114 :   NS_INTERFACE_MAP_ENTRY(nsIXPCScriptable)
      49         3893421 :   NS_INTERFACE_MAP_ENTRY(nsIClassInfo)
      50         3866987 :   NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
      51          117664 :   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIXPCScriptable)
      52           91170 : NS_INTERFACE_MAP_END_THREADSAFE
      53                 : 
      54         3923986 : NS_IMPL_THREADSAFE_ADDREF(BackstagePass)
      55         3923928 : NS_IMPL_THREADSAFE_RELEASE(BackstagePass)
      56                 : 
      57                 : // The nsIXPCScriptable map declaration that will generate stubs for us...
      58                 : #define XPC_MAP_CLASSNAME           BackstagePass
      59                 : #define XPC_MAP_QUOTED_CLASSNAME   "BackstagePass"
      60                 : #define                             XPC_MAP_WANT_NEWRESOLVE
      61                 : #define XPC_MAP_FLAGS       nsIXPCScriptable::USE_JSSTUB_FOR_ADDPROPERTY   |  \
      62                 :                             nsIXPCScriptable::USE_JSSTUB_FOR_DELPROPERTY   |  \
      63                 :                             nsIXPCScriptable::USE_JSSTUB_FOR_SETPROPERTY   |  \
      64                 :                             nsIXPCScriptable::DONT_ENUM_STATIC_PROPS       |  \
      65                 :                             nsIXPCScriptable::DONT_ENUM_QUERY_INTERFACE    |  \
      66                 :                             nsIXPCScriptable::IS_GLOBAL_OBJECT             |  \
      67                 :                             nsIXPCScriptable::DONT_REFLECT_INTERFACE_NAMES
      68                 : #include "xpc_map_end.h" /* This will #undef the above */
      69                 : 
      70                 : /* bool newResolve (in nsIXPConnectWrappedNative wrapper, in JSContextPtr cx, in JSObjectPtr obj, in jsval id, in PRUint32 flags, out JSObjectPtr objp); */
      71                 : NS_IMETHODIMP
      72          878208 : BackstagePass::NewResolve(nsIXPConnectWrappedNative *wrapper,
      73                 :                           JSContext * cx, JSObject * obj,
      74                 :                           jsid id, PRUint32 flags,
      75                 :                           JSObject * *objp, bool *_retval)
      76                 : {
      77                 :     JSBool resolved;
      78                 : 
      79          878208 :     *_retval = !!JS_ResolveStandardClass(cx, obj, id, &resolved);
      80          878208 :     if (!*_retval)
      81               0 :         return NS_OK;
      82                 : 
      83          878208 :     if (resolved) {
      84           10635 :         *objp = obj;
      85           10635 :         return NS_OK;
      86                 :     }
      87                 : 
      88          867573 :     *_retval = !!ResolveWorkerClasses(cx, obj, id, flags, objp);
      89          867573 :     return NS_OK;
      90                 : }
      91                 : 
      92                 : /***************************************************************************/
      93                 : /* void getInterfaces (out PRUint32 count, [array, size_is (count), retval]
      94                 :                        out nsIIDPtr array); */
      95                 : NS_IMETHODIMP
      96            1398 : BackstagePass::GetInterfaces(PRUint32 *aCount, nsIID * **aArray)
      97                 : {
      98            1398 :     const PRUint32 count = 2;
      99            1398 :     *aCount = count;
     100                 :     nsIID **array;
     101            1398 :     *aArray = array = static_cast<nsIID**>(nsMemory::Alloc(count * sizeof(nsIID*)));
     102            1398 :     if (!array)
     103               0 :         return NS_ERROR_OUT_OF_MEMORY;
     104                 : 
     105            1398 :     PRUint32 index = 0;
     106                 :     nsIID* clone;
     107                 : #define PUSH_IID(id)                                                          \
     108                 :     clone = static_cast<nsIID *>(nsMemory::Clone(&NS_GET_IID( id ),           \
     109                 :                                                  sizeof(nsIID)));             \
     110                 :     if (!clone)                                                               \
     111                 :         goto oom;                                                             \
     112                 :     array[index++] = clone;
     113                 : 
     114            1398 :     PUSH_IID(nsIXPCScriptable)
     115            1398 :     PUSH_IID(nsIScriptObjectPrincipal)
     116                 : #undef PUSH_IID
     117                 : 
     118            1398 :     return NS_OK;
     119                 : oom:
     120               0 :     while (index)
     121               0 :         nsMemory::Free(array[--index]);
     122               0 :     nsMemory::Free(array);
     123               0 :     *aArray = nsnull;
     124               0 :     return NS_ERROR_OUT_OF_MEMORY;
     125                 : }
     126                 : 
     127                 : /* nsISupports getHelperForLanguage (in PRUint32 language); */
     128                 : NS_IMETHODIMP
     129           13217 : BackstagePass::GetHelperForLanguage(PRUint32 language,
     130                 :                                     nsISupports **retval)
     131                 : {
     132           13217 :     *retval = nsnull;
     133           13217 :     return NS_OK;
     134                 : }
     135                 : 
     136                 : /* readonly attribute string contractID; */
     137                 : NS_IMETHODIMP
     138               0 : BackstagePass::GetContractID(char * *aContractID)
     139                 : {
     140               0 :     *aContractID = nsnull;
     141               0 :     return NS_ERROR_NOT_AVAILABLE;
     142                 : }
     143                 : 
     144                 : /* readonly attribute string classDescription; */
     145                 : NS_IMETHODIMP
     146               0 : BackstagePass::GetClassDescription(char * *aClassDescription)
     147                 : {
     148                 :     static const char classDescription[] = "BackstagePass";
     149               0 :     *aClassDescription = (char*)nsMemory::Clone(classDescription, sizeof(classDescription));
     150               0 :     return *aClassDescription ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
     151                 : }
     152                 : 
     153                 : /* readonly attribute nsCIDPtr classID; */
     154                 : NS_IMETHODIMP
     155               0 : BackstagePass::GetClassID(nsCID * *aClassID)
     156                 : {
     157               0 :     *aClassID = nsnull;
     158               0 :     return NS_OK;
     159                 : }
     160                 : 
     161                 : /* readonly attribute PRUint32 implementationLanguage; */
     162                 : NS_IMETHODIMP
     163               0 : BackstagePass::GetImplementationLanguage(PRUint32 *aImplementationLanguage)
     164                 : {
     165               0 :     *aImplementationLanguage = nsIProgrammingLanguage::CPLUSPLUS;
     166               0 :     return NS_OK;
     167                 : }
     168                 : 
     169                 : /* readonly attribute PRUint32 flags; */
     170                 : NS_IMETHODIMP
     171           13217 : BackstagePass::GetFlags(PRUint32 *aFlags)
     172                 : {
     173           13217 :     *aFlags = nsIClassInfo::THREADSAFE;
     174           13217 :     return NS_OK;
     175                 : }
     176                 : 
     177                 : /* [notxpcom] readonly attribute nsCID classIDNoAlloc; */
     178                 : NS_IMETHODIMP
     179               0 : BackstagePass::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc)
     180                 : {
     181               0 :     return NS_ERROR_NOT_AVAILABLE;
     182                 : }

Generated by: LCOV version 1.7