netwerk/base/src/RedirectChannelRegistrar.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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