LCOV - code coverage report
Current view: directory - dom/plugins/ipc - PluginIdentifierParent.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 35 0 0.0 %
Date: 2012-06-02 Functions: 4 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
       2                 :  * vim: sw=2 ts=2 et :
       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 Plugins.
      17                 :  *
      18                 :  * The Initial Developer of the Original Code is
      19                 :  *   Mozilla Foundation.
      20                 :  * Portions created by the Initial Developer are Copyright (C) 2010
      21                 :  * the Initial Developer. All Rights Reserved.
      22                 :  *
      23                 :  * Contributor(s):
      24                 :  *   Ben Turner <bent.mozilla@gmail.com>
      25                 :  *
      26                 :  * Alternatively, the contents of this file may be used under the terms of
      27                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      28                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      29                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      30                 :  * of those above. If you wish to allow use of your version of this file only
      31                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      32                 :  * use your version of this file under the terms of the MPL, indicate your
      33                 :  * decision by deleting the provisions above and replace them with the notice
      34                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      35                 :  * the provisions above, a recipient may use your version of this file under
      36                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      37                 :  *
      38                 :  * ***** END LICENSE BLOCK ***** */
      39                 : 
      40                 : #include "PluginIdentifierParent.h"
      41                 : 
      42                 : #include "nsServiceManagerUtils.h"
      43                 : #include "nsNPAPIPlugin.h"
      44                 : #include "nsIJSContextStack.h"
      45                 : #include "PluginScriptableObjectUtils.h"
      46                 : #include "mozilla/unused.h"
      47                 : 
      48                 : using namespace mozilla::plugins::parent;
      49                 : 
      50                 : namespace mozilla {
      51                 : namespace plugins {
      52                 : 
      53                 : bool
      54               0 : PluginIdentifierParent::RecvRetain()
      55                 : {
      56               0 :   mTemporaryRefs = 0;
      57                 : 
      58                 :   // Intern the jsid if necessary.
      59               0 :   jsid id = NPIdentifierToJSId(mIdentifier);
      60               0 :   if (JSID_IS_INT(id)) {
      61               0 :     return true;
      62                 :   }
      63                 : 
      64                 :   // The following is what nsNPAPIPlugin.cpp does. Gross, but the API doesn't
      65                 :   // give you a NPP to play with.
      66                 :   nsCOMPtr<nsIThreadJSContextStack> stack =
      67               0 :     do_GetService("@mozilla.org/js/xpc/ContextStack;1");
      68               0 :   if (!stack) {
      69               0 :     return false;
      70                 :   }
      71                 : 
      72               0 :   JSContext *cx = nsnull;
      73               0 :   stack->GetSafeJSContext(&cx);
      74               0 :   if (!cx) {
      75               0 :     return false;
      76                 :   }
      77                 : 
      78               0 :   JSAutoRequest ar(cx);
      79               0 :   JSString* str = JSID_TO_STRING(id);
      80               0 :   JSString* str2 = JS_InternJSString(cx, str);
      81               0 :   if (!str2) {
      82               0 :     return false;
      83                 :   }
      84                 : 
      85               0 :   NS_ASSERTION(str == str2, "Interning a string in a JSID should always return the same string.");
      86                 : 
      87               0 :   return true;
      88                 : }
      89                 : 
      90               0 : PluginIdentifierParent::StackIdentifier::StackIdentifier
      91                 :     (PluginInstanceParent* inst, NPIdentifier aIdentifier)
      92               0 :   : mIdentifier(inst->Module()->GetIdentifierForNPIdentifier(inst->GetNPP(), aIdentifier))
      93                 : {
      94               0 : }
      95                 : 
      96               0 : PluginIdentifierParent::StackIdentifier::StackIdentifier
      97                 :     (NPObject* aObject, NPIdentifier aIdentifier)
      98               0 :   : mIdentifier(NULL)
      99                 : {
     100               0 :   PluginInstanceParent* inst = GetInstance(aObject);
     101               0 :   mIdentifier = inst->Module()->GetIdentifierForNPIdentifier(inst->GetNPP(), aIdentifier);
     102               0 : }
     103                 : 
     104               0 : PluginIdentifierParent::StackIdentifier::~StackIdentifier()
     105                 : {
     106               0 :   if (!mIdentifier) {
     107               0 :     return;
     108                 :   }
     109                 : 
     110               0 :   if (!mIdentifier->IsTemporary()) {
     111               0 :     return;
     112                 :   }
     113                 : 
     114               0 :   if (mIdentifier->RemoveTemporaryRef()) {
     115               0 :     unused << PPluginIdentifierParent::Send__delete__(mIdentifier);
     116                 :   }
     117               0 : }
     118                 : 
     119                 : } // namespace mozilla::plugins
     120                 : } // namespace mozilla

Generated by: LCOV version 1.7