netwerk/protocol/rtsp/RtspHandler.cpp

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

     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 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #include "RtspChannelChild.h"
     8 #include "RtspChannelParent.h"
     9 #include "RtspHandler.h"
    10 #include "nsILoadGroup.h"
    11 #include "nsIInterfaceRequestor.h"
    12 #include "nsIURI.h"
    13 #include "nsAutoPtr.h"
    14 #include "nsStandardURL.h"
    15 #include "mozilla/net/NeckoChild.h"
    17 namespace mozilla {
    18 namespace net {
    20 NS_IMPL_ISUPPORTS(RtspHandler, nsIProtocolHandler)
    22 //-----------------------------------------------------------------------------
    23 // RtspHandler::nsIProtocolHandler
    24 //-----------------------------------------------------------------------------
    26 NS_IMETHODIMP
    27 RtspHandler::GetScheme(nsACString &aScheme)
    28 {
    29   aScheme.AssignLiteral("rtsp");
    30   return NS_OK;
    31 }
    33 NS_IMETHODIMP
    34 RtspHandler::GetDefaultPort(int32_t *aDefaultPort)
    35 {
    36   *aDefaultPort = kDefaultRtspPort;
    37   return NS_OK;
    38 }
    40 NS_IMETHODIMP
    41 RtspHandler::GetProtocolFlags(uint32_t *aProtocolFlags)
    42 {
    43   *aProtocolFlags = URI_NORELATIVE | URI_NOAUTH | URI_INHERITS_SECURITY_CONTEXT |
    44     URI_LOADABLE_BY_ANYONE | URI_NON_PERSISTABLE | URI_SYNC_LOAD_IS_OK;
    46   return NS_OK;
    47 }
    49 NS_IMETHODIMP
    50 RtspHandler::NewURI(const nsACString & aSpec,
    51                     const char *aOriginCharset,
    52                     nsIURI *aBaseURI, nsIURI **aResult)
    53 {
    54   int32_t port;
    56   nsresult rv = GetDefaultPort(&port);
    57   NS_ENSURE_SUCCESS(rv, rv);
    59   nsRefPtr<nsStandardURL> url = new nsStandardURL();
    60   rv = url->Init(nsIStandardURL::URLTYPE_AUTHORITY, port, aSpec,
    61                  aOriginCharset, aBaseURI);
    62   NS_ENSURE_SUCCESS(rv, rv);
    64   url.forget(aResult);
    65   return NS_OK;
    66 }
    68 NS_IMETHODIMP
    69 RtspHandler::NewChannel(nsIURI *aURI, nsIChannel **aResult)
    70 {
    71   bool isRtsp = false;
    72   nsRefPtr<nsBaseChannel> rtspChannel;
    74   nsresult rv = aURI->SchemeIs("rtsp", &isRtsp);
    75   NS_ENSURE_SUCCESS(rv, rv);
    76   NS_ENSURE_TRUE(isRtsp, NS_ERROR_UNEXPECTED);
    78   if (IsNeckoChild()) {
    79     rtspChannel = new RtspChannelChild(aURI);
    80   } else {
    81     rtspChannel = new RtspChannelParent(aURI);
    82   }
    84   rv = rtspChannel->Init();
    85   NS_ENSURE_SUCCESS(rv, rv);
    87   rtspChannel.forget(aResult);
    88   return NS_OK;
    89 }
    91 NS_IMETHODIMP
    92 RtspHandler::AllowPort(int32_t port, const char *scheme, bool *aResult)
    93 {
    94   // Do not override any blacklisted ports.
    95   *aResult = false;
    96   return NS_OK;
    97 }
    99 } // namespace net
   100 } // namespace mozilla

mercurial