netwerk/base/src/RedirectChannelRegistrar.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #include "RedirectChannelRegistrar.h"
     7 namespace mozilla {
     8 namespace net {
    10 NS_IMPL_ISUPPORTS(RedirectChannelRegistrar, nsIRedirectChannelRegistrar)
    12 RedirectChannelRegistrar::RedirectChannelRegistrar()
    13   : mRealChannels(64)
    14   , mParentChannels(64)
    15   , mId(1)
    16 {
    17 }
    19 NS_IMETHODIMP
    20 RedirectChannelRegistrar::RegisterChannel(nsIChannel *channel,
    21                                           uint32_t *_retval)
    22 {
    23   mRealChannels.Put(mId, channel);
    24   *_retval = mId;
    26   ++mId;
    28   // Ensure we always provide positive ids
    29   if (!mId)
    30     mId = 1;
    32   return NS_OK;
    33 }
    35 NS_IMETHODIMP
    36 RedirectChannelRegistrar::GetRegisteredChannel(uint32_t id,
    37                                                nsIChannel **_retval)
    38 {
    39   if (!mRealChannels.Get(id, _retval))
    40     return NS_ERROR_NOT_AVAILABLE;
    42   return NS_OK;
    43 }
    45 NS_IMETHODIMP
    46 RedirectChannelRegistrar::LinkChannels(uint32_t id,
    47                                        nsIParentChannel *channel,
    48                                        nsIChannel** _retval)
    49 {
    50   if (!mRealChannels.Get(id, _retval))
    51     return NS_ERROR_NOT_AVAILABLE;
    53   mParentChannels.Put(id, channel);
    54   return NS_OK;
    55 }
    57 NS_IMETHODIMP
    58 RedirectChannelRegistrar::GetParentChannel(uint32_t id,
    59                                            nsIParentChannel **_retval)
    60 {
    61   if (!mParentChannels.Get(id, _retval))
    62     return NS_ERROR_NOT_AVAILABLE;
    64   return NS_OK;
    65 }
    67 NS_IMETHODIMP
    68 RedirectChannelRegistrar::DeregisterChannels(uint32_t id)
    69 {
    70   mRealChannels.Remove(id);
    71   mParentChannels.Remove(id);
    72   return NS_OK;
    73 }
    75 }
    76 }

mercurial