LCOV - code coverage report
Current view: directory - netwerk/ipc - NeckoChild.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 61 0 0.0 %
Date: 2012-06-02 Functions: 15 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* vim: set sw=2 ts=8 et tw=80 : */
       3                 : 
       4                 : /* ***** BEGIN LICENSE BLOCK *****
       5                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       6                 :  *
       7                 :  * The contents of this file are subject to the Mozilla Public License Version
       8                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       9                 :  * the License. You may obtain a copy of the License at
      10                 :  * http://www.mozilla.org/MPL/
      11                 :  *
      12                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      13                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      14                 :  * for the specific language governing rights and limitations under the
      15                 :  * License.
      16                 :  *
      17                 :  * The Original Code is mozilla.org code.
      18                 :  *
      19                 :  * The Initial Developer of the Original Code is
      20                 :  *  The Mozilla Foundation
      21                 :  * Portions created by the Initial Developer are Copyright (C) 2009
      22                 :  * the Initial Developer. All Rights Reserved.
      23                 :  *
      24                 :  * Contributor(s):
      25                 :  *   Jason Duell <jduell.mcbugs@gmail.com>
      26                 :  *   Honza Bambas <honzab@firemni.cz>
      27                 :  *
      28                 :  * Alternatively, the contents of this file may be used under the terms of
      29                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      30                 :  * 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 "nsHttp.h"
      43                 : #include "mozilla/net/NeckoChild.h"
      44                 : #include "mozilla/dom/ContentChild.h"
      45                 : #include "mozilla/net/HttpChannelChild.h"
      46                 : #include "mozilla/net/CookieServiceChild.h"
      47                 : #include "mozilla/net/WyciwygChannelChild.h"
      48                 : #include "mozilla/net/FTPChannelChild.h"
      49                 : #include "mozilla/net/WebSocketChannelChild.h"
      50                 : 
      51                 : namespace mozilla {
      52                 : namespace net {
      53                 : 
      54                 : PNeckoChild *gNeckoChild = nsnull;
      55                 : 
      56                 : // C++ file contents
      57               0 : NeckoChild::NeckoChild()
      58                 : {
      59               0 : }
      60                 : 
      61               0 : NeckoChild::~NeckoChild()
      62                 : {
      63               0 : }
      64                 : 
      65               0 : void NeckoChild::InitNeckoChild()
      66                 : {
      67               0 :   NS_ABORT_IF_FALSE(IsNeckoChild(), "InitNeckoChild called by non-child!");
      68                 : 
      69               0 :   if (!gNeckoChild) {
      70                 :     mozilla::dom::ContentChild * cpc = 
      71               0 :       mozilla::dom::ContentChild::GetSingleton();
      72               0 :     NS_ASSERTION(cpc, "Content Protocol is NULL!");
      73               0 :     gNeckoChild = cpc->SendPNeckoConstructor(); 
      74               0 :     NS_ASSERTION(gNeckoChild, "PNecko Protocol init failed!");
      75                 :   }
      76               0 : }
      77                 : 
      78                 : // Note: not actually called; has some lifespan as child process, so
      79                 : // automatically destroyed at exit.  
      80               0 : void NeckoChild::DestroyNeckoChild()
      81                 : {
      82               0 :   NS_ABORT_IF_FALSE(IsNeckoChild(), "DestroyNeckoChild called by non-child!");
      83                 :   static bool alreadyDestroyed = false;
      84               0 :   NS_ABORT_IF_FALSE(!alreadyDestroyed, "DestroyNeckoChild already called!");
      85                 : 
      86               0 :   if (!alreadyDestroyed) {
      87               0 :     Send__delete__(gNeckoChild); 
      88               0 :     gNeckoChild = nsnull;
      89               0 :     alreadyDestroyed = true;
      90                 :   }
      91               0 : }
      92                 : 
      93                 : PHttpChannelChild* 
      94               0 : NeckoChild::AllocPHttpChannel(PBrowserChild* browser)
      95                 : {
      96                 :   // This constructor is only used when PHttpChannel is constructed by
      97                 :   // the parent process, e.g. during a redirect.  (Normally HttpChannelChild is
      98                 :   // created by nsHttpHandler::NewProxiedChannel(), and then creates the
      99                 :   // PHttpChannel in HttpChannelChild::AsyncOpen().)
     100                 : 
     101                 :   // No need to store PBrowser. It is only needed by the parent.
     102               0 :   HttpChannelChild* httpChannel = new HttpChannelChild();
     103               0 :   httpChannel->AddIPDLReference();
     104               0 :   return httpChannel;
     105                 : }
     106                 : 
     107                 : bool 
     108               0 : NeckoChild::DeallocPHttpChannel(PHttpChannelChild* channel)
     109                 : {
     110               0 :   NS_ABORT_IF_FALSE(IsNeckoChild(), "DeallocPHttpChannel called by non-child!");
     111                 : 
     112               0 :   HttpChannelChild* child = static_cast<HttpChannelChild*>(channel);
     113               0 :   child->ReleaseIPDLReference();
     114               0 :   return true;
     115                 : }
     116                 : 
     117                 : PFTPChannelChild*
     118               0 : NeckoChild::AllocPFTPChannel()
     119                 : {
     120                 :   // We don't allocate here: see FTPChannelChild::AsyncOpen()
     121               0 :   NS_RUNTIMEABORT("AllocPFTPChannel should not be called");
     122               0 :   return nsnull;
     123                 : }
     124                 : 
     125                 : bool
     126               0 : NeckoChild::DeallocPFTPChannel(PFTPChannelChild* channel)
     127                 : {
     128               0 :   NS_ABORT_IF_FALSE(IsNeckoChild(), "DeallocPFTPChannel called by non-child!");
     129                 : 
     130               0 :   FTPChannelChild* child = static_cast<FTPChannelChild*>(channel);
     131               0 :   child->ReleaseIPDLReference();
     132               0 :   return true;
     133                 : }
     134                 : 
     135                 : PCookieServiceChild* 
     136               0 : NeckoChild::AllocPCookieService()
     137                 : {
     138                 :   // We don't allocate here: see nsCookieService::GetSingleton()
     139               0 :   NS_NOTREACHED("AllocPCookieService should not be called");
     140               0 :   return nsnull;
     141                 : }
     142                 : 
     143                 : bool 
     144               0 : NeckoChild::DeallocPCookieService(PCookieServiceChild* cs)
     145                 : {
     146               0 :   NS_ASSERTION(IsNeckoChild(), "DeallocPCookieService called by non-child!");
     147                 : 
     148               0 :   CookieServiceChild *p = static_cast<CookieServiceChild*>(cs);
     149               0 :   p->Release();
     150               0 :   return true;
     151                 : }
     152                 : 
     153                 : PWyciwygChannelChild*
     154               0 : NeckoChild::AllocPWyciwygChannel()
     155                 : {
     156               0 :   WyciwygChannelChild *p = new WyciwygChannelChild();
     157               0 :   p->AddIPDLReference();
     158               0 :   return p;
     159                 : }
     160                 : 
     161                 : bool
     162               0 : NeckoChild::DeallocPWyciwygChannel(PWyciwygChannelChild* channel)
     163                 : {
     164               0 :   NS_ABORT_IF_FALSE(IsNeckoChild(), "DeallocPWyciwygChannel called by non-child!");
     165                 : 
     166               0 :   WyciwygChannelChild *p = static_cast<WyciwygChannelChild*>(channel);
     167               0 :   p->ReleaseIPDLReference();
     168               0 :   return true;
     169                 : }
     170                 : 
     171                 : PWebSocketChild*
     172               0 : NeckoChild::AllocPWebSocket(PBrowserChild* browser)
     173                 : {
     174               0 :   NS_NOTREACHED("AllocPWebSocket should not be called");
     175               0 :   return nsnull;
     176                 : }
     177                 : 
     178                 : bool
     179               0 : NeckoChild::DeallocPWebSocket(PWebSocketChild* child)
     180                 : {
     181               0 :   WebSocketChannelChild* p = static_cast<WebSocketChannelChild*>(child);
     182               0 :   p->ReleaseIPDLReference();
     183               0 :   return true;
     184                 : }
     185                 : 
     186                 : }} // mozilla::net
     187                 : 

Generated by: LCOV version 1.7