author Shih-Chiang Chien <>
Mon, 24 Apr 2017 11:09:35 +0800
changeset 587450 0425872587b4c64e80ce16ba2e91a6009a797fac
child 648192 c236dfe7dc98c387219d7cb45d0693560db708fd
child 694109 98e2b4ee9775a2a2b5cc1bb8a390bfe901814f38
permissions -rw-r--r--
Bug 1015466 - Part 3, PHttpBackgroundChannel lifecycle management. r=mayhemer PHttpBackgroundChannel is created by content process because PBackground IPDL can only be initiated from content process. The background channel deletion is controlled by chrome process while PHttpChannel is going to be closed or canceled. BackgroundChannelRegistrar is introduced for pairing HttpChannelParent and HttpBackgroundChannelParent since they are created over different IPDL asynchronously. nsIParentRedirectingChannel.continueVerification is introduced to asynchronously wait for background channel to be established on the new channel during the Redirect2Verify phase. MozReview-Commit-ID: 41l8ivan8iA

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at */

#ifndef mozilla_net_BackgroundChannelRegistrar_h__
#define mozilla_net_BackgroundChannelRegistrar_h__

#include "nsIBackgroundChannelRegistrar.h"
#include "nsRefPtrHashtable.h"

namespace mozilla {
namespace net {

class HttpBackgroundChannelParent;
class HttpChannelParent;

class BackgroundChannelRegistrar final : public nsIBackgroundChannelRegistrar
  typedef nsRefPtrHashtable<nsUint64HashKey, HttpChannelParent>
  typedef nsRefPtrHashtable<nsUint64HashKey, HttpBackgroundChannelParent>

  explicit BackgroundChannelRegistrar();

  virtual ~BackgroundChannelRegistrar();

  // A helper function for BackgroundChannelRegistrar itself to callback
  // HttpChannelParent and HttpBackgroundChannelParent when both objects are
  // ready. aChannelParent and aBgParent is the pair of HttpChannelParent and
  // HttpBackgroundChannelParent that should be linked together.
  void NotifyChannelLinked(HttpChannelParent* aChannelParent,
                           HttpBackgroundChannelParent* aBgParent);

  // Store unlinked HttpChannelParent objects.
  ChannelHashtable mChannels;

  // Store unlinked HttpBackgroundChannelParent objects.
  BackgroundChannelHashtable mBgChannels;


} // namespace net
} // namespace mozilla

#endif // mozilla_net_BackgroundChannelRegistrar_h__