LCOV - code coverage report
Current view: directory - netwerk/protocol/websocket - BaseWebSocketChannel.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 82 0 0.0 %
Date: 2012-06-02 Functions: 16 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                 : /* ***** 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.
      17                 :  *
      18                 :  * The Initial Developer of the Original Code is
      19                 :  * Mozilla Foundation.
      20                 :  * Portions created by the Initial Developer are Copyright (C) 2011
      21                 :  * the Initial Developer. All Rights Reserved.
      22                 :  *
      23                 :  * Contributor(s):
      24                 :  *   Josh Matthews <josh@joshmatthews.net>
      25                 :  *
      26                 :  * Alternatively, the contents of this file may be used under the terms of
      27                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      28                 :  * or 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 "WebSocketLog.h"
      41                 : #include "BaseWebSocketChannel.h"
      42                 : #include "nsILoadGroup.h"
      43                 : #include "nsIInterfaceRequestor.h"
      44                 : #include "nsIURI.h"
      45                 : #include "nsAutoPtr.h"
      46                 : #include "nsStandardURL.h"
      47                 : 
      48                 : #if defined(PR_LOGGING)
      49                 : PRLogModuleInfo *webSocketLog = nsnull;
      50                 : #endif
      51                 : 
      52                 : namespace mozilla {
      53                 : namespace net {
      54                 : 
      55               0 : BaseWebSocketChannel::BaseWebSocketChannel()
      56               0 :   : mEncrypted(false)
      57                 : {
      58                 : #if defined(PR_LOGGING)
      59               0 :   if (!webSocketLog)
      60               0 :     webSocketLog = PR_NewLogModule("nsWebSocket");
      61                 : #endif
      62               0 : }
      63                 : 
      64                 : //-----------------------------------------------------------------------------
      65                 : // BaseWebSocketChannel::nsIWebSocketChannel
      66                 : //-----------------------------------------------------------------------------
      67                 : 
      68                 : NS_IMETHODIMP
      69               0 : BaseWebSocketChannel::GetOriginalURI(nsIURI **aOriginalURI)
      70                 : {
      71               0 :   LOG(("BaseWebSocketChannel::GetOriginalURI() %p\n", this));
      72                 : 
      73               0 :   if (!mOriginalURI)
      74               0 :     return NS_ERROR_NOT_INITIALIZED;
      75               0 :   NS_ADDREF(*aOriginalURI = mOriginalURI);
      76               0 :   return NS_OK;
      77                 : }
      78                 : 
      79                 : NS_IMETHODIMP
      80               0 : BaseWebSocketChannel::GetURI(nsIURI **aURI)
      81                 : {
      82               0 :   LOG(("BaseWebSocketChannel::GetURI() %p\n", this));
      83                 : 
      84               0 :   if (!mOriginalURI)
      85               0 :     return NS_ERROR_NOT_INITIALIZED;
      86               0 :   if (mURI)
      87               0 :     NS_ADDREF(*aURI = mURI);
      88                 :   else
      89               0 :     NS_ADDREF(*aURI = mOriginalURI);
      90               0 :   return NS_OK;
      91                 : }
      92                 : 
      93                 : NS_IMETHODIMP
      94               0 : BaseWebSocketChannel::
      95                 : GetNotificationCallbacks(nsIInterfaceRequestor **aNotificationCallbacks)
      96                 : {
      97               0 :   LOG(("BaseWebSocketChannel::GetNotificationCallbacks() %p\n", this));
      98               0 :   NS_IF_ADDREF(*aNotificationCallbacks = mCallbacks);
      99               0 :   return NS_OK;
     100                 : }
     101                 : 
     102                 : NS_IMETHODIMP
     103               0 : BaseWebSocketChannel::
     104                 : SetNotificationCallbacks(nsIInterfaceRequestor *aNotificationCallbacks)
     105                 : {
     106               0 :   LOG(("BaseWebSocketChannel::SetNotificationCallbacks() %p\n", this));
     107               0 :   mCallbacks = aNotificationCallbacks;
     108               0 :   return NS_OK;
     109                 : }
     110                 : 
     111                 : NS_IMETHODIMP
     112               0 : BaseWebSocketChannel::GetLoadGroup(nsILoadGroup **aLoadGroup)
     113                 : {
     114               0 :   LOG(("BaseWebSocketChannel::GetLoadGroup() %p\n", this));
     115               0 :   NS_IF_ADDREF(*aLoadGroup = mLoadGroup);
     116               0 :   return NS_OK;
     117                 : }
     118                 : 
     119                 : NS_IMETHODIMP
     120               0 : BaseWebSocketChannel::SetLoadGroup(nsILoadGroup *aLoadGroup)
     121                 : {
     122               0 :   LOG(("BaseWebSocketChannel::SetLoadGroup() %p\n", this));
     123               0 :   mLoadGroup = aLoadGroup;
     124               0 :   return NS_OK;
     125                 : }
     126                 : 
     127                 : NS_IMETHODIMP
     128               0 : BaseWebSocketChannel::GetExtensions(nsACString &aExtensions)
     129                 : {
     130               0 :   LOG(("BaseWebSocketChannel::GetExtensions() %p\n", this));
     131               0 :   aExtensions = mNegotiatedExtensions;
     132               0 :   return NS_OK;
     133                 : }
     134                 : 
     135                 : NS_IMETHODIMP
     136               0 : BaseWebSocketChannel::GetProtocol(nsACString &aProtocol)
     137                 : {
     138               0 :   LOG(("BaseWebSocketChannel::GetProtocol() %p\n", this));
     139               0 :   aProtocol = mProtocol;
     140               0 :   return NS_OK;
     141                 : }
     142                 : 
     143                 : NS_IMETHODIMP
     144               0 : BaseWebSocketChannel::SetProtocol(const nsACString &aProtocol)
     145                 : {
     146               0 :   LOG(("BaseWebSocketChannel::SetProtocol() %p\n", this));
     147               0 :   mProtocol = aProtocol;                        /* the sub protocol */
     148               0 :   return NS_OK;
     149                 : }
     150                 : 
     151                 : //-----------------------------------------------------------------------------
     152                 : // BaseWebSocketChannel::nsIProtocolHandler
     153                 : //-----------------------------------------------------------------------------
     154                 : 
     155                 : 
     156                 : NS_IMETHODIMP
     157               0 : BaseWebSocketChannel::GetScheme(nsACString &aScheme)
     158                 : {
     159               0 :   LOG(("BaseWebSocketChannel::GetScheme() %p\n", this));
     160                 : 
     161               0 :   if (mEncrypted)
     162               0 :     aScheme.AssignLiteral("wss");
     163                 :   else
     164               0 :     aScheme.AssignLiteral("ws");
     165               0 :   return NS_OK;
     166                 : }
     167                 : 
     168                 : NS_IMETHODIMP
     169               0 : BaseWebSocketChannel::GetDefaultPort(PRInt32 *aDefaultPort)
     170                 : {
     171               0 :   LOG(("BaseWebSocketChannel::GetDefaultPort() %p\n", this));
     172                 : 
     173               0 :   if (mEncrypted)
     174               0 :     *aDefaultPort = kDefaultWSSPort;
     175                 :   else
     176               0 :     *aDefaultPort = kDefaultWSPort;
     177               0 :   return NS_OK;
     178                 : }
     179                 : 
     180                 : NS_IMETHODIMP
     181               0 : BaseWebSocketChannel::GetProtocolFlags(PRUint32 *aProtocolFlags)
     182                 : {
     183               0 :   LOG(("BaseWebSocketChannel::GetProtocolFlags() %p\n", this));
     184                 : 
     185                 :   *aProtocolFlags = URI_NORELATIVE | URI_NON_PERSISTABLE | ALLOWS_PROXY | 
     186               0 :       ALLOWS_PROXY_HTTP | URI_DOES_NOT_RETURN_DATA | URI_DANGEROUS_TO_LOAD;
     187               0 :   return NS_OK;
     188                 : }
     189                 : 
     190                 : NS_IMETHODIMP
     191               0 : BaseWebSocketChannel::NewURI(const nsACString & aSpec, const char *aOriginCharset,
     192                 :                              nsIURI *aBaseURI, nsIURI **_retval NS_OUTPARAM)
     193                 : {
     194               0 :   LOG(("BaseWebSocketChannel::NewURI() %p\n", this));
     195                 : 
     196                 :   PRInt32 port;
     197               0 :   nsresult rv = GetDefaultPort(&port);
     198               0 :   if (NS_FAILED(rv))
     199               0 :     return rv;
     200                 : 
     201               0 :   nsRefPtr<nsStandardURL> url = new nsStandardURL();
     202               0 :   rv = url->Init(nsIStandardURL::URLTYPE_AUTHORITY, port, aSpec,
     203               0 :                 aOriginCharset, aBaseURI);
     204               0 :   if (NS_FAILED(rv))
     205               0 :     return rv;
     206               0 :   NS_ADDREF(*_retval = url);
     207               0 :   return NS_OK;
     208                 : }
     209                 : 
     210                 : NS_IMETHODIMP
     211               0 : BaseWebSocketChannel::NewChannel(nsIURI *aURI, nsIChannel **_retval NS_OUTPARAM)
     212                 : {
     213               0 :   LOG(("BaseWebSocketChannel::NewChannel() %p\n", this));
     214               0 :   return NS_ERROR_NOT_IMPLEMENTED;
     215                 : }
     216                 : 
     217                 : NS_IMETHODIMP
     218               0 : BaseWebSocketChannel::AllowPort(PRInt32 port, const char *scheme,
     219                 :                                 bool *_retval NS_OUTPARAM)
     220                 : {
     221               0 :   LOG(("BaseWebSocketChannel::AllowPort() %p\n", this));
     222                 : 
     223                 :   // do not override any blacklisted ports
     224               0 :   *_retval = false;
     225               0 :   return NS_OK;
     226                 : }
     227                 : 
     228                 : } // namespace net
     229                 : } // namespace mozilla

Generated by: LCOV version 1.7